2 #include <ThirdParty/glm/glm/gtc/matrix_transform.hpp> 3 #include <ThirdParty/glm/glm/gtx/euler_angles.hpp> 44 this->position = position;
45 shouldRecalculateModelMatrix =
true;
62 this->rotation = rotation;
63 shouldRecalculateModelMatrix =
true;
81 shouldRecalculateModelMatrix =
true;
98 this->modelMatrix = modelMatrix;
99 shouldRecalculateModelMatrix =
true;
104 SetModelMatrix(glm::mat4x4(modelMatrix[0], modelMatrix[1], modelMatrix[2], modelMatrix[3],
105 modelMatrix[4], modelMatrix[5], modelMatrix[6], modelMatrix[7],
106 modelMatrix[8], modelMatrix[9], modelMatrix[10], modelMatrix[11],
107 modelMatrix[12], modelMatrix[13], modelMatrix[14], modelMatrix[15]));
112 SetModelMatrix(glm::mat4x4(modelMatrix[0].x, modelMatrix[0].y, modelMatrix[0].z, modelMatrix[0].w,
113 modelMatrix[1].x, modelMatrix[1].y, modelMatrix[1].z, modelMatrix[1].w,
114 modelMatrix[2].x, modelMatrix[2].y, modelMatrix[2].z, modelMatrix[2].w,
115 modelMatrix[3].x, modelMatrix[3].y, modelMatrix[3].z, modelMatrix[3].w));
125 this->isStatic = isStatic;
135 if (isStatic)
return;
137 position += positionToAdd;
138 shouldRecalculateModelMatrix =
true;
158 if (isStatic)
return;
160 rotation += rotationToAdd;
180 if (isStatic)
return;
183 shouldRecalculateModelMatrix =
true;
203 return glm::normalize(glm::vec3(modelMatrix[0]));
208 return glm::normalize(glm::vec3(modelMatrix[1]));
213 return glm::normalize(glm::vec3(modelMatrix[2]));
223 if (isStatic)
return;
225 modelMatrix *= glm::lookAt(position, targetPosition,
GetUp());
226 shouldRecalculateModelMatrix =
true;
231 if (isStatic)
return;
233 glm::mat4x4 rotationMatrix;
234 glm::rotate(rotationMatrix, angle, axis);
235 modelMatrix *= rotationMatrix;
237 shouldRecalculateModelMatrix =
true;
242 if (shouldRecalculateModelMatrix ==
false)
return;
249 glm::mat4x4 rotationMatrix = glm::eulerAngleYXZ(rotation.y, rotation.x, rotation.z);
250 glm::mat4x4 rotationScaleMatrix = rotationMatrix * glm::scale(rotationMatrix, scale);
251 rotationScaleMatrix[3] = glm::vec4(position, 1);
253 modelMatrix = rotationScaleMatrix;
254 shouldRecalculateModelMatrix =
false;
259 if (position != other.position)
return true;
260 if (rotation != other.rotation)
return true;
261 if (scale != other.scale)
return true;
267 if (position != other.position)
return false;
268 if (rotation != other.rotation)
return false;
269 if (scale != other.scale)
return false;