1 #include "CompositeModel.hpp"
3 #include "EntityModel.hpp"
4 #include "../graphics/DirectionalLighting.hpp"
6 #include <glm/gtx/quaternion.hpp>
11 CompositeModel::CompositeModel()
14 , orientation(1.0f, 0.0f, 0.0f, 0.0f)
20 CompositeModel &CompositeModel::AddPart() {
22 parts.back().parent = this;
27 glm::mat4 CompositeModel::LocalTransform() const noexcept {
28 glm::mat4 transform(toMat4(orientation));
29 transform[3].x = position.x;
30 transform[3].y = position.y;
31 transform[3].z = position.z;
35 glm::mat4 CompositeModel::GlobalTransform() const noexcept {
37 return Parent().GlobalTransform() * LocalTransform();
39 return LocalTransform();
44 void CompositeModel::Render(const glm::mat4 &M, DirectionalLighting &prog) const {
45 glm::mat4 transform(M * LocalTransform());
50 for (const CompositeModel &part : parts) {
51 part.Render(transform, prog);