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;
84 std::vector<glm::vec3> vertices;
85 std::vector<glm::vec3> colors;
86 std::vector<glm::vec3> normals;
88 std::vector<unsigned int> indexes;
94 glm::mat3 M_inv_trans;
97 glm::vec3 trans_scale;
100 MbsWorld3D *world_3d;
105 glm::vec3 specular_mat;
112 void SetNbTriangles(
int nb_triangles);
113 void NormalsCompute();
114 void ApplyTransform();
116 void BasicLoad(GLdouble *tmp_vert, GLfloat *tmp_coord,
int nb_tri,
int nb_vert, glm::vec3
const& color);
118 void ColorHeight(std::vector<glm::vec3>
const& vertices, std::vector<glm::vec3> &colors,
119 int axis,
bool inv_color,
bool bound_flag,
float min_range,
float max_range,
const char* name);
122 glm::mat4 TransMat(
float x,
float y,
float z)
125 1.0f, 0.0f, 0.0f, 0.0f,
126 0.0f, 1.0f, 0.0f, 0.0f,
127 0.0f, 0.0f, 1.0f, 0.0f,
133 glm::mat4 ScaleMat(
float x,
float y,
float z)
136 x , 0.0f, 0.0f, 0.0f,
137 0.0f, y , 0.0f, 0.0f,
138 0.0f, 0.0f, z , 0.0f,
139 0.0f, 0.0f, 0.0f, 1.0f
144 glm::mat4 RotMatX(
float angle_rad)
148 cos_a = cos(angle_rad);
149 sin_a = sin(angle_rad);
152 1.0f, 0.0f , 0.0f , 0.0f,
153 0.0f, cos_a, sin_a, 0.0f,
154 0.0f, -sin_a, cos_a, 0.0f,
155 0.0f, 0.0f , 0.0f , 1.0f
160 glm::mat4 RotMatY(
float angle_rad)
164 cos_a = cos(angle_rad);
165 sin_a = sin(angle_rad);
168 cos_a, 0.0f, -sin_a, 0.0f,
169 0.0f , 1.0f, 0.0f , 0.0f,
170 sin_a, 0.0f, cos_a, 0.0f,
171 0.0f , 0.0f, 0.0f , 1.0f
176 glm::mat4 RotMatZ(
float angle_rad)
180 cos_a = cos(angle_rad);
181 sin_a = sin(angle_rad);
184 cos_a, sin_a, 0.0f, 0.0f,
185 -sin_a, cos_a, 0.0f, 0.0f,
186 0.0f , 0.0f , 1.0f, 0.0f,
187 0.0f , 0.0f , 0.0f, 1.0f
192 MbsShapeRenderer* shRenderer;