Tramway SDK
model.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_RENDER_MODEL_H
5#define TRAM_SDK_RENDER_MODEL_H
6
7#include <render/material.h>
8
9namespace tram::Render {
10
11struct ModelData;
12struct ModelAABB;
13
17 uint32_t material;
18};
19
20struct IndexRange {
21 uint32_t index_offset = 0;
22 uint32_t index_length = 0;
23 uint32_t material_count = 0;
25 uint32_t materials[15] = { 0 };
26};
27
28class Model : public Resource {
29public:
31
32 void LoadFromDisk();
33 void LoadFromMemory();
34
35 void Unload() {}
36
38
41
42 const std::vector<Bone>& GetArmature() const { return armature; }
43 const std::vector<Material*>& GetMaterials() const { return materials; }
44 const std::vector<IndexRange>& GetIndexRanges() const { return index_ranges; }
45
46 void DrawAABB(vec3 position, quat rotation);
47 void FindAllFromRay(vec3 ray_pos, vec3 ray_dir, std::vector<AABBTriangle>& result);
48
49 vec3 GetAABBMin() const { return aabb_min; }
50 vec3 GetAABBMax() const { return aabb_max; }
51
52 static Model* Find(name_t name);
53
54protected:
56
59
60 std::vector<IndexRange> index_ranges;
61
64
65 std::vector<Material*> materials;
66
67 Model* source = nullptr;
68
69 std::vector<Bone> armature;
73};
74
75}
76
77
78#endif // TRAM_SDK_RENDER_MODEL_H
Definition: model.h:28
static Model * Find(name_t name)
Definition: model.cpp:32
vec3 aabb_max
Definition: model.h:63
void LoadFromDisk()
Definition: model.cpp:277
void DrawAABB(vec3 position, quat rotation)
Definition: model.cpp:165
vec3 GetAABBMin() const
Definition: model.h:49
void FindAllFromRay(vec3 ray_pos, vec3 ray_dir, std::vector< AABBTriangle > &result)
Definition: model.cpp:114
indexarray_t GetIndexArray() const
Definition: model.h:40
void LoadFromMemory()
Definition: model.cpp:43
ModelAABB * model_aabb
Definition: model.h:71
size_t approx_vram_usage
Definition: model.h:72
std::vector< IndexRange > index_ranges
Definition: model.h:60
const std::vector< IndexRange > & GetIndexRanges() const
Definition: model.h:44
vec3 aabb_min
Definition: model.h:62
ModelData * model_data
Definition: model.h:70
std::vector< Bone > armature
Definition: model.h:69
void Unload()
Definition: model.h:35
const std::vector< Bone > & GetArmature() const
Definition: model.h:42
vertexformat_t GetVertexFormat() const
Definition: model.h:37
Model(name_t name)
Definition: model.h:30
indexarray_t index_array
Definition: model.h:58
vertexarray_t vertex_array
Definition: model.h:57
vec3 GetAABBMax() const
Definition: model.h:50
vertexarray_t GetVertexArray() const
Definition: model.h:39
Model * source
Definition: model.h:67
std::vector< Material * > materials
Definition: model.h:65
const std::vector< Material * > & GetMaterials() const
Definition: model.h:43
vertexformat_t vertex_format
Definition: model.h:55
Definition: resource.h:12
name_t name
Definition: resource.h:38
Definition: gui.h:9
uint32_t vertexformat_t
Definition: render.h:20
@ VERTEX_STATIC
Definition: render.h:67
uint32_t materialtype_t
Definition: render.h:21
glm::vec3 vec3
Definition: math.h:12
glm::quat quat
Definition: math.h:13
Definition: model.h:14
vec3 normal
Definition: model.h:16
uint32_t material
Definition: model.h:17
vec3 point1
Definition: model.h:15
vec3 point2
Definition: model.h:15
vec3 point3
Definition: model.h:15
Definition: model.h:20
materialtype_t material_type
Definition: model.h:24
uint32_t material_count
Definition: model.h:23
uint32_t index_length
Definition: model.h:22
uint32_t materials[15]
Definition: model.h:25
uint32_t index_offset
Definition: model.h:21
Definition: model.cpp:108
Definition: vertices.h:48
Definition: render.h:118
void * generic
Definition: render.h:123
Definition: render.h:101
void * generic
Definition: render.h:112
Definition: uid.h:11