DayZ 1.24
Loading...
Searching...
No Matches
DayZPlayerCamera3rdPerson.c
Go to the documentation of this file.
1// *************************************************************************************
2// ! DayZPlayerCamera3rdPerson - base for 3rd person cameras
3// *************************************************************************************
5{
6 static const float CONST_UD_MIN = -85.0;
7 static const float CONST_UD_MAX = 85.0;
8
9 static const float CONST_LR_MIN = -160.0;
10 static const float CONST_LR_MAX = 160.0;
11
13 {
14 if (pInput.Camera3rdIsRightShoulder())
16 else
18
22 m_fLeanDistance = 0.3;
24 }
25
26
27 //
43
44 //
46 {
47 m_pPlayer.GetMovementState(m_MovementState);
48
52
54
55 // update l/r offsets and set it as
58 else
60
62
65
67 if (m_iBoneIndex != -1)
68 pOutResult.m_CameraTM[3] = m_pPlayer.GetBonePositionMS(m_iBoneIndex);
69 else
70 pOutResult.m_CameraTM[3] = "0 0 0";
71
75
78 else
80
81 // ls offset + ms offset + shoulder width
82 pOutResult.m_CameraTM[3] = pOutResult.m_CameraTM[3] + pOutResult.m_CameraTM[0] * lsOffset[0] + pOutResult.m_CameraTM[1] * lsOffset[1] + pOutResult.m_CameraTM[2] * lsOffset[2] + msOffset;
83
85 pOutResult.m_fDistance = m_fDistance;
86 pOutResult.m_fUseHeading = 1.0;
87 pOutResult.m_fInsideCamera = 0.0;
88 pOutResult.m_fPredictCollisionRadius = m_fPredictCollisionRadius;
89
93 }
94
96 {
97 vector a;
98 a[0] = m_fUpDownAngle;
99 a[1] = m_fLeftRightAngle;
100 a[2] = 0;
101 return a;
102 }
103
105 {
106 vector a;
107 a[0] = m_fUpDownAngleAdd;
109 a[2] = 0;
110 return a;
111 }
112
113 override string GetCameraName()
114 {
115 return "DayZPlayerCamera3rdPerson";
116 }
117
119 protected int m_iBoneIndex = -1;
122 protected float m_fDistance;
123 protected float m_fShoulderWidth;
124 protected bool m_bShoulderInLS;
125 protected float m_fRoll;
126 protected float m_fLeanDistance;
127
128
130 protected float m_fUpDownAngle;
131 protected float m_fUpDownAngleAdd;
132 protected float m_fLeftRightAngle;
133 protected float m_fLeftRightAngleAdd;
134
136 protected float m_fCameraLRShoulder; // -1..1 shoulderness :)
137 protected float m_fCameraLRShoulderVel[1]; // 0
138
141
144}
145
146
147// *************************************************************************************
148// ! DayZPlayerCamera3rdPersonErc - 3rd person erected
149// *************************************************************************************
151{
154 //Print("new camera: DayZPlayerCamera3rdPersonErc");
155
157 m_CameraOffsetMS = "0.0 1.4 0.0";
158 m_CameraOffsetLS = "0.0 0.3 0.0";
161 }
162}
163
164
165// *************************************************************************************
166// ! DayZPlayerCamera3rdPersonJump - 3rd person jump
167// *************************************************************************************
169{
171 {
172 //Print("new camera: DayZPlayerCamera3rdPersonJump");
173
175 m_fDelay = 0.15;
176 m_fDamping = 0.25;
177
179 m_fJumpStartY = pPlayer.GetOrigin()[1];
180 m_fJumpOffset = 0;
181 m_fDelayTimer = 0;
182 }
183
184 //
186 {
187 super.OnUpdate(pDt, pOutResult);
188
189 float yPos = m_pPlayer.GetOrigin()[1];
190 float yDiff = yPos - m_fJumpStartY;
191 yDiff = Math.Clamp(yDiff, 0.0, 2.0);
194 {
197 }
198 else
200
201 float newY = pOutResult.m_CameraTM[3][1] - m_fJumpOffset;
202 pOutResult.m_CameraTM[3][1] = newY;
203 }
204
206 float m_fDelay;
208
214}
215
216// *************************************************************************************
217// ! DayZPlayerCamera3rdPersonJump - 3rd person jump
218// *************************************************************************************
220{
223 //Print("new camera: DayZPlayerCamera3rdPersonClimb");
224 m_fDistance = 1.0;
225 m_CameraOffsetMS = "0.0 0.3 -0.6";
226 m_iBoneIndex = pPlayer.GetBoneIndexByName("Spine");
228 }
229}
230
231// *************************************************************************************
232// ! DayZPlayerCamera3rdPersonErc - 3rd person erected sprint
233// *************************************************************************************
235{
237 {
238 //Print("new camera: DayZPlayerCamera3rdPersonErcSpr");
239
240 m_fDistance = 2.0;
241 m_CameraOffsetMS = "0.0 1.3 0.0";
242 m_CameraOffsetLS = "0.0 0.3 0.0";
243 m_fShoulderWidth = 0.15;
244
245 m_iPelvisBone = pPlayer.GetBoneIndexByName("Pelvis");
246 if (m_iPelvisBone == -1)
247 Print("DayZPlayerCamera3rdPersonErcSpr: hips bone not found");
248
249 m_fTime = 0.0;
250 }
252
253 //
255 {
256 m_fTime += pDt * 5;
257
260 m_pPlayer.GetBoneTransformLS(m_iPelvisBone, tm);
262 float xShift = tm[1][0];
263 m_CurrentCameraRoll = xShift * 3.0; // 3 is just made up value i like :)
265 // m_CurrentCameraRoll = (sin(1.5 * m_fTime)); // + 0.3 * sin(3.6 * m_fTime) + 0.2 * sin(0.7 * m_fTime)) / 1.3 * 3;
268 super.OnUpdate(pDt, pOutResult);
270 //pOutResult.m_fFovMultiplier = 1.2;
274 protected int m_iPelvisBone;
275 protected float m_fTime;
276
280// *************************************************************************************
281// ! DayZPlayerCamera3rdPersonErcRaised - 3rd person erected raised
282// *************************************************************************************
287 //Print("new camera: DayZPlayerCamera3rdPersonErcRaised");
289
290 if (pPlayer.GetCurrentPerItemCameraUD() == DayZPlayerCameras.PERITEMUD_EMPTYHANDED)
291 {
292 // no item in hands
293 m_fDistance = 1.2;
294 m_fShoulderWidth = 0.4;
295 m_CameraOffsetMS = "0.0 1.3 0.2";
296 m_CameraOffsetLS = "0.0 0.3 0.0";
297
298 }
299 else if (pPlayer.GetCurrentPerItemCameraUD() == DayZPlayerCameras.PERITEMUD_TWOHANDED)
300 {
301 // two handed
302 m_fDistance = 1.2;
303 m_fShoulderWidth = 0.4;
304 m_CameraOffsetMS = "0.0 1.3 0.2";
305 m_CameraOffsetLS = "0.0 0.3 0.0";
306 }
307 else if (pPlayer.GetCurrentPerItemCameraUD() == DayZPlayerCameras.PERITEMUD_ONEHANDED)
308 {
309 // one handed
310 m_fDistance = 1.2;
311 m_fShoulderWidth = 0.4;
312 m_CameraOffsetMS = "0.0 1.3 0.2";
313 m_CameraOffsetLS = "0.0 0.3 0.0";
314 }
315 else
316 {
317 // weapons in hands
318 m_fDistance = 0.8;
319 m_CameraOffsetMS = "0.0 1.3 0.2";
320 m_CameraOffsetLS = "0.0 0.3 0.0";
321 m_fShoulderWidth = 0.5;
322 }
323 }
325 override bool IsCamera3rdRaised()
326 {
327 return true;
328 }
329}
330
331
332// *************************************************************************************
333// ! DayZPlayerCamera3rdPersonErcRaised - 3rd person erected raised
334// *************************************************************************************
336{
338 {
340 pInput.Override3rdIsRightShoulder(HumanInputControllerOverrideType.ENABLED, pInput.Camera3rdIsRightShoulder());
341 }
342}
343
344
345// *************************************************************************************
346// ! DayZPlayerCamera3rdPersonCrouch - 3rd person crouch
347// *************************************************************************************
349{
350 static const float CONST_CAMERAMOVEMENTHEIGH = 0.4; // 0 idle, 0.15 walk 0.3 run/sprint
351
353 {
354 //Print("new camera: DayZPlayerCamera3rdPersonCrouch");
355
356 m_fDistance = 1.4;
357 m_CameraOffsetMS = "0.0 0.7 0.1";
358 m_CameraOffsetLS = "0.0 0.3 0.0";
359 m_fShoulderWidth = 0.3;
360 }
361
362 //
363 override void OnUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
364 {
365 m_pPlayer.GetMovementState(m_MovementState);
366
368 float movement = (Limit(m_MovementState.m_iMovement, 1, 3) - 1.0) * 0.5;
372
374 super.OnUpdate(pDt, pOutResult);
375 }
376
377 protected float m_fCameraHeight; // -1..1 shoulderness :)
378 protected float m_fCameraHeightVel[1]; // 0
379}
380
381
382// *************************************************************************************
383// ! DayZPlayerCamera3rdPersonCrouchRaised- 3rd person crouch raised
384// *************************************************************************************
385class DayZPlayerCamera3rdPersonCrouchRaised extends DayZPlayerCamera3rdPersonCrouch
386{
388 {
389 //Print("new camera: DayZPlayerCamera3rdPersonCrouchRaised");
390
391 m_fDistance = 0.8;
392 m_CameraOffsetMS = "0.0 0.8 0.1"; // being overwritten by m_CameraOffsetMS[1] from DayZPlayerCamera3rdPersonCrouch
393 m_CameraOffsetLS = "0.0 0.3 0.0";
394 m_fShoulderWidth = 0.5;
395 }
396
397 override bool IsCamera3rdRaised()
398 {
399 return true;
400 }
401}
402
403
404// *************************************************************************************
405// ! DayZPlayerCamera3rdPersonProneRaised - 3rd person prone raised
406// *************************************************************************************
408{
409 protected vector m_BaseOffset
411 protected float m_LookAtLRAngle;
412
413 float UpdateLRAngleLookAt(float pMin, float pMax, float pDt)
414 {
417 {
420
421 m_fLRAngleVel[0] = 0; // reset filter
422 }
423 else
424 {
425 // smooth value back to 0
427 // m_fLeftRightAngle = 0.9 * (1.0 - pDt);
428 }
429
430 return m_LookAtLRAngle;
431 }
432
434 {
436
437 if (m_iBoneIndex != -1)
438 m_BaseOffset = m_pPlayer.GetBonePositionMS(m_iBoneIndex);
439 else
440 m_BaseOffset = "0 0 0";
441 }
442
443
444 //
445 override void OnUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
446 {
449
450 float orientYaw = m_pPlayer.GetOrientation()[0];
453
454 // Print("OY: " + orientYaw.ToString() + " HY: " + headYaw.ToString());
455
456 // update l/r offsets and set it as
457
459
462 else
464
466
469
471 if (m_iBoneIndex != -1)
472 {
473 vector bonePos = m_pPlayer.GetBonePositionMS(m_iBoneIndex);
477 }
478
482
484
485 // ls offset + ms offset + shoulder width
486 pOutResult.m_CameraTM[3] = m_BaseOffset + pOutResult.m_CameraTM[0] * lsOffset[0] + pOutResult.m_CameraTM[1] * lsOffset[1] + pOutResult.m_CameraTM[2] * lsOffset[2] + msOffset;
487
490
492 pOutResult.m_fDistance = m_fDistance;
493 pOutResult.m_fUseHeading = 1.0;
494 pOutResult.m_fInsideCamera = 0.0;
495 pOutResult.m_fPositionModelSpace = 1.0;
496 pOutResult.m_bUpdateWhenBlendOut = false;
497
501 }
502}
503
504// *************************************************************************************
505// ! DayZPlayerCamera3rdPersonProne - 3rd person prone
506// *************************************************************************************
508{
510 {
511 //Print("new camera: DayZPlayerCamera3rdPersonProne");
512 m_iBoneIndex = pPlayer.GetBoneIndexByName("Camera3rd_Helper");
513 m_fDistance = 1.0;
514 m_CameraOffsetMS = "0.0 0.4 0.0";
515 m_CameraOffsetLS = "0.0 0.2 0.0";
516 m_fShoulderWidth = 0.5;
517 }
518
519}
520
521// *************************************************************************************
522// ! DayZPlayerCamera3rdPersonProneRaised - 3rd person prone raised
523// *************************************************************************************
525{
528 //Print("new camera: DayZPlayerCamera3rdPersonProneRaised");
529 m_iBoneIndex = pPlayer.GetBoneIndexByName("Camera3rd_Helper");
530 m_fDistance = 1.0;
531 m_CameraOffsetMS = "0.0 0.4 0.0";
532 m_CameraOffsetLS = "0.0 0.2 0.0";
533 m_fShoulderWidth = 0.5;
534 }
535
536 override bool IsCamera3rdRaised()
537 {
538 return true;
539 }
540}
int m_iBoneIndex
main bone
float m_fLeftRightAngle
left right angle in rad (in freelook only)
float m_fUpDownAngle
up down angle in rad
static const float CONST_UD_MAX
up limit
float m_fLeftRightAngleAdd
left right angle in rad (in freelook only)
float m_fUpDownAngleAdd
up down angle in rad
static const float CONST_LR_MIN
down limit
static const float CONST_LR_MAX
up limit
static const float CONST_UD_MIN
down limit
float m_fCameraHeight
void DayZPlayerCamera3rdPerson(DayZPlayer pPlayer, HumanInputController pInput)
vector m_CameraOffsetMS
model space offset
class DayZPlayerCamera3rdPersonCrouchRaised extends DayZPlayerCamera3rdPersonCrouch m_BaseOffsetVelZ[1]
float m_jumpOffsetVelocity[1]
int m_iBoneIndex
runtime config
void DayZPlayerCamera3rdPersonJump(DayZPlayer pPlayer, HumanInputController pInput)
float m_fLeftRightAngle
left right angle in rad (in freelook only)
class DayZPlayerCamera3rdPerson extends DayZPlayerCameraBase DayZPlayerCamera3rdPersonErc(DayZPlayer pPlayer, HumanInputController pInput)
float m_fUpDownAngle
runtime values
static const float CONST_UD_MAX
up limit
class DayZPlayerCamera3rdPersonJump extends DayZPlayerCamera3rdPersonErc DayZPlayerCamera3rdPersonClimb(DayZPlayer pPlayer, HumanInputController pInput)
float m_fShoulderWidth
shoulder camera widths
float m_fUpDownAngleAdd
up down angle in rad
float m_fDistance
distance from start
float m_fDelay
runtime config
void DayZPlayerCamera3rdPersonCrouch(DayZPlayer pPlayer, HumanInputController pInput)
class DayZPlayerCamera3rdPersonProne extends DayZPlayerCamera3rdPersonProneBase DayZPlayerCamera3rdPersonProneRaised(DayZPlayer pPlayer, HumanInputController pInput)
float m_fPredictCollisionRadius
collision prediction
override bool IsCamera3rdRaised()
class DayZPlayerCamera3rdPersonCrouchRaised extends DayZPlayerCamera3rdPersonCrouch m_BaseOffsetVelY[1]
class DayZPlayerCamera3rdPersonErcSpr extends DayZPlayerCamera3rdPersonErc DayZPlayerCamera3rdPersonErcRaised(DayZPlayer pPlayer, HumanInputController pInput)
float m_fDelayTimer
runtime values
class DayZPlayerCamera3rdPersonCrouchRaised extends DayZPlayerCamera3rdPersonCrouch m_BaseOffsetVelX[1]
float m_fCameraLRShoulder
shoulder offsets
ref HumanMovementState m_MovementState
movement state
float UpdateLRAngleLookAt(float pMin, float pMax, float pDt)
float m_fCameraLRShoulderVel[1]
static const float CONST_UD_MIN
down limit
float m_fJumpStartY
vector m_CameraOffsetLS
local space offset
void DayZPlayerCamera3rdPersonProne(DayZPlayer pPlayer, HumanInputController pInput)
float m_fJumpOffset
class DayZPlayerCamera3rdPersonErcRaisedMelee extends DayZPlayerCamera3rdPersonErcRaised CONST_CAMERAMOVEMENTHEIGH
float m_fLeanDistance
shift on leaning
float m_LookAtLRAngle
bool m_bShoulderInLS
true - shoulder is in local space
float m_fCameraHeightVel[1]
void DayZPlayerCamera3rdPersonErcSpr(DayZPlayer pPlayer, HumanInputController pInput)
float UpdateLRAngleUnlocked(out float pAngle, out float pAngleAdd, float pMin, float pMax, float pDt)
float m_CurrentCameraYaw
float m_CurrentCameraPitch
float UpdateUDAngleUnlocked(out float pAngle, out float pAngleAdd, float pMin, float pMax, float pDt)
float Limit(float pV, float pMin, float pMax)
limit function
void StdFovUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
float m_CurrentCameraRoll
bool m_bForceFreeLook
void InitCameraOnPlayer(bool force=false)
float fixAngle_180_180(float pAngle)
float m_WeaponSwayModifier
void UpdateCameraNV(PlayerBase player)
void ProcessCameraShake(float delta, out float leftRight, out float upDown)
float m_fLRAngleVel[1]
void DayZPlayerCamera3rdPersonCrouchRaised(DayZPlayer pPlayer, HumanInputController pInput)
override void OnUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
void DayZPlayerCamera3rdPersonErcSpr(DayZPlayer pPlayer, HumanInputController pInput)
void DayZPlayerCamera3rdPersonJump(DayZPlayer pPlayer, HumanInputController pInput)
override void HandleShoulderCameraOverride(HumanInputController pInput)
void DayZPlayerCamera3rdPersonProne(DayZPlayer pPlayer, HumanInputController pInput)
this is main camera class
vector m_CameraOffsetMS
model space offset
float m_fLeftRightAngleAdd
left right angle in rad (in freelook only)
void DayZPlayerCamera3rdPerson(DayZPlayer pPlayer, HumanInputController pInput)
float m_fRoll
camera roll (deprecated)
bool m_bShoulderInLS
true - shoulder is in local space
float m_fLeanDistance
shift on leaning
float m_fCameraLRShoulder
shoulder offsets
override void OnActivate(DayZPlayerCamera pPrevCamera, DayZPlayerCameraResult pPrevCameraResult)
float m_fShoulderWidth
shoulder camera widths
vector m_CameraOffsetLS
local space offset
override void OnUpdate(float pDt, out DayZPlayerCameraResult pOutResult)
float m_fPredictCollisionRadius
collision prediction
float m_fDistance
distance from start
float m_fUpDownAngleAdd
up down angle in rad
float m_fLeftRightAngle
left right angle in rad (in freelook only)
float m_fUpDownAngle
up down angle in rad
static const int PERITEMUD_TWOHANDED
for empty hands
static const int PERITEMUD_EMPTYHANDED
uninitialized / invalid per item camera user data
static const int PERITEMUD_ONEHANDED
for empty hands
proto native bool CameraIsFreeLook()
returns true if freelook is active
proto native vector GetAimChange()
returns per tick aim change (in radians)
proto native bool Camera3rdIsRightShoulder()
returns true if camera is on right/ false-left shoulder
proto native float GetHeadingAngle()
returns main heading angle (in radians) -PI .. PI (this is world Y angle player is actualy pointing t...
Definition EnMath.c:7
float m_fDistance
camera distance (external cameras only)
Definition dayzplayer.c:63
float m_fPredictCollisionRadius
sphere radius used for collision prediction
Definition dayzplayer.c:65
DayZPlayer m_pPlayer
data
Definition dayzplayer.c:135
HumanInputController m_pInput
human input
Definition dayzplayer.c:136
class DayZPlayerCameraResult DayZPlayerCamera(DayZPlayer pPlayer, HumanInputController pInput)
Definition dayzplayer.c:56
vector GetCurrentOrientation()
Definition dayzplayer.c:112
proto void Print(void var)
Prints content of variable to console/log.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static const float RAD2DEG
Definition EnMath.c:16
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.
proto native void OnUpdate()
Definition tools.c:333
HumanInputControllerOverrideType
Definition human.c:8
class HumanMovementState OnActivate()
HumanCommandScript fully scriptable command.
Definition human.c:1167