31 lines
762 B
C++
31 lines
762 B
C++
#include <glm/glm.hpp>
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
#include "CompoundShape.hpp"
|
|
|
|
// constructors
|
|
|
|
CompoundShape::CompoundShape(const std::vector<Shape> shapes)
|
|
: shapes { shapes }
|
|
, transform { 1.0f } {
|
|
|
|
for (auto& shape : this->shapes) {
|
|
shape.init();
|
|
}
|
|
}
|
|
|
|
// public
|
|
|
|
void CompoundShape::draw() {
|
|
for (auto& shape : this->shapes) {
|
|
glm::mat4 orig_transform { shape.transform };
|
|
shape.transform = glm::rotate(shape.transform, glm::radians(90.0f), glm::vec3 { 0.0f, 0.0f, 1.0f });
|
|
shape.draw();
|
|
shape.transform = orig_transform;
|
|
}
|
|
}
|
|
|
|
void CompoundShape::rotate(const float rotation_rad, const glm::vec3& axis) {
|
|
this->transform = glm::rotate(this->transform, rotation_rad, axis);
|
|
}
|