Tramway SDK
material.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_MATERIAL_H
5#define TRAM_SDK_RENDER_MATERIAL_H
6
7#include <render/render.h>
8
9namespace tram::Render {
10
24};
25
30};
31
32class Material : public Resource {
33public:
36
37 inline texturehandle_t GetTexture() const { return texture; }
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 void SetMaterialType(materialtype_t type) { this->type = type; }
49 void SetMaterialProperty(MaterialProperty property) { this->property = property; }
50 void SetColor(color_t color) { this->color = color; }
51 void SetSpecular(float weight, float exponent, float transparency) { specular_weight = weight; specular_exponent = exponent; specular_transparency = transparency; }
52 void SetTextureType(TextureType texture_type) { this->texture_type = texture_type; }
53 void SetSource(Material* source) { this->source = source; }
54
55 void MakePattern(vec3 color1, vec3 color2);
56
57 void LoadFromDisk();
58 void LoadFromMemory();
59
60 void Unload() {}
61
62 static Material* Find(name_t name);
64
65 static void LoadMaterialInfo(const char* filename);
66
67protected:
73
74 Material* source = nullptr;
75
76 vec3 color = {1.0f, 1.0f, 1.0f};
77 float specular_weight = 0.0f;
78 float specular_exponent = 1.0f;
80
81 uint32_t width = 0;
82 uint32_t height = 0;
83 uint8_t channels = 0;
84 uint8_t* texture_data = nullptr;
86
87 friend class Sprite;
88};
89
90}
91
92#endif // TRAM_SDK_RENDER_MATERIAL_H
Definition: material.h:32
Material * source
Definition: material.h:74
void SetSpecular(float weight, float exponent, float transparency)
Definition: material.h:51
void LoadFromDisk()
Definition: material.cpp:213
MaterialProperty GetProperty() const
Definition: material.h:41
vec3 GetColor() const
Definition: material.h:42
void SetTextureType(TextureType texture_type)
Definition: material.h:52
size_t approx_vram_usage
Definition: material.h:85
void SetMaterialProperty(MaterialProperty property)
Definition: material.h:49
vec3 color
Definition: material.h:76
void SetMaterialType(materialtype_t type)
Definition: material.h:47
static Material * Make(name_t name, materialtype_t type)
Creates a material.
Definition: material.cpp:164
float GetSpecularWeight() const
Definition: material.h:43
void LoadFromMemory()
Definition: material.cpp:284
void SetMaterialFilter(MaterialFilter filter)
Definition: material.h:48
uint32_t width
Definition: material.h:81
uint32_t GetWidth() const
Definition: material.h:38
float GetSpecularTransparency() const
Definition: material.h:45
Material(name_t name)
Definition: material.h:34
uint32_t height
Definition: material.h:82
uint8_t * texture_data
Definition: material.h:84
texturehandle_t texture
Definition: material.h:68
static void LoadMaterialInfo(const char *filename)
Loads a Material definition file.
Definition: material.cpp:36
TextureType texture_type
Definition: material.h:72
void SetSource(Material *source)
Definition: material.h:53
texturehandle_t GetTexture() const
Definition: material.h:37
static Material * Find(name_t name)
Finds a Material.
Definition: material.cpp:182
MaterialProperty= PROPERTY_METAL
Definition: material.h:71
float specular_transparency
Definition: material.h:79
MaterialFilter filter
Definition: material.h:70
float GetSpecularExponent() const
Definition: material.h:44
uint32_t GetHeight() const
Definition: material.h:39
materialtype_t GetType() const
Definition: material.h:40
uint8_t channels
Definition: material.h:83
void SetColor(color_t color)
Definition: material.h:50
float specular_exponent
Definition: material.h:78
float specular_weight
Definition: material.h:77
void MakePattern(vec3 color1, vec3 color2)
Makes Material a pattern.
Definition: material.cpp:201
materialtype_t type
Definition: material.h:69
void Unload()
Definition: material.h:60
Definition: sprite.h:24
Definition: resource.h:12
name_t name
Definition: resource.h:38
Definition: gui.h:9
@ MATERIAL_TEXTURE
Definition: render.h:75
vec3 color_t
Definition: render.h:17
uint32_t materialtype_t
Definition: render.h:21
MaterialProperty
Definition: material.h:11
@ PROPERTY_METAL_THIN
Definition: material.h:13
@ PROPERTY_GRATE
Definition: material.h:16
@ PROPERTY_SNOW
Definition: material.h:20
@ PROPERTY_SLIME
Definition: material.h:14
@ PROPERTY_GRASS
Definition: material.h:21
@ PROPERTY_GLASS
Definition: material.h:19
@ PROPERTY_WOOD
Definition: material.h:17
@ PROPERTY_TILE
Definition: material.h:15
@ PROPERTY_COMPUTER
Definition: material.h:18
@ PROPERTY_CONCRETE
Definition: material.h:22
@ PROPERTY_FLESH
Definition: material.h:23
@ PROPERTY_METAL
Definition: material.h:12
MaterialFilter
Definition: render.h:85
@ FILTER_NEAREST
Definition: render.h:86
TextureType
Definition: material.h:26
@ TEXTURE_SOURCE
Definition: material.h:29
@ TEXTURE_NONE
Definition: material.h:27
@ TEXTURE_SAME
Definition: material.h:28
glm::vec3 vec3
Definition: math.h:12
Definition: render.h:142
void * generic
Definition: render.h:147
Definition: uid.h:11