DayZ 1.24
Loading...
Searching...
No Matches
PluginCharPlacement.c
Go to the documentation of this file.
2{
3 PluginDeveloper m_ModuleDeveloper;
10 vector m_cameraTrans[4];
14
15 const float FOV = 0.5236;
16
17 void CheckInit()
18 {
19 if (m_Initialized)
20 {
21 Print("logging...");
22 Log(FOV.ToString(), "FOV");
23 Log(m_camera_dir.ToString(), "camera dir");
24 Log(m_cam_pos.ToString(), "camera pos");
25 Log(m_demoPos.ToString(), "character pos");
26
27 return;
28 }
29
30 if (FreeDebugCamera.GetInstance().IsActive())
31 Init();
32 }
33
34 void Init()
35 {
36 if (m_Character)
37 m_Character.Delete();
38
39 m_Initialized = true;
40 m_Character = PlayerBase.Cast(GetGame().CreateObject("SurvivorF_Judy", FreeDebugCamera.GetInstance().GetPosition(), false, false/*ai*/));
41
42 FreeDebugCamera.GetInstance().SetFOV(FOV); //default scene FOV
43 m_demoRot = "0 0 0";
44 }
45
46 override void OnUpdate(float delta_time)
47 {
48 if (!m_Initialized) return;
49 if (!FreeDebugCamera.GetInstance().IsActive()) return;
50 if (!m_Character) return;
51 m_camera_orientation = FreeDebugCamera.GetInstance().GetOrientation();
52 m_camera_orientation[1] = 1;
53 FreeDebugCamera.GetInstance().SetOrientation(m_camera_orientation); //remove to unlock vertical axis
54 m_cam_pos = FreeDebugCamera.GetInstance().GetPosition();
55 m_character_pos = m_Character.GetPosition();
56 m_camera_dir = FreeDebugCamera.GetInstance().GetDirection();
57
58 m_camera_dir.Normalize();
59 m_Character.SetPosition(CalculatePos());//(FreeDebugCamera.GetInstance().GetPosition() + ( m_camera_dir * 2) );
60 m_demoRot[0] = Math.Atan2(-m_camera_dir[0], -m_camera_dir[2]) * Math.RAD2DEG;
61 m_Character.SetOrientation(m_demoRot);//(FreeDebugCamera.GetInstance().GetPosition() - m_demoPos);
62 }
63
64 override void OnDestroy()
65 {
66 FreeDebugCamera.GetInstance().SetFOV(g_Game.GetUserFOV());
67 }
68
70 {
71 vector cam_pos = FreeDebugCamera.GetInstance().GetPosition();
72 Math3D.MatrixIdentity4(m_cameraTrans);
73 Math3D.DirectionAndUpMatrix(m_camera_dir/* - SnapToGround(cam_pos)*/, "0 1 0", m_cameraTrans);
74 m_cameraTrans[3] = cam_pos;
75 m_demoPos = Vector(/*0.685547, -0.988281,*/0, 0, 3.68823).Multiply4(m_cameraTrans);
76 m_demoPos[1] = GetGame().SurfaceY(m_demoPos[0], m_demoPos[2]);
77
78 return m_demoPos;
79 }
80}
DayZGame g_Game
Definition DayZGame.c:3528
override Widget Init()
Definition DayZGame.c:120
ref Timer m_Timer
Definition DayZGame.c:675
class LogTemplates Log(string message, LogTemplateID template_id=0)
Creates debug log (optional) from LogTemplate which are registred.
bool m_Initialized
Definition EnMath.c:7
vector CalculatePos()
PlayerBase m_Character
vector m_camera_orientation
PluginDeveloper m_ModuleDeveloper
override void OnDestroy()
override void OnUpdate(float delta_time)
proto string ToString()
proto float Normalize()
Normalizes vector. Returns length.
proto string ToString(bool beautify=true)
Vector to string.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:233
static proto void DirectionAndUpMatrix(vector dir, vector up, out vector mat[4])
Creates rotation matrix from direction and up vector.
static proto float Atan2(float y, float x)
Returns angle in radians from tangent.
static const float RAD2DEG
Definition EnMath.c:16