iocp 구현하기
This commit is contained in:
9
Client/include/vulkan_engine/asset/object/material.h
Normal file
9
Client/include/vulkan_engine/asset/object/material.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "vulkan_engine/vulkan/texture_handle.h"
|
||||
|
||||
namespace veng {
|
||||
struct Material {
|
||||
TextureHandle texture_handle;
|
||||
};
|
||||
} // namespace veng
|
||||
156
Client/include/vulkan_engine/asset/object/model.h
Normal file
156
Client/include/vulkan_engine/asset/object/model.h
Normal file
@@ -0,0 +1,156 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "material.h"
|
||||
#include "vulkan_engine/vulkan/buffer_handle.h"
|
||||
#include "vulkan_engine/vulkan/vertex.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),
|
||||
OnColision(other.OnColision),
|
||||
visible(other.visible),
|
||||
colision(other.colision) {
|
||||
graphics_ = nullptr;
|
||||
}
|
||||
|
||||
Model(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),
|
||||
OnColision(other.OnColision),
|
||||
visible(other.visible),
|
||||
colision(other.colision) {
|
||||
graphics_ = other.graphics_;
|
||||
other.graphics_ = nullptr;
|
||||
}
|
||||
|
||||
Model& operator=(const Model& other) {
|
||||
if (this != &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;
|
||||
OnColision = other.OnColision;
|
||||
visible = other.visible;
|
||||
colision = other.colision;
|
||||
|
||||
graphics_ = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Model& operator=(Model&& other) noexcept {
|
||||
if (this != &other) {
|
||||
vertices = std::move(other.vertices);
|
||||
vertex_buffer = other.vertex_buffer;
|
||||
indices = std::move(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 = std::move(other.material);
|
||||
original_offset = other.original_offset;
|
||||
owner = other.owner;
|
||||
radius = other.radius;
|
||||
OnColision = other.OnColision;
|
||||
visible = other.visible;
|
||||
colision = other.colision;
|
||||
|
||||
// graphics_만 옮기고, 원본은 nullptr
|
||||
graphics_ = other.graphics_;
|
||||
other.graphics_ = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::vector<veng::Vertex> vertices;
|
||||
veng::BufferHandle vertex_buffer;
|
||||
std::vector<std::uint32_t> 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::function<void(Model* self, Model* other)> OnColision = nullptr;
|
||||
|
||||
bool visible = true;
|
||||
bool colision = false;
|
||||
|
||||
private:
|
||||
class Graphics* graphics_;
|
||||
};
|
||||
} // namespace veng
|
||||
Reference in New Issue
Block a user