1 #ifndef BLANK_MODEL_COMPOSITEINSTANCE_HPP_
2 #define BLANK_MODEL_COMPOSITEINSTANCE_HPP_
6 #include <glm/gtc/quaternion.hpp>
12 class DirectionalLighting;
14 // TODO: this doesn't have to be a tree, actually
15 // linearizing might be a good opportunity to optimize
16 class CompositeInstance {
18 friend class CompositeModel;
23 operator bool() const noexcept { return part_model; }
24 const CompositeModel &GetModel() const noexcept { return *part_model; }
26 const glm::vec3 &Position() const noexcept { return position; }
27 void Position(const glm::vec3 &p) noexcept { position = p; }
29 const glm::quat &Orientation() const noexcept { return orientation; }
30 void Orientation(const glm::quat &o) noexcept { orientation = o; }
32 glm::mat4 LocalTransform() const noexcept;
33 glm::mat4 GlobalTransform() const noexcept;
35 void Render(const glm::mat4 &, DirectionalLighting &) const;
38 CompositeInstance &AddPart();
39 bool HasParent() const noexcept { return parent; }
40 CompositeInstance &Parent() const noexcept { return *parent; }
41 bool IsRoot() const noexcept { return !HasParent(); }
44 const CompositeModel *part_model;
45 CompositeInstance *parent;
48 glm::quat orientation;
50 std::vector<CompositeInstance> parts;