Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
ScriptCamera.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameLib/Scripted"
, description:
"Script camera"
)]
2
class
ScriptCameraClass
: GenericEntityClass
3
{
4
5
}
6
7
class
ScriptCamera
:
GenericEntity
8
{
9
[
Attribute
(
"60"
,
UIWidgets
.Slider,
"Field of view"
,
"0 180 1"
)]
10
float
FOV;
11
[
Attribute
(
"1"
,
UIWidgets
.EditBox,
"Near plane clip"
)]
12
float
NearPlane;
13
[
Attribute
(
"4000"
,
UIWidgets
.EditBox,
"Far plane clip"
)]
14
float
FarPlane
;
15
16
[
Attribute
(
"1"
,
UIWidgets
.ComboBox,
"Projection type"
,
""
, enumType:
CameraType
)]
17
int
Type
;
18
[
Attribute
(
"5"
,
UIWidgets
.Slider,
"Camera speed"
,
"0 20 1"
)]
19
float
Speed
;
20
[
Attribute
(
"1"
,
UIWidgets
.CheckBox,
"Free Fly"
,
""
)]
21
bool
FreeFly
;
22
[
Attribute
(
"0"
,
UIWidgets
.CheckBox,
"Invert vertical"
,
""
)]
23
bool
Inverted
;
24
[
Attribute
(
"0"
,
UIWidgets
.Slider,
"Camera index"
,
"0 31 1"
)]
25
int
Index
;
26
[
Attribute
(
"0"
,
UIWidgets
.CheckBox,
"Enable preload"
,
""
)]
27
bool
EnablePreload
;
28
float
m_MouseSensitivity
= 0.001;
// should be somewhere else.
29
float
m_GamepadSensitivity
= 0.2;
// should be somewhere else.
30
int
m_GamepadFreeFly
;
31
32
// debug variables
33
int
m_DbgListSelection
= 0;
34
ref array<string>
m_DbgOptions
= {
"Perspective"
,
"Orthographic"
};
35
36
void
ScriptCamera
(
IEntitySource
src,
IEntity
parent)
37
{
38
SetFlags
(
EntityFlags
.ACTIVE,
false
);
39
SetEventMask
(
EntityEvent
.POSTFRAME);
40
41
BaseWorld
world =
GetWorld
();
42
world.SetCameraVerticalFOV(
Index
, FOV);
43
world.SetCameraFarPlane(
Index
,
FarPlane
);
44
world.SetCameraNearPlane(
Index
, NearPlane);
45
world.SetCameraType(
Index
,
Type
);
46
m_DbgListSelection
=
Type
- 1;
47
world.SetCamera(
Index
,
GetOrigin
(),
GetYawPitchRoll
());
48
vector
camMat[4];
49
GetTransform
(camMat);
50
world.SetCameraEx(
Index
, camMat);
51
if
(
EnablePreload
)
52
world.SchedulePreload(
GetOrigin
(), 500);
53
m_GamepadFreeFly
=
FreeFly
;
54
}
55
56
override
protected
void
EOnPostFrame
(
IEntity
owner,
float
timeSlice)
//EntityEvent.FRAME
57
{
58
g_Game
.GetInputManager().ActivateContext(
"ScriptCameraContext"
);
59
60
if
(
g_Game
.GetInputManager().GetActionTriggered(
"CamFreeFly"
))
61
{
62
FreeFly
= !
FreeFly
;
63
}
64
65
if
(
FreeFly
)
66
{
67
FreeFly
(timeSlice);
68
}
69
else
70
{
71
vector
camMat[4];
// matrix can be set outside the class
72
GetWorldTransform
(camMat);
73
GetWorld
().SetCameraEx(
Index
, camMat);
74
}
75
76
// DebugInfo();
77
}
78
79
protected
void
FreeFly
(
float
timeSlice)
80
{
81
vector
camPosition =
GetOrigin
();
82
vector
angles
=
GetYawPitchRoll
();
83
vector
camMat[4];
84
GetTransform
(camMat);
85
InputManager
imanager =
g_Game
.GetInputManager();
86
imanager.ActivateContext(
"ScriptCameraFreeFlyContext"
);
87
88
// get input
89
float
turnX = imanager.GetActionValue(
"CamTurnRight"
) * 20.0 * timeSlice;
90
float
turnY = imanager.GetActionValue(
"CamTurnUp"
) * 20.0 * timeSlice;
91
float
turnZ = imanager.GetActionValue(
"CamRotate"
) * 20.0 * timeSlice;
92
float
moveForward = imanager.GetActionValue(
"CamForward"
);
93
float
moveRight = imanager.GetActionValue(
"CamRight"
);
94
float
moveAscend = imanager.GetActionValue(
"CamAscend"
);
95
float
speedDelta = imanager.GetActionValue(
"CamSpeedDelta"
) * timeSlice;
96
bool
speedBoostHigh = imanager.GetActionTriggered(
"CamSpeedBoostHigh"
);
97
bool
speedBoostLow = imanager.GetActionTriggered(
"CamSpeedBoostLow"
);
98
99
Speed
=
Math
.Clamp(
Speed
+ speedDelta *
Speed
* 0.25, 0.1, 1000.0);
100
101
float
finalSpeed =
Speed
;
102
if
(speedBoostHigh)
103
finalSpeed *= 25;
104
else
if
(speedBoostLow)
105
finalSpeed *= 5;
106
107
// rotation
108
angles
[0] = turnX +
angles
[0];
109
if
(
Inverted
)
110
angles
[1] = turnY +
angles
[1];
111
else
112
angles
[1] = -turnY +
angles
[1];
113
114
angles
[2] = turnZ +
angles
[2];
115
116
// movement
117
vector
move =
vector
.Zero;
118
vector
forward = camMat[2];
119
vector
up = camMat[1];
120
vector
side = camMat[0];
121
122
move += forward * moveForward;
123
move += side * moveRight;
124
move += up * moveAscend;
125
126
// ------------
127
camPosition = (move * timeSlice * finalSpeed) + camPosition;
128
129
Math3D
.AnglesToMatrix(
angles
, camMat);
130
camMat[3] = camPosition;
131
SetTransform
(camMat);
132
GetWorld
().SetCameraEx(
Index
, camMat);
133
}
134
135
protected
void
DebugInfo
()
136
{
137
InputManager
imanager =
g_Game
.GetInputManager();
138
DbgUI
.Begin(
String
(
"Camera #"
+
Index
.ToString()), 0,
Index
* 300);
139
140
DbgUI
.Text(
String
(
"Position : "
+
GetOrigin
().
ToString
()));
141
DbgUI
.Text(
String
(
"Orientation (Y, P, R): "
+
GetYawPitchRoll
().
ToString
()));
142
DbgUI
.Text(
String
(
"Speed : "
+
Speed
.ToString()));
143
DbgUI
.Text(
String
(
"Mouse sensitivity : "
+ (2000 - (1 /
m_MouseSensitivity
)).
ToString
()));
144
DbgUI
.Check(
"Select Free fly"
,
FreeFly
);
145
DbgUI
.List(
"Camera type"
,
m_DbgListSelection
,
m_DbgOptions
);
146
if
(
m_DbgListSelection
+ 1 !=
Type
)
147
{
148
Type
=
m_DbgListSelection
+ 1;
149
GetWorld
().SetCameraType(
Index
,
Type
);
150
}
151
152
float
sensitivity = 2000 - (1 /
m_MouseSensitivity
);
153
DbgUI
.SliderFloat(
"Mouse sensitivity"
, sensitivity, 1, 1999);
154
m_MouseSensitivity
= 1 / (2000 - sensitivity);
155
156
DbgUI
.Text(
"CamTurnRight: "
+ imanager.GetActionValue(
"CamTurnRight"
));
157
DbgUI
.Text(
"CamTurnUp: "
+ imanager.GetActionValue(
"CamTurnUp"
));
158
DbgUI
.Text(
"CamSpeedDelta: "
+ imanager.GetActionValue(
"CamSpeedDelta"
));
159
DbgUI
.Text(
"CamForward: "
+ imanager.GetActionValue(
"CamForward"
));
160
DbgUI
.Text(
"CamRight: "
+imanager.GetActionValue(
"CamRight"
));
161
DbgUI
.Text(
"CamAscend: "
+ imanager.GetActionValue(
"CamAscend"
));
162
DbgUI
.Text(
"CamSpeedBoostHigh: "
+ imanager.GetActionTriggered(
"CamSpeedBoostHigh"
));
163
DbgUI
.Text(
"CamSpeedBoostLow:"
+ imanager.GetActionTriggered(
"CamSpeedBoostLow"
));
164
165
DbgUI
.End();
166
}
167
}
Index
int Index
Definition
worldEditor.c:28
angles
ref array< string > angles
Definition
PrefabImporter.c:22
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
EnablePreload
bool EnablePreload
Definition
ScriptCamera.c:27
FarPlane
float FarPlane
Definition
ScriptCamera.c:14
m_MouseSensitivity
float m_MouseSensitivity
Definition
ScriptCamera.c:28
m_GamepadSensitivity
float m_GamepadSensitivity
Definition
ScriptCamera.c:29
Speed
float Speed
Definition
ScriptCamera.c:19
ScriptCamera
void ScriptCamera(IEntitySource src, IEntity parent)
Definition
ScriptCamera.c:36
Inverted
bool Inverted
Definition
ScriptCamera.c:23
m_DbgListSelection
int m_DbgListSelection
Definition
ScriptCamera.c:33
FreeFly
bool FreeFly
Definition
ScriptCamera.c:21
m_GamepadFreeFly
int m_GamepadFreeFly
Definition
ScriptCamera.c:30
m_DbgOptions
ref array< string > m_DbgOptions
Definition
ScriptCamera.c:34
Type
int Type
Definition
ScriptCamera.c:17
DebugInfo
void DebugInfo()
Definition
ScriptCamera.c:135
BaseWorld
Definition
BaseWorld.c:13
DbgUI
Definition
DbgUI.c:66
GenericEntity
Definition
GenericEntity.c:16
IEntity
Definition
IEntity.c:13
IEntity::SetEventMask
proto external EntityEvent SetEventMask(EntityEvent e)
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetYawPitchRoll
proto external vector GetYawPitchRoll()
IEntity::EOnPostFrame
void EOnPostFrame(IEntity owner, float timeSlice)
IEntity::GetWorldTransform
proto external void GetWorldTransform(out vector mat[])
See IEntity::GetTransform.
IEntity::GetWorld
proto external BaseWorld GetWorld()
IEntity::SetTransform
proto external bool SetTransform(vector mat[4])
IEntity::SetFlags
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
IEntity::GetTransform
proto external void GetTransform(out vector mat[])
IEntitySource
Definition
IEntitySource.c:13
InputManager
Input management system for user interactions.
Definition
InputManager.c:20
Math3D
Definition
Math3D.c:13
Math
Definition
Math.c:13
ScriptCameraClass
Definition
ScriptCamera.c:3
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
g_Game
Game g_Game
Game singleton instance.
Definition
gameLib.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
EntityFlags
EntityFlags
Various entity flags.
Definition
EntityFlags.c:14
ToString
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
String
string String(string s)
Definition
Types.c:14
CameraType
CameraType
Definition
CameraType.c:14
scripts
GameLib
entities
ScriptCamera.c
Generated by
1.17.0