Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CameraBase.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Camera", description: "Scripted camera", color: "128 000 255 255")]
3 {
4 };
5 
9 class SCR_CameraBase: CameraBase
10 {
11  [Attribute(desc: "Show debug shape in World Editor even when the entity is not selected.")]
12  protected bool m_bShowDebugViewCone;
13 
20  bool IsInView(vector worldPos, WorkspaceWidget workspace = null)
21  {
22  if (!workspace)
23  workspace = GetGame().GetWorkspace();
24 
25  return IsInView(worldPos, workspace.GetWidth() / (float)workspace.GetHeight());
26  }
33  bool IsInView(vector worldPos, float aspectRatio)
34  {
35  vector localPos = CoordToLocal(worldPos);
36  float angleV = SCR_Math.DeltaAngle(Math.Atan2(localPos[2], localPos[1]) * Math.RAD2DEG, 90);
37  float angleH = SCR_Math.DeltaAngle(Math.Atan2(localPos[2], localPos[0]) * Math.RAD2DEG, 90);
38 
39  float fovV = GetVerticalFOV() / 2;
40  float fovH = Math.Atan2(Math.Tan(fovV * Math.DEG2RAD) * aspectRatio, 1) * Math.RAD2DEG;
41 
42  return Math.InverseLerp(-fovV, fovV, angleV) < 1 && Math.InverseLerp(-fovH, fovH, angleH) < 1;
43  }
44 
49  private ref ScriptInvoker Event_EOnActivate = new ScriptInvoker;
54  private ref ScriptInvoker Event_EOnDeactivate = new ScriptInvoker;
59  private ref ScriptInvoker Event_CameraActivate = new ScriptInvoker;
64  private ref ScriptInvoker Event_CameraDeactivate = new ScriptInvoker;
65 
66  ScriptInvoker GetOnActivate()
67  {
68  return Event_EOnActivate;
69  }
70  ScriptInvoker GetOnDeactivate()
71  {
72  return Event_EOnDeactivate;
73  }
74  ScriptInvoker GetOnCameraActivate()
75  {
76  return Event_CameraActivate;
77  }
78  ScriptInvoker GetOnCameraDeactivate()
79  {
80  return Event_CameraDeactivate;
81  }
82 
83  override void EOnActivate(IEntity owner)
84  {
85  super.EOnActivate(owner);
86 
87  Event_EOnActivate.Invoke();
88  }
89  override void EOnDeactivate(IEntity owner)
90  {
91  super.EOnDeactivate(owner);
92 
93  if (Event_EOnDeactivate) //--- Invoker may be null when the entity is being deleted
94  Event_EOnDeactivate.Invoke();
95  }
96  override void CameraActivate()
97  {
98  Event_CameraActivate.Invoke();
99  }
100  override void CameraDeactivate()
101  {
102  Event_CameraDeactivate.Invoke();
103  }
104 
105 #ifdef WORKBENCH
106  override void _WB_AfterWorldUpdate(float timeSlice)
107  {
108  WorldEditorAPI api = _WB_GetEditorAPI();
109  if (!api || (!api.IsEntitySelected(api.EntityToSource(this)) && !m_bShowDebugViewCone))
110  return;
111 
112  float length = GetFarPlane();
113  float height = Math.Tan(GetVerticalFOV() / 2 * Math.DEG2RAD) * length;
114  float width = height * (api.GetScreenWidth() / api.GetScreenHeight());
115 
116  vector transform[4];
117  GetTransform(transform);
118 
119  vector points[12];
120 
121  //--- Top
122  points[0] = transform[3];
123  points[1] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * width;
124  points[2] = transform[3] + transform[2] * length + transform[1] * height + transform[0] * -width;
125 
126  //--- Right
127  points[3] = points[0];
128  points[4] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * width;
129  points[5] = points[1];
130 
131  //--- Bottom
132  points[6] = points[0];
133  points[7] = transform[3] + transform[2] * length + transform[1] * -height + transform[0] * -width;
134  points[8] = points[4];
135 
136  //--- Left
137  points[9] = points[0];
138  points[10] = points[2];
139  points[11] = points[7];
140 
141  Shape.CreateTris(ARGBF(0.25, 0.5, 0, 1), ShapeFlags.ONCE | ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE, points, 4);
142  }
143 #endif
144 };
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CameraBaseClass
Definition: SCR_CameraBase.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_Math
Definition: SCR_Math.c:1
GetFarPlane
proto external float GetFarPlane()
SCR_CameraBase
Definition: SCR_CameraBase.c:9
Attribute
typedef Attribute
Post-process effect of scripted camera.
GetVerticalFOV
proto external float GetVerticalFOV()
CameraBaseClass
Definition: CameraBase.c:12
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180