]> git.localhorst.tv Git - blank.git/blobdiff - src/model/Part.hpp
save a little bandwidth
[blank.git] / src / model / Part.hpp
index 029442bfabb5646f3dd22c45d5e45c3de80387a6..3a17f2046137b39da28699d66452932978843471 100644 (file)
@@ -1,10 +1,9 @@
 #ifndef BLAMK_MODEL_PART_HPP_
 #define BLAMK_MODEL_PART_HPP_
 
-#include "geometry.hpp"
-
 #include <cstdint>
 #include <list>
+#include <memory>
 #include <vector>
 #include <glm/glm.hpp>
 #include <glm/gtc/quaternion.hpp>
@@ -14,35 +13,52 @@ namespace blank {
 
 class DirectionalLighting;
 class EntityMesh;
+class Instance;
 class Model;
+class ResourceIndex;
+class Shape;
+class ShapeRegistry;
+class TokenStreamReader;
 
 struct Part {
 
-       std::uint16_t id;
-       AABB bounds;
+public:
        struct State {
                glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f);
                glm::quat orientation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f);
-       } initial;
-       const EntityMesh *mesh;
+       };
 
        Part();
        ~Part();
 
+       void Read(TokenStreamReader &, ResourceIndex &, const ShapeRegistry &);
+
        Part &AddChild();
        const std::list<Part> &Children() const noexcept { return children; }
 
        std::uint16_t Enumerate(std::uint16_t) noexcept;
        void Index(std::vector<Part *> &) noexcept;
 
-       glm::mat4 LocalTransform(const std::vector<State> &) const noexcept;
-       glm::mat4 GlobalTransform(const std::vector<State> &) const noexcept;
+       std::uint16_t ID() const noexcept { return id; }
 
-       void Render(const glm::mat4 &, const std::vector<State> &, DirectionalLighting &) const;
+       glm::mat4 LocalTransform(const Instance &) const noexcept;
+       glm::mat4 GlobalTransform(const Instance &) const noexcept;
+
+       void Render(
+               const glm::mat4 &,
+               const Instance &,
+               DirectionalLighting &) const;
 
 private:
        const Part *parent;
+       const Shape *shape;
        std::list<Part> children;
+       std::vector<float> tex_map;
+       mutable std::unique_ptr<EntityMesh> mesh;
+       State initial;
+       glm::tvec3<unsigned char> hsl_mod;
+       glm::tvec3<unsigned char> rgb_mod;
+       std::uint16_t id;
 
 };