#pragma once #include #include #include #include #include "material.h" #include "vulkan_engine/vulkan/buffer_handle.h" #include "vulkan_engine/vulkan/vertex.h" #include "utils/snowflake.h" namespace veng { struct Model { Model() : graphics_(nullptr) {} Model(class Graphics* graphics) : graphics_(graphics) {} ~Model(); Model(const Model& other) : vertices(other.vertices), vertex_buffer(other.vertex_buffer), indices(other.indices), index_buffer(other.index_buffer), transform(other.transform), position(other.position), linear_velocity(other.linear_velocity), linear_acceleration(other.linear_acceleration), rotation(other.rotation), angular_velocity(other.angular_velocity), angular_acceleration(other.angular_acceleration), scale(other.scale), material(other.material), original_offset(other.original_offset), owner(other.owner), radius(other.radius), lifespan(other.lifespan), OnColision(other.OnColision), visible(other.visible), colision(other.colision) { ID = utils::GenerateID(); graphics_ = nullptr; } Model(Model&& other) : vertices(std::move(other.vertices)), vertex_buffer(std::move(other.vertex_buffer)), indices(std::move(other.indices)), index_buffer(std::move(other.index_buffer)), transform(other.transform), position(other.position), linear_velocity(other.linear_velocity), linear_acceleration(other.linear_acceleration), rotation(other.rotation), angular_velocity(other.angular_velocity), angular_acceleration(other.angular_acceleration), scale(other.scale), material(other.material), original_offset(other.original_offset), owner(other.owner), radius(other.radius), lifespan(other.lifespan), OnColision(other.OnColision), visible(other.visible), colision(other.colision) { ID = other.ID; ::memset(&other.ID, 0, 8); graphics_ = other.graphics_; other.graphics_ = nullptr; } Model& operator=(Model&& other) noexcept { if (this != &other) { ID = other.ID; ::memset(&other.ID, 0, 8); vertices = std::move(other.vertices); vertex_buffer = std::move(other.vertex_buffer); indices = std::move(other.indices); index_buffer = std::move(other.index_buffer); transform = other.transform; position = other.position; linear_velocity = other.linear_velocity; linear_acceleration = other.linear_acceleration; rotation = other.rotation; angular_velocity = other.angular_velocity; angular_acceleration = other.angular_acceleration; scale = other.scale; material = std::move(other.material); original_offset = other.original_offset; owner = other.owner; radius = other.radius; lifespan = other.lifespan; OnColision = other.OnColision; visible = other.visible; colision = other.colision; graphics_ = other.graphics_; other.graphics_ = nullptr; } return *this; } utils::Snowflake ID; std::vector Serialize(); void Deserialize(std::vector data); std::vector vertices; veng::BufferHandle vertex_buffer; std::vector indices; veng::BufferHandle index_buffer; glm::mat4 transform = glm::rotate(glm::mat4(1.0f), glm::radians(180.f), glm::vec3(0.f, 0.f, 1.f)); glm::vec3 position = glm::vec3(0.f); glm::vec3 linear_velocity = glm::vec3(0.f); glm::vec3 linear_acceleration = glm::vec3(0.f); glm::quat rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); glm::vec3 angular_velocity = glm::vec3(0.f); // μΆ• * 각속도(rad/s) glm::vec3 angular_acceleration = glm::vec3(0.f); glm::vec3 scale = glm::vec3(1.f); Material material; void Update(float dt); glm::vec3 original_offset = glm::vec3(0.f); Model* owner = this; std::float_t radius = 0.f; std::float_t lifespan = -1.f; std::function OnColision = nullptr; bool visible = true; bool colision = false; private: class Graphics* graphics_; }; } // namespace veng