일단 float * float 위에서는 움직이는데 큰 좌표계 구성 안하면 멀티플레이 절대 불가능

This commit is contained in:
2025-05-21 01:52:41 +09:00
parent 0ea46b288d
commit 96c9f70828
16 changed files with 379 additions and 106 deletions

22
include/asset/loader.h Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include "asset/object/model.h"
#include "assimp/Importer.hpp"
#include "assimp/postprocess.h"
#include "assimp/scene.h"
namespace veng {
typedef Model& inModel;
class Loader {
public:
void setPath(std::string path);
void loadModel(inModel model);
std::vector<std::uint8_t> readTexture();
private:
Assimp::Importer importer_;
const struct aiScene* scene_;
};
} // namespace veng

View File

@@ -1,15 +1,15 @@
#pragma once
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <vector>
#include "material.h"
#include "vulkan/graphics.h"
#include "vulkan/buffer_handle.h"
#include "vulkan/vertex.h"
#include <memory>
namespace veng {
struct Model {
Model(std::shared_ptr<class Graphics> graphics);
Model(class Graphics* graphics) : graphics_(graphics) {}
~Model();
std::vector<veng::Vertex> vertices;
@@ -17,11 +17,26 @@ struct Model {
std::vector<std::uint32_t> indices;
veng::BufferHandle index_buffer;
glm::mat4 transform;
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;
private:
std::weak_ptr<class Graphics> graphics_;
glm::mat4 UpdateTransform(float dt);
glm::vec3 original_offset = glm::vec3(0.f);
private:
class Graphics* graphics_;
};
} // namespace veng

View File

@@ -0,0 +1,39 @@
#pragma once
#include <unordered_map>
#include "asset/object/model.h"
namespace std {
template <>
struct hash<glm::i64vec3> {
std::size_t operator()(const glm::i64vec3& v) const noexcept {
std::size_t h1 = std::hash<int64_t>()(v.x);
std::size_t h2 = std::hash<int64_t>()(v.y);
std::size_t h3 = std::hash<int64_t>()(v.z);
return h1 ^ (h2 << 1) ^ (h3 << 2);
}
};
} // namespace std
namespace veng {
class Coord {
public:
Coord() : seg(glm::i64vec3(0)), pos(glm::vec3(0.f)) {}
Coord(glm::vec3 _pos) : seg(glm::i64vec3(0)), pos(_pos) {}
Coord(glm::i64vec3 _seg, glm::vec3 _pos) : seg(_seg), pos(_pos) {}
glm::i64vec3 seg;
glm::vec3 pos;
Coord operator+(const Coord& other) const;
Coord operator-(const Coord& other) const;
std::unordered_map<glm::i64vec3, glm::vec3> coord_system;
private:
const std::float_t border = 1000.f;
};
} // namespace veng

View File

@@ -40,6 +40,7 @@ class Graphics final {
BufferHandle CreateIndexBuffer(gsl::span<std::uint32_t> indices);
void DestroyBuffer(BufferHandle handle);
TextureHandle CreateTexture(gsl::czstring path);
TextureHandle CreateTexture(std::vector<std::uint8_t> image_file_data);
TextureHandle CreateTexture(gsl::span<std::uint8_t> image_file_data);
void DestroyTexture(TextureHandle handle);