-
Notifications
You must be signed in to change notification settings - Fork 0
/
Socket.h
86 lines (67 loc) · 1.92 KB
/
Socket.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
//#include "Actor.h"
//#include "Matrix4x4.h"
//#include "Object.h"
class Socket: public Object
{
public:
Socket(Entity actor_attached_to_ID,Vector3D rel_pos, Rotator3D rel_rot_to_actor)
{
m_actor_attached_to_ID = actor_attached_to_ID;
m_rel_pos_to_actor = rel_pos;
m_rel_rot_to_actor = rel_rot_to_actor;
}
~Socket()
{
}
virtual void Tick(float DeltaTime) override
{
UpdateSocket(DeltaTime);
}
virtual void BeginPlay() override
{
}
void UpdateSocket(float DeltaTime)
{
auto & transform = m_EntityComponentSystemManager->GetComponent<TransformComponent>(m_actor_attached_to_ID);
Matrix4x4 world_pos, temp;
world_pos.setIdentity();
temp.setIdentity();
temp.setRotationRadiansX(transform.rotation.GetRadianValue().m_x);
world_pos *= temp;
temp.setIdentity();
temp.setRotationRadiansY(transform.rotation.GetRadianValue().m_y);
world_pos *= temp;
// std::cout << world_cam.getXDirection().m_x << " " << world_cam.getXDirection().m_y << " " << world_cam.getXDirection().m_z << std::endl;
if(b_inherit_position)
m_position = transform.position + world_pos.getZDirection() * m_rel_pos_to_actor.m_z
+ world_pos.getYDirection() * m_rel_pos_to_actor.m_y
+ world_pos.getXDirection() * m_rel_pos_to_actor.m_x;
if (b_inherit_rotation)
m_rotation = transform.rotation;
}
Vector3D GetPosition()
{
return m_position;
}
Rotator3D GetRotation()
{
return m_rotation;
}
void SetInheritPosition(bool inherit)
{
b_inherit_position = inherit;
}
void SetInheritRotation(bool inherit)
{
b_inherit_rotation = inherit;
}
private:
Vector3D m_position;
Rotator3D m_rotation;
bool b_inherit_position = true;
bool b_inherit_rotation = true;
Vector3D m_rel_pos_to_actor;
Rotator3D m_rel_rot_to_actor;
Entity m_actor_attached_to_ID;
};