8 #ifndef _MBS_SHAPE_3D_HH_
9 #define _MBS_SHAPE_3D_HH_
11 #ifndef degreesToRadians
12 #define degreesToRadians(x) x*(3.141592f/180.0f)
15 #ifndef GLM_FORCE_RADIANS
16 #define GLM_FORCE_RADIANS
41 float transparency = 1.0,
42 glm::vec3
const& trans_pos = glm::vec3(0.0f),
43 glm::vec3
const& trans_scale = glm::vec3(1.0, 1.0, 1.0),
44 glm::vec3
const& trans_rot = glm::vec3(0.0f),
45 float shiny_mat = 250.f,
46 glm::vec3
const& specular_mat = glm::vec3(1.0f, 1.0f, 1.0f),
47 const char* name =
"none");
51 void SetModelMat(glm::mat4
const& model_mat)
53 this->model_mat = model_mat;
57 shRenderer->SetModelMat(model_mat);
63 void Render(MbsViewPoint *viewpoint);
66 void ShadowDepth(
int index){shRenderer->ShadowDepth(index);}
69 void SetShinyMat(
float val) { shiny_mat = val; }
72 void SetSpecularMat(glm::vec3
const& vec) { specular_mat = vec; }
75 MbsShapeRenderer* GetShapeRenderer(){
return shRenderer; }
80 std::vector<glm::vec3> temp_vertices;
81 std::vector<glm::vec3> temp_colors;
82 std::vector<glm::vec3> temp_normals;
83 std::vector<glm::vec3> temp_line_vertices;
84 std::vector<glm::vec3> temp_line_colors;
86 std::vector<glm::vec3> vertices;
87 std::vector<glm::vec3> colors;
88 std::vector<glm::vec3> normals;
89 std::vector<glm::vec3> line_vertices;
90 std::vector<glm::vec3> line_colors;
92 std::vector<unsigned int> indexes;
93 std::vector<unsigned int> line_indexes;
99 glm::mat3 M_inv_trans;
102 glm::vec3 trans_scale;
105 MbsWorld3D *world_3d;
110 glm::vec3 specular_mat;
117 void SetNbTriangles(
int nb_triangles);
118 void NormalsCompute();
119 void ApplyTransform();
121 void VBOLineIndexing();
122 void BasicLoad(GLdouble *tmp_vert, GLfloat *tmp_coord,
int nb_tri,
int nb_vert, glm::vec3
const& color);
124 void ColorHeight(std::vector<glm::vec3>
const& vertices, std::vector<glm::vec3> &colors,
125 int axis,
bool inv_color,
bool bound_flag,
float min_range,
float max_range,
const char* name);
128 glm::mat4 TransMat(
float x,
float y,
float z)
131 1.0f, 0.0f, 0.0f, 0.0f,
132 0.0f, 1.0f, 0.0f, 0.0f,
133 0.0f, 0.0f, 1.0f, 0.0f,
139 glm::mat4 ScaleMat(
float x,
float y,
float z)
142 x , 0.0f, 0.0f, 0.0f,
143 0.0f, y , 0.0f, 0.0f,
144 0.0f, 0.0f, z , 0.0f,
145 0.0f, 0.0f, 0.0f, 1.0f
150 glm::mat4 RotMatX(
float angle_rad)
154 cos_a = cos(angle_rad);
155 sin_a = sin(angle_rad);
158 1.0f, 0.0f , 0.0f , 0.0f,
159 0.0f, cos_a, sin_a, 0.0f,
160 0.0f, -sin_a, cos_a, 0.0f,
161 0.0f, 0.0f , 0.0f , 1.0f
166 glm::mat4 RotMatY(
float angle_rad)
170 cos_a = cos(angle_rad);
171 sin_a = sin(angle_rad);
174 cos_a, 0.0f, -sin_a, 0.0f,
175 0.0f , 1.0f, 0.0f , 0.0f,
176 sin_a, 0.0f, cos_a, 0.0f,
177 0.0f , 0.0f, 0.0f , 1.0f
182 glm::mat4 RotMatZ(
float angle_rad)
186 cos_a = cos(angle_rad);
187 sin_a = sin(angle_rad);
190 cos_a, sin_a, 0.0f, 0.0f,
191 -sin_a, cos_a, 0.0f, 0.0f,
192 0.0f , 0.0f , 1.0f, 0.0f,
193 0.0f , 0.0f , 0.0f, 1.0f
198 MbsShapeRenderer* shRenderer;