Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditorMetaStruct.c
Go to the documentation of this file.
1 
7 {
8  protected float pX; //--- Camera pos X
9  protected float pY; //--- Camera pos Y
10  protected float pZ; //--- Camera pos Z
11  protected float qX; //--- Camera quaternion X
12  protected float qY; //--- Camera quaternion Y
13  protected float qZ; //--- Camera quaternion Z
14  protected float qW; //--- Camera quaternion W
15 
16  void Serialize()
17  {
18  SCR_ManualCamera camera = SCR_CameraEditorComponent.GetCameraInstance();
19  if (camera)
20  {
21  vector transform[4];
22  camera.GetWorldTransform(transform);
23 
24  pX = transform[3][0];
25  pY = transform[3][1];
26  pZ = transform[3][2];
27 
28  float quat[4];
29  Math3D.MatrixToQuat(transform, quat);
30  qX = quat[0];
31  qY = quat[1];
32  qZ = quat[2];
33  qW = quat[3];
34  }
35  }
36  void Deserialize()
37  {
38  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
39  if (editorManager)
40  {
41  //--- Editor manager exists, load camera directly
42  OnEditorManagerCreated(editorManager);
43  }
44  else
45  {
46  //--- Editor manager does not exist yet (e.g., on mission start), wait for it to be created
48  if (core)
49  core.Event_OnEditorManagerInitOwner.Insert(OnEditorManagerCreated);
50  }
51  }
52  void ClearCache()
53  {
54  pX = 0;
55  pY = 0;
56  pZ = 0;
57  qX = 0;
58  qY = 0;
59  qZ = 0;
60  qW = 0;
61  }
62  protected void OnEditorManagerCreated(SCR_EditorManagerEntity editorManager)
63  {
64  //--- Wait one frame for editor modes to be initialized
65  GetGame().GetCallqueue().CallLater(OnEditorManagerCreatedDelayed, 1, false);
66  }
67  protected void OnEditorManagerCreatedDelayed()
68  {
70  if (!editorCameraManager)
71  return;
72 
73  SCR_ManualCamera camera = editorCameraManager.GetCamera();
74  if (camera)
75  //--- Camera exists, load it directly
76  OnCameraCreated(camera);
77  else
78  //--- Camera does not exist (e.g., editor not opened yet), wait for it to be created
79  editorCameraManager.GetOnCameraCreate().Insert(OnCameraCreated);
80 
82  if (core)
83  core.Event_OnEditorManagerInitOwner.Remove(OnEditorManagerCreated);
84  }
85  protected void OnCameraCreated(SCR_ManualCamera camera)
86  {
87  vector transform[4];
88  transform[3] = Vector(pX, pY, pZ);
89 
90  if (transform[3] != vector.Zero)
91  {
92  float quat[4];
93  quat[0] = qX;
94  quat[1] = qY;
95  quat[2] = qZ;
96  quat[3] = qW;
97  Math3D.QuatToMatrix(quat, transform);
98 
99  camera.SetTransform(transform);
100  }
101 
103  if (editorCameraManager)
104  editorCameraManager.GetOnCameraCreate().Remove(OnCameraCreated);
105  }
106  void Log()
107  {
108  float quat[4];
109  quat[0] = qX;
110  quat[1] = qY;
111  quat[2] = qZ;
112  quat[3] = qW;
113  vector angles = Math3D.QuatToAngles(quat);
114 
115  PrintFormat(" SCR_EditorMetaStruct: cam pos: %1 | cam ang: %2", Vector(pX, pY, pZ), angles);
116  }
117  void SCR_EditorMetaStruct()
118  {
119  RegV("pX");
120  RegV("pY");
121  RegV("pZ");
122  RegV("qX");
123  RegV("qY");
124  RegV("qZ");
125  RegV("qW");
126  }
127 }
SCR_ManualCamera
Definition: SCR_ManualCamera.c:16
SCR_EditorMetaStruct
Definition: SCR_EditorMetaStruct.c:6
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CameraEditorComponent
Definition: SCR_CameraEditorComponent.c:13
JsonApiStruct
Parameters for joining server.
Definition: FeedbackDialogUI.c:2
SCR_EditorManagerCore
Core component to manage SCR_EditorManagerEntity.
Definition: SCR_EditorManagerCore.c:5
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26