Tramway SDK v0.1.1
material.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_RENDER_MATERIAL_H
4#define TRAM_SDK_RENDER_MATERIAL_H
5
6#include <render/render.h>
7
8namespace tram::Render {
9
23};
24
29};
30
31class Material : public Resource {
32public:
35
36 inline texturehandle_t GetTexture() const { return texture; }
37 inline material_t GetMaterial() const { return material; }
38 inline uint32_t GetWidth() const { return width; }
39 inline uint32_t GetHeight() const { return height; }
40 inline materialtype_t GetType() const { return type; }
41 inline MaterialProperty GetProperty() const { return property; }
42 inline vec3 GetColor() const { return color; }
43 inline float GetSpecularWeight() const { return specular_weight; }
44 inline float GetSpecularExponent() const { return specular_exponent; }
45 inline float GetSpecularTransparency() const { return specular_transparency; }
46
47 // TODO: update the material in the API when these are called
48 void SetMaterialType(materialtype_t type) { this->type = type; }
51 void SetColor(color_t color) { this->color = color; }
52 void SetSpecular(float weight, float exponent, float transparency) { specular_weight = weight; specular_exponent = exponent; specular_transparency = transparency; }
53 void SetReflectivity(float reflectivity) { this->reflectivity = reflectivity; }
54 void SetTextureType(TextureType texture_type) { this->texture_type = texture_type; }
55 void SetSource(Material* source) { this->source = source; }
56
57 void MakePattern(vec3 color1, vec3 color2);
58
59 void LoadFromDisk();
60 void LoadFromMemory();
61
62 void Unload() {}
63
64 static Material* Find(name_t name);
66
67 static void LoadMaterialInfo(const char* filename);
68
69protected:
75
76 material_t material = {.generic = nullptr};
77
78 Material* source = nullptr;
79
80 vec3 color = {1.0f, 1.0f, 1.0f};
81 float specular_weight = 0.0f;
82 float specular_exponent = 1.0f;
84 float reflectivity = 0.0f;
85
86 uint32_t width = 0;
87 uint32_t height = 0;
88 uint8_t channels = 0;
89 uint8_t* texture_data = nullptr;
91
92 friend class Sprite;
93};
94
95}
96
97#endif // TRAM_SDK_RENDER_MATERIAL_H
Material resource.
Definition: material.h:31
Material * source
Definition: material.h:78
void SetSpecular(float weight, float exponent, float transparency)
Definition: material.h:52
void LoadFromDisk()
Definition: material.cpp:224
MaterialProperty GetProperty() const
Definition: material.h:41
vec3 GetColor() const
Definition: material.h:42
void SetTextureType(TextureType texture_type)
Definition: material.h:54
size_t approx_vram_usage
Definition: material.h:90
void SetMaterialProperty(MaterialProperty property)
Definition: material.h:50
material_t GetMaterial() const
Definition: material.h:37
vec3 color
Definition: material.h:80
void SetMaterialType(materialtype_t type)
Definition: material.h:48
static Material * Make(name_t name, materialtype_t type)
Creates a material.
Definition: material.cpp:175
float GetSpecularWeight() const
Definition: material.h:43
void LoadFromMemory()
Pushes material textures to GPU.
Definition: material.cpp:298
void SetMaterialFilter(MaterialFilter filter)
Definition: material.h:49
uint32_t width
Definition: material.h:86
uint32_t GetWidth() const
Definition: material.h:38
float GetSpecularTransparency() const
Definition: material.h:45
Material(name_t name)
Definition: material.h:33
uint32_t height
Definition: material.h:87
uint8_t * texture_data
Definition: material.h:89
texturehandle_t texture
Definition: material.h:70
static void LoadMaterialInfo(const char *filename)
Loads a Material definition file.
Definition: material.cpp:45
TextureType texture_type
Definition: material.h:74
void SetSource(Material *source)
Definition: material.h:55
texturehandle_t GetTexture() const
Definition: material.h:36
MaterialProperty property
Definition: material.h:73
static Material * Find(name_t name)
Finds a Material.
Definition: material.cpp:193
float specular_transparency
Definition: material.h:83
MaterialFilter filter
Definition: material.h:72
float GetSpecularExponent() const
Definition: material.h:44
uint32_t GetHeight() const
Definition: material.h:39
materialtype_t GetType() const
Definition: material.h:40
void SetReflectivity(float reflectivity)
Definition: material.h:53
float reflectivity
Definition: material.h:84
material_t material
Definition: material.h:76
uint8_t channels
Definition: material.h:88
void SetColor(color_t color)
Definition: material.h:51
float specular_exponent
Definition: material.h:82
float specular_weight
Definition: material.h:81
void MakePattern(vec3 color1, vec3 color2)
Makes Material a pattern.
Definition: material.cpp:212
materialtype_t type
Definition: material.h:71
void Unload()
Definition: material.h:62
Sprite resource.
Definition: sprite.h:23
Definition: resource.h:11
name_t name
Definition: resource.h:37
High-level Render system API.
Definition: gui.h:8
@ MATERIAL_TEXTURE
Definition: render.h:76
vec3 color_t
Definition: render.h:16
uint32_t materialtype_t
Definition: render.h:20
MaterialProperty
Definition: material.h:10
@ PROPERTY_METAL_THIN
Definition: material.h:12
@ PROPERTY_GRATE
Definition: material.h:15
@ PROPERTY_SNOW
Definition: material.h:19
@ PROPERTY_SLIME
Definition: material.h:13
@ PROPERTY_GRASS
Definition: material.h:20
@ PROPERTY_GLASS
Definition: material.h:18
@ PROPERTY_WOOD
Definition: material.h:16
@ PROPERTY_TILE
Definition: material.h:14
@ PROPERTY_COMPUTER
Definition: material.h:17
@ PROPERTY_CONCRETE
Definition: material.h:21
@ PROPERTY_FLESH
Definition: material.h:22
@ PROPERTY_METAL
Definition: material.h:11
MaterialFilter
Definition: render.h:87
@ FILTER_NEAREST
Definition: render.h:88
TextureType
Definition: material.h:25
@ TEXTURE_SOURCE
Definition: material.h:28
@ TEXTURE_NONE
Definition: material.h:26
@ TEXTURE_SAME
Definition: material.h:27
glm::vec3 vec3
Definition: math.h:11
Definition: render.h:186
void * generic
Definition: render.h:191
Definition: render.h:160
Interned string type.
Definition: uid.h:10