#pragma once #include "shared.hpp" #include #include #include #define GLM_PRECISION_HIGHP_FLOAT #include "p3d/model.hpp" #include "glm/glm.hpp" #include "glm/vec3.hpp" #include "glm/mat4x4.hpp" namespace ace { namespace simulation { class vertex; typedef std::shared_ptr vertex_p; class lod; typedef std::shared_ptr lod_p; class object; typedef std::shared_ptr object_p; typedef std::map>> animation_transform; class vertex_table { public: vertex_table() {}; vertex_table(const ace::p3d::vertex_table_p, const ace::p3d::lod_p, const ace::p3d::model_p); ~vertex_table(); vertex_p operator[] (const int index) { return vertices[index]; } std::vector vertices; private: bool animated; }; class face { public: face() {}; face(const ace::p3d::face_p, const ace::p3d::lod_p, const ace::p3d::model_p, ace::simulation::lod *); ~face(); uint8_t type; std::vector vertices; }; typedef std::shared_ptr face_p; class named_selection { public: named_selection() {}; named_selection(const ace::p3d::named_selection_p, const ace::p3d::lod_p, const ace::p3d::model_p, ace::simulation::lod *); ~named_selection(); std::string name; std::vector faces; std::vector vertices; void animate(const glm::mat4 &, ace::vector3); }; typedef std::shared_ptr named_selection_p; class vertex { public: vertex(vertex_table &, ace::vector3, uint32_t); ~vertex(); ace::vector3 operator * (const float &v) { return animated_vertex * v; } ace::vector3 operator / (const float &v) { return animated_vertex / v; } ace::vector3 operator * (const ace::vector3 &v) { return animated_vertex * v; } ace::vector3 operator / (const ace::vector3 &v) { return animated_vertex / v; } ace::vector3 operator + (const ace::vector3 &v) { return animated_vertex + v; } ace::vector3 operator - (const ace::vector3 &v) { return animated_vertex - v; } ace::vector3 operator - () { return -(animated_vertex); } bool operator == (const ace::vector3 &r) { return (animated_vertex == r); } bool operator > (const ace::vector3 &r) const { throw 1; } bool operator < (const ace::vector3 &r) const { throw 1; } bool operator <= (const ace::vector3 &r) const { throw 1; } bool operator >= (const ace::vector3 &r) const { throw 1; } float x() { return animated_vertex.x(); } float y() { return animated_vertex.y(); } float z() { return animated_vertex.z(); } uint16_t id() { return this->vertex_id; } operator ace::vector3() { return animated_vertex; } std::vector faces; std::vector selections; void animate(const glm::mat4 &, ace::vector3, bool); private: ace::vector3 original_vertex; ace::vector3 animated_vertex; vertex_table &table; uint16_t vertex_id; }; class lod { public: lod() {}; lod(const ace::p3d::lod_p, const ace::p3d::model_p); ~lod(); uint32_t id; float type; vertex_table vertices; ace::vector3 autocenter_pos; std::map selections; std::vector faces; }; class animation; typedef std::shared_ptr animation_p; class lod_animation_info { public: lod_animation_info() {}; lod_animation_info(animation *, lod_p, const ace::p3d::animate_bone_p, const ace::p3d::animation_p, const ace::p3d::model_p); ~lod_animation_info(); animation *animation_definition; int32_t index; lod_p lod; ace::vector3 axis_direction; ace::vector3 axis_position; }; typedef std::shared_ptr lod_animation_info_p; class animation { public: animation() {}; animation(object *, const ace::p3d::animation_p, const ace::p3d::model_p); ~animation(); uint32_t type; std::string name; // "RightDoor" std::string source; // "rotor" float min_value; float max_value; float min_phase; float max_phase; float offset0; float offset1; float angle0; float angle1; float hide_value; ace::vector3 direct_axis_pos; ace::vector3 direct_axis_dir; float direct_angle; float direct_axis_offset; uint32_t source_address; std::vector transforms; std::map lod_info; animation_transform animate(const float, const std::vector &, animation_transform); float get_scale(float); }; class bone; typedef std::shared_ptr bone_p; class bone { public: bone( const std::string, const std::vector &, const std::map &, bone *, const ace::p3d::model_p, object *); ~bone() {}; std::string name; bone *parent; std::vector children; std::vector animations; object *base_object; void animate(const std::map &, const std::vector &, animation_transform base_transforms); }; class object { public: object(); object(const ace::p3d::model_p); ~object(); std::vector lods; std::vector animations; void animate(const std::map &, const std::vector &); std::map all_bones; bone_p root_bone; }; } }