8 #ifndef _MBS_3D_COMPONENT_HH_
9 #define _MBS_3D_COMPONENT_HH_
11 #ifndef degreesToRadians
12 #define degreesToRadians(x) x*(3.141592f/180.0f)
15 #ifndef GLM_FORCE_RADIANS
16 #define GLM_FORCE_RADIANS
30 enum {COMP_TYPE_COMPONENT, COMP_TYPE_BODY, COMP_TYPE_ABSTRACT, COMP_TYPE_ANCHOR, COMP_TYPE_JOINT, COMP_TYPE_BASE};
37 Mbs3DComponent(MbsWorld3D *world_3d,
const char* name, glm::mat4
const& abs_mat = glm::mat4(1.0f));
38 virtual ~Mbs3DComponent();
41 void SetAbsMat(glm::mat4
const& abs_mat) { this->abs_mat = abs_mat; }
44 glm::mat4 GetAbsMat()
const {
return abs_mat; }
47 int GetCompType()
const {
return comp_type; }
49 void ReleaseChildList();
51 Joint3D* AddT1(
const char* name,
float joint_value = 0.0f);
52 Joint3D* AddT2(
const char* name,
float joint_value = 0.0f);
53 Joint3D* AddT3(
const char* name,
float joint_value = 0.0f);
54 Joint3D* AddR1(
const char* name,
float joint_value = 0.0f);
55 Joint3D* AddR2(
const char* name,
float joint_value = 0.0f);
56 Joint3D* AddR3(
const char* name,
float joint_value = 0.0f);
58 Base3D* AddBaseJoint();
60 bool IsName(
const char* name);
62 Mbs3DComponent* Get3DCompName(
int comp_type,
const char* name);
64 virtual void UpdateAbsMatTree();
66 virtual void PrintTree(
int level);
73 std::vector<Joint3D*> joint_child_list;
75 std::vector<Mbs3DComponent*> mbs_3d_child_list;
82 Joint3D* AddJoint(
const char* name,
int joint_type,
float joint_value);
83 void PrintName(
int level);
84 void PrintChildList(
int level);
87 glm::mat4 TransMat(
float x,
float y,
float z)
90 1.0f, 0.0f, 0.0f, 0.0f,
91 0.0f, 1.0f, 0.0f, 0.0f,
92 0.0f, 0.0f, 1.0f, 0.0f,
98 glm::mat4 ScaleMat(
float x,
float y,
float z)
101 x , 0.0f, 0.0f, 0.0f,
102 0.0f, y , 0.0f, 0.0f,
103 0.0f, 0.0f, z , 0.0f,
104 0.0f, 0.0f, 0.0f, 1.0f
109 glm::mat4 RotMatX(
float angle_rad)
113 cos_a = cos(angle_rad);
114 sin_a = sin(angle_rad);
117 1.0f, 0.0f , 0.0f , 0.0f,
118 0.0f, cos_a, sin_a, 0.0f,
119 0.0f, -sin_a, cos_a, 0.0f,
120 0.0f, 0.0f , 0.0f , 1.0f
125 glm::mat4 RotMatY(
float angle_rad)
129 cos_a = cos(angle_rad);
130 sin_a = sin(angle_rad);
133 cos_a, 0.0f, -sin_a, 0.0f,
134 0.0f , 1.0f, 0.0f , 0.0f,
135 sin_a, 0.0f, cos_a, 0.0f,
136 0.0f , 0.0f, 0.0f , 1.0f
141 glm::mat4 RotMatZ(
float angle_rad)
145 cos_a = cos(angle_rad);
146 sin_a = sin(angle_rad);
149 cos_a, sin_a, 0.0f, 0.0f,
150 -sin_a, cos_a, 0.0f, 0.0f,
151 0.0f , 0.0f , 1.0f, 0.0f,
152 0.0f , 0.0f , 0.0f, 1.0f