DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
DayZPlayerCameraVehicles.c
Go to the documentation of this file.
1// *************************************************************************************
2// ! DayZPlayerCamera1stPersonVehicle - first person in vehicle
3// *************************************************************************************
4class DayZPlayerCamera1stPersonVehicle extends DayZPlayerCamera1stPerson
5{
6 override void OnUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
7 {
8 super.OnUpdate(pDt, pOutResult);
9
10 pOutResult.m_fUseHeading = 0.0;
11 pOutResult.m_bUpdateEveryFrame = GetGame().IsPhysicsExtrapolationEnabled();
12 }
13}
14
15// *************************************************************************************
16// ! DayZPlayerCamera3rdPersonVehicle - 3rd person in vehicle (generic)
17// *************************************************************************************
19{
20 static const float CONST_UD_MIN = -85.0;
21 static const float CONST_UD_MAX = 85.0;
22
23 static const float CONST_LR_MIN = -160.0;
24 static const float CONST_LR_MAX = 160.0;
25
26 const float CONST_LINEAR_VELOCITY_STRENGTH = 0.025;
28
32
34 {
35 //Print("new camera: DayZPlayerCamera3rdPersonVehicle");
36
37 m_fDistance = 4.0;
38 m_CameraOffsetMS = "0.0 1.3 0.0";
39
40 HumanCommandVehicle vehicleCommand = pPlayer.GetCommand_Vehicle();
41 if ( vehicleCommand )
42 {
43 Transport transport = vehicleCommand.GetTransport();
44 if ( transport )
45 {
46 m_Transport = transport;
47 m_fDistance = transport.GetTransportCameraDistance();
48 m_CameraOffsetMS = transport.GetTransportCameraOffset();
49 }
50 }
51 }
52
53 override void OnActivate( DayZPlayerCamera pPrevCamera, DayZPlayerCameraResult pPrevCameraResult )
54 {
55 if (pPrevCamera)
56 {
57 vector baseAngles = pPrevCamera.GetBaseAngles();
58 m_fUpDownAngle = baseAngles[0];
59 m_fLeftRightAngle = baseAngles[1];
60
61 vector addAngles = pPrevCamera.GetAdditiveAngles();
62 m_fUpDownAngleAdd = addAngles[0];
63 m_fLeftRightAngleAdd = addAngles[1];
64 }
65
70 }
71
72 override void OnUpdate( float pDt, out DayZPlayerCameraResult pOutResult )
73 {
75 vector playerTransformWS[4];
76 m_pPlayer.GetTransform(playerTransformWS);
77
79 IEntity vehicle = m_Transport;
80 pOutResult.m_CollisionIgnoreEntity = vehicle;
81
83 vector cameraPosition = vector.Zero;
84 if ( vehicle )
85 {
86 vector vehiclePositionWS = vehicle.GetOrigin();
87 vector vehiclePositionMS = vehiclePositionWS.InvMultiply4(playerTransformWS);
88 cameraPosition = vehiclePositionMS + m_CameraOffsetMS;
89 }
90
95
97 vector posDiffLS = vector.Zero;
98 vector rotDiffLS = vector.Zero;
99
100 if ( vehicle )
101 {
103 posDiffLS = posDiffWS.InvMultiply3(playerTransformWS);
104
106 rotDiffLS = rotDiffWS.InvMultiply3(playerTransformWS);
107 }
108
110 m_LagOffsetPosition[0] = Math.SmoothCD(m_LagOffsetPosition[0], posDiffLS[0], m_fLagOffsetVelocityX, 0.3, 1000, pDt);
111 m_LagOffsetPosition[1] = Math.SmoothCD(m_LagOffsetPosition[1], posDiffLS[1], m_fLagOffsetVelocityY, 0.3, 1000, pDt);
112 m_LagOffsetPosition[2] = Math.SmoothCD(m_LagOffsetPosition[2], posDiffLS[2], m_fLagOffsetVelocityZ, 0.3, 1000, pDt);
113
117
119 vector rot;
123
124 Math3D.YawPitchRollMatrix(GetCurrentOrientation() + rot, pOutResult.m_CameraTM);
125
127 pOutResult.m_CameraTM[3] = cameraPosition - m_LagOffsetPosition;
128
130 pOutResult.m_fDistance = m_fDistance;
131 pOutResult.m_fUseHeading = 0.0;
132 pOutResult.m_fInsideCamera = 0.0;
133 pOutResult.m_fIgnoreParentRoll = 1.0;
134 pOutResult.m_bUpdateEveryFrame = GetGame().IsPhysicsExtrapolationEnabled();
135
136 StdFovUpdate(pDt, pOutResult);
137
138 super.OnUpdate(pDt, pOutResult);
139 }
140
142 {
143 vector a;
144 a[0] = m_fUpDownAngle;
145 a[1] = m_fLeftRightAngle;
146 a[2] = 0;
147 return a;
148 }
149
151 {
152 vector a;
153 a[0] = m_fUpDownAngleAdd;
155 a[2] = 0;
156 return a;
157 }
158
161 protected float m_fDistance;
162
164 protected float m_fUpDownAngle;
165 protected float m_fUpDownAngleAdd;
166 protected float m_fLeftRightAngle;
167 protected float m_fLeftRightAngleAdd;
168
172 protected float m_fLagOffsetVelocityX[1];
173 protected float m_fLagOffsetVelocityY[1];
174 protected float m_fLagOffsetVelocityZ[1];
175 protected float m_fLagOffsetVelocityYaw[1];
176 protected float m_fLagOffsetVelocityPitch[1];
177 protected float m_fLagOffsetVelocityRoll[1];
178
181}
static const float CONST_UD_MAX
up limit
protected float m_fUpDownAngleAdd
up down angle in rad
static const float CONST_LR_MIN
down limit
protected float m_fLeftRightAngle
left right angle in rad (in freelook only)
static const float CONST_LR_MAX
up limit
protected float m_fUpDownAngle
up down angle in rad
protected float m_fLeftRightAngleAdd
left right angle in rad (in freelook only)
static const float CONST_UD_MIN
down limit
protected vector m_CameraOffsetMS
model space offset
float UpdateLRAngleUnlocked(out float pAngle, out float pAngleAdd, float pMin, float pMax, float pDt)
protected float m_CurrentCameraPitch
float UpdateUDAngleUnlocked(out float pAngle, out float pAngleAdd, float pMin, float pMax, float pDt)
void StdFovUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
protected float m_CurrentCameraYaw
protected float m_CurrentCameraRoll
protected float m_fLagOffsetVelocityX[1]
void DayZPlayerCamera3rdPersonVehicle(DayZPlayer pPlayer, HumanInputController pInput)
const float CONST_ANGULAR_LAG_ROLL_STRENGTH
const float CONST_ANGULAR_VELOCITY_STRENGTH
protected float m_fLagOffsetVelocityY[1]
const float CONST_ANGULAR_LAG_PITCH_STRENGTH
protected float m_fLagOffsetVelocityPitch[1]
protected vector m_LagOffsetOrientation
protected float m_fLagOffsetVelocityZ[1]
protected float m_fLagOffsetVelocityRoll[1]
protected Transport m_Transport
cache
protected vector m_LagOffsetPosition
lag offsets
const float CONST_ANGULAR_LAG_YAW_STRENGTH
protected float m_fLagOffsetVelocityYaw[1]
const float CONST_LINEAR_VELOCITY_STRENGTH
proto native bool IsPhysicsExtrapolationEnabled()
If physics extrapolation is enabled, always true on retail release builds.
override void OnUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
this is main camera class
override vector GetAdditiveAngles()
protected float m_fUpDownAngleAdd
up down angle in rad
protected float m_fLeftRightAngle
left right angle in rad (in freelook only)
protected float m_fUpDownAngle
up down angle in rad
protected float m_fLeftRightAngleAdd
left right angle in rad (in freelook only)
protected vector m_CameraOffsetMS
model space offset
protected float m_fDistance
distance from start
proto native Transport GetTransport()
Definition EnMath.c:7
Base native class for all motorized wheeled vehicles.
Definition Car.c:80
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
static const vector Zero
Definition EnConvert.c:110
proto vector InvMultiply4(vector mat[4])
Invert-transforms position.
float m_fDistance
camera distance (external cameras only)
Definition dayzplayer.c:63
protected DayZPlayer m_pPlayer
data
Definition dayzplayer.c:135
class DayZPlayerCameraResult DayZPlayerCamera(DayZPlayer pPlayer, HumanInputController pInput)
Definition dayzplayer.c:56
vector GetCurrentOrientation()
Definition dayzplayer.c:112
proto native CGame GetGame()
proto native external vector GetOrigin()
Returns origin of Entity.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
static proto float SmoothCD(float val, float target, inout float velocity[], float smoothTime, float maxVelocity, float dt)
Does the CD smoothing function - easy in | easy out / S shaped smoothing.
static const float RAD2DEG
Definition EnMath.c:16
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto vector dBodyGetAngularVelocity(notnull IEntity body)
Gets angular velocity for a rigidbody.
proto native void OnUpdate()
Definition tools.c:338
class HumanMovementState OnActivate()
HumanCommandScript fully scriptable command.
Definition human.c:1169