Copperfield Engine 0.1
C++ Game Engine
Loading...
Searching...
No Matches
load_obj.hpp
1#pragma once
2#include <future>
3#include <iostream>
4#include <map>
5#include <unordered_map>
6#include <optional>
7#include <vector>
8
9
10#include "math/vector_2.h"
11#include "math/vector_3.h"
12#include "tiny_obj_loader.h"
13
14class ResourceManager;
15
16struct Vertex {
17 coma::Vec3 pos = {0.0f, 0.0f, 0.0f};
18 coma::Vec3 nor = {0.0f, 0.0f, 0.0f};
19 coma::Vec2 uv = {0.0f, 0.0f};
20
21 bool operator==(const Vertex& other) const {
22 return (other.pos == pos && other.nor == nor && other.uv == uv);
23 }
24};
25
26class Obj {
27 public:
28 Obj() = default;
29
32 static std::optional<Obj> loadObj(const std::string& dir,
33 const std::string& name);
34
38 bool createBuffers(ResourceManager& e);
39
40 tinyobj::attrib_t attrib_;
41 std::vector<tinyobj::shape_t> shapes_;
42 std::vector<tinyobj::material_t> materials_;
43 std::string name_;
44 std::vector<Vertex> vertex_map_;
45
46};
Stores and offers access to all meshes, textures, and sounds of the engine.
Definition: resource_manager.hpp:27
represents mathematical vector with 2 components
Definition: vector_2.h:7
represents mathematical vector with 3 components
Definition: vector_3.h:12