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; }
25 const glm::vec3 &Position() const noexcept { return position; }
26 void Position(const glm::vec3 &p) noexcept { position = p; }
28 const glm::quat &Orientation() const noexcept { return orientation; }
29 void Orientation(const glm::quat &o) noexcept { orientation = o; }
31 glm::mat4 LocalTransform() const noexcept;
32 glm::mat4 GlobalTransform() const noexcept;
34 void Render(const glm::mat4 &, DirectionalLighting &) const;
37 CompositeInstance &AddPart();
38 bool HasParent() const noexcept { return parent; }
39 CompositeInstance &Parent() const noexcept { return *parent; }
40 bool IsRoot() const noexcept { return !HasParent(); }
43 const CompositeModel *part_model;
44 CompositeInstance *parent;
47 glm::quat orientation;
49 std::vector<CompositeInstance> parts;