Tramway SDK v0.1.1
model.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_RENDER_MODEL_H
4#define TRAM_SDK_RENDER_MODEL_H
5
6#include <render/material.h>
7
8namespace tram::Render {
9
10struct ModelData;
11struct ModelAABB;
12
16 uint32_t material;
17};
18
19struct IndexRange {
20 uint32_t index_offset = 0;
21 uint32_t index_length = 0;
22 uint32_t material_count = 0;
24 uint32_t materials[15] = { 0 };
25};
26
27class Model : public Resource {
28public:
30
31 void LoadFromDisk();
32 void LoadFromMemory();
33
34 void Unload() {}
35
37
40
41 const std::vector<Bone>& GetArmature() const { return armature; }
42 const std::vector<Material*>& GetMaterials() const { return materials; }
43 const std::vector<IndexRange>& GetIndexRanges() const { return index_ranges; }
44
45 void DrawAABB(vec3 position, quat rotation);
46 void FindAllFromRay(vec3 ray_pos, vec3 ray_dir, std::vector<AABBTriangle>& result);
47 void FindAllFromAABB(vec3 min, vec3 max, std::vector<AABBTriangle>& result);
48
49 vec3 GetAABBMin() const { return aabb_min; }
50 vec3 GetAABBMax() const { return aabb_max; }
51
52 vec3 GetOrigin() const { return origin; }
53
54 float GetNearDistance() const { return fade_near; }
55 float GetFarDistance() const { return fade_far; }
56 void SetNearDistance(float dist) { fade_near = dist; }
57 void SetFarDistance(float dist) { fade_far = dist; }
58
59 static Model* Find(name_t name);
60
61protected:
63
66
67 std::vector<IndexRange> index_ranges;
68
69 vec3 aabb_min = {0.0f, 0.0f, 0.0f};
70 vec3 aabb_max = {0.0f, 0.0f, 0.0f};
71
72 float fade_near = 0.0f;
73 float fade_far = INFINITY;
74
75 vec3 origin = {0.0f, 0.0f, 0.0f};
76
77 std::vector<Material*> materials;
78
79 Model* source = nullptr;
80
81 std::vector<Bone> armature;
85};
86
87}
88
89
90#endif // TRAM_SDK_RENDER_MODEL_H
Definition: model.h:27
static Model * Find(name_t name)
Definition: model.cpp:58
vec3 aabb_max
Definition: model.h:70
void LoadFromDisk()
Definition: model.cpp:287
void DrawAABB(vec3 position, quat rotation)
Draws the AABB tree.
Definition: model.cpp:205
vec3 GetAABBMin() const
Definition: model.h:49
void FindAllFromRay(vec3 ray_pos, vec3 ray_dir, std::vector< AABBTriangle > &result)
Finds triangles that intersect ray.
Definition: model.cpp:143
vec3 GetOrigin() const
Definition: model.h:52
indexarray_t GetIndexArray() const
Definition: model.h:39
void LoadFromMemory()
Definition: model.cpp:69
ModelAABB * model_aabb
Definition: model.h:83
void SetNearDistance(float dist)
Definition: model.h:56
float GetFarDistance() const
Definition: model.h:55
size_t approx_vram_usage
Definition: model.h:84
void FindAllFromAABB(vec3 min, vec3 max, std::vector< AABBTriangle > &result)
Definition: model.cpp:154
std::vector< IndexRange > index_ranges
Definition: model.h:67
const std::vector< IndexRange > & GetIndexRanges() const
Definition: model.h:43
vec3 aabb_min
Definition: model.h:69
ModelData * model_data
Definition: model.h:82
std::vector< Bone > armature
Definition: model.h:81
void Unload()
Definition: model.h:34
const std::vector< Bone > & GetArmature() const
Definition: model.h:41
vertexformat_t GetVertexFormat() const
Definition: model.h:36
Model(name_t name)
Definition: model.h:29
indexarray_t index_array
Definition: model.h:65
float fade_near
Definition: model.h:72
float GetNearDistance() const
Definition: model.h:54
float fade_far
Definition: model.h:73
vertexarray_t vertex_array
Definition: model.h:64
vec3 GetAABBMax() const
Definition: model.h:50
vertexarray_t GetVertexArray() const
Definition: model.h:38
Model * source
Definition: model.h:79
void SetFarDistance(float dist)
Definition: model.h:57
std::vector< Material * > materials
Definition: model.h:77
const std::vector< Material * > & GetMaterials() const
Definition: model.h:42
vertexformat_t vertex_format
Definition: model.h:62
vec3 origin
Definition: model.h:75
Definition: resource.h:11
name_t name
Definition: resource.h:37
High-level Render system API.
Definition: gui.h:8
uint32_t vertexformat_t
Definition: render.h:19
@ VERTEX_STATIC
Definition: render.h:68
uint32_t materialtype_t
Definition: render.h:20
glm::vec3 vec3
Definition: math.h:11
glm::quat quat
Definition: math.h:12
Definition: model.h:13
vec3 normal
Definition: model.h:15
uint32_t material
Definition: model.h:16
vec3 point1
Definition: model.h:14
vec3 point2
Definition: model.h:14
vec3 point3
Definition: model.h:14
Definition: model.h:19
materialtype_t material_type
Definition: model.h:23
uint32_t material_count
Definition: model.h:22
uint32_t index_length
Definition: model.h:21
uint32_t materials[15]
Definition: model.h:24
uint32_t index_offset
Definition: model.h:20
Definition: model.cpp:134
Definition: vertices.h:58
Definition: render.h:126
Definition: render.h:109
Interned string type.
Definition: uid.h:10