Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzplayercameravehicles.c
Go to the documentation of this file.
1 // *************************************************************************************
2 // ! DayZPlayerCamera1stPersonVehicle - first person in vehicle
3 // *************************************************************************************
4 class 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;
27  const float CONST_ANGULAR_VELOCITY_STRENGTH = 0.025;
28 
29  const float CONST_ANGULAR_LAG_YAW_STRENGTH = 4.0;
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 
67  m_fLagOffsetVelocityX[0] = 0;
68  m_fLagOffsetVelocityY[0] = 0;
69  m_fLagOffsetVelocityZ[0] = 0;
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  {
102  vector posDiffWS = GetVelocity(vehicle) * CONST_LINEAR_VELOCITY_STRENGTH;
103  posDiffLS = posDiffWS.InvMultiply3(playerTransformWS);
104 
105  vector rotDiffWS = dBodyGetAngularVelocity(vehicle) * Math.RAD2DEG * CONST_ANGULAR_VELOCITY_STRENGTH;
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 
114  m_LagOffsetOrientation[0] = Math.SmoothCD(m_LagOffsetOrientation[0], rotDiffLS[1], m_fLagOffsetVelocityYaw, 0.3, 1000, pDt);
115  m_LagOffsetOrientation[1] = Math.SmoothCD(m_LagOffsetOrientation[1], rotDiffLS[2], m_fLagOffsetVelocityPitch, 0.3, 1000, pDt);
116  m_LagOffsetOrientation[2] = Math.SmoothCD(m_LagOffsetOrientation[2], rotDiffLS[0], m_fLagOffsetVelocityRoll, 0.3, 1000, pDt);
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;
154  a[1] = m_fLeftRightAngleAdd;
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 }
m_fUpDownAngleAdd
protected float m_fUpDownAngleAdd
up down angle in rad
Definition: dayzplayercameravehicles.c:165
GetGame
proto native CGame GetGame()
CONST_UD_MIN
class DayZPlayerCamera1stPersonVehicle extends DayZPlayerCamera1stPerson CONST_UD_MIN
down limit
OnUpdate
override void OnUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
Definition: dayzplayercameravehicles.c:72
m_fLagOffsetVelocityRoll
protected float m_fLagOffsetVelocityRoll[1]
Definition: dayzplayercameravehicles.c:177
UpdateUDAngleUnlocked
float UpdateUDAngleUnlocked(out float pAngle, out float pAngleAdd, float pMin, float pMax, float pDt)
Definition: dayzplayercamera_base.c:129
DayZPlayerCamera
class DayZPlayerCameraResult DayZPlayerCamera(DayZPlayer pPlayer, HumanInputController pInput)
Definition: dayzplayer.c:56
m_CameraOffsetMS
protected vector m_CameraOffsetMS
runtime config
Definition: dayzplayercameravehicles.c:160
CONST_ANGULAR_LAG_YAW_STRENGTH
const float CONST_ANGULAR_LAG_YAW_STRENGTH
Definition: dayzplayercameravehicles.c:29
m_Transport
protected Transport m_Transport
cache
Definition: dayzplayercameravehicles.c:180
m_fDistance
protected float m_fDistance
distance from start
Definition: dayzplayercameravehicles.c:161
m_fUpDownAngle
protected float m_fUpDownAngle
runtime values
Definition: dayzplayercameravehicles.c:164
UpdateLRAngleUnlocked
float UpdateLRAngleUnlocked(out float pAngle, out float pAngleAdd, float pMin, float pMax, float pDt)
Definition: dayzplayercamera_base.c:170
m_fLagOffsetVelocityYaw
protected float m_fLagOffsetVelocityYaw[1]
Definition: dayzplayercameravehicles.c:175
DayZPlayer
Definition: dayzplayerimplement.c:72
m_LagOffsetPosition
protected vector m_LagOffsetPosition
lag offsets
Definition: dayzplayercameravehicles.c:170
IEntity
Definition: enentity.c:164
m_fLeftRightAngleAdd
protected float m_fLeftRightAngleAdd
left right angle in rad
Definition: dayzplayercameravehicles.c:167
OnActivate
override void OnActivate(DayZPlayerCamera pPrevCamera, DayZPlayerCameraResult pPrevCameraResult)
Definition: dayzplayercameravehicles.c:53
m_pPlayer
protected DayZPlayer m_pPlayer
data
Definition: dayzplayer.c:135
vector
Definition: enconvert.c:105
m_CurrentCameraPitch
protected float m_CurrentCameraPitch
Definition: dayzplayercamera_base.c:559
DayZPlayerCamera1stPerson
Definition: dayzplayercameravehicles.c:4
DayZPlayerCameraResult
Definition: dayzplayer.c:11
m_fLagOffsetVelocityPitch
protected float m_fLagOffsetVelocityPitch[1]
Definition: dayzplayercameravehicles.c:176
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
HumanInputController
Definition: human.c:17
DayZPlayerCamera3rdPersonVehicle
void DayZPlayerCamera3rdPersonVehicle(DayZPlayer pPlayer, HumanInputController pInput)
Definition: dayzplayercameravehicles.c:33
HumanCommandVehicle
Definition: human.c:689
CONST_ANGULAR_LAG_ROLL_STRENGTH
const float CONST_ANGULAR_LAG_ROLL_STRENGTH
Definition: dayzplayercameravehicles.c:31
GetBaseAngles
override vector GetBaseAngles()
Definition: dayzplayercameravehicles.c:141
DayZPlayerCameraBase
this is main camera class
Definition: dayzplayercamera1stperson.c:4
m_fLeftRightAngle
protected float m_fLeftRightAngle
left right angle in rad
Definition: dayzplayercameravehicles.c:166
m_fLagOffsetVelocityZ
protected float m_fLagOffsetVelocityZ[1]
Definition: dayzplayercameravehicles.c:174
dBodyGetAngularVelocity
proto vector dBodyGetAngularVelocity(notnull IEntity body)
Gets angular velocity for a rigidbody.
GetAdditiveAngles
override vector GetAdditiveAngles()
Definition: dayzplayercameravehicles.c:150
CONST_ANGULAR_VELOCITY_STRENGTH
const float CONST_ANGULAR_VELOCITY_STRENGTH
Definition: dayzplayercameravehicles.c:27
m_CurrentCameraYaw
protected float m_CurrentCameraYaw
Definition: dayzplayercamera_base.c:558
m_fLagOffsetVelocityX
protected float m_fLagOffsetVelocityX[1]
Definition: dayzplayercameravehicles.c:172
CONST_LINEAR_VELOCITY_STRENGTH
const float CONST_LINEAR_VELOCITY_STRENGTH
Definition: dayzplayercameravehicles.c:26
StdFovUpdate
void StdFovUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
Definition: dayzplayercamera_base.c:295
Math
Definition: enmath.c:6
GetCurrentOrientation
vector GetCurrentOrientation()
Definition: dayzplayer.c:112
GetVelocity
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
m_CurrentCameraRoll
protected float m_CurrentCameraRoll
Definition: dayzplayercamera_base.c:560
Math3D
Definition: enmath3d.c:27
CONST_ANGULAR_LAG_PITCH_STRENGTH
const float CONST_ANGULAR_LAG_PITCH_STRENGTH
Definition: dayzplayercameravehicles.c:30
m_LagOffsetOrientation
protected vector m_LagOffsetOrientation
Definition: dayzplayercameravehicles.c:171
m_fLagOffsetVelocityY
protected float m_fLagOffsetVelocityY[1]
Definition: dayzplayercameravehicles.c:173