Tramway SDK
Public Member Functions | Static Public Member Functions | Protected Attributes | Properties | Friends | List of all members
tram::Render::Material Class Reference

#include <material.h>

Inheritance diagram for tram::Render::Material:
tram::Resource

Public Member Functions

 Material (name_t name)
 
 Material (name_t name, materialtype_t type)
 
texturehandle_t GetTexture () const
 
uint32_t GetWidth () const
 
uint32_t GetHeight () const
 
materialtype_t GetType () const
 
MaterialProperty GetProperty () const
 
vec3 GetColor () const
 
float GetSpecularWeight () const
 
float GetSpecularExponent () const
 
float GetSpecularTransparency () const
 
void SetMaterialType (materialtype_t type)
 
void SetMaterialFilter (MaterialFilter filter)
 
void SetMaterialProperty (MaterialProperty property)
 
void SetColor (color_t color)
 
void SetSpecular (float weight, float exponent, float transparency)
 
void SetTextureType (TextureType texture_type)
 
void SetSource (Material *source)
 
void MakePattern (vec3 color1, vec3 color2)
 Makes Material a pattern. More...
 
void LoadFromDisk ()
 
void LoadFromMemory ()
 
void Unload ()
 
- Public Member Functions inherited from tram::Resource
 Resource (name_t name)
 
Resource::Status GetStatus () const
 
name_t GetName () const
 
size_t GetReferences () const
 
bool IsLoadFailed () const
 
void AddReference ()
 
void RemoveReference ()
 
void Load ()
 

Static Public Member Functions

static MaterialFind (name_t name)
 Finds a Material. More...
 
static MaterialMake (name_t name, materialtype_t type)
 Creates a material. More...
 
static void LoadMaterialInfo (const char *filename)
 Loads a Material definition file. More...
 

Protected Attributes

texturehandle_t texture = {.generic = 0}
 
materialtype_t type = MATERIAL_TEXTURE
 
MaterialFilter filter = FILTER_NEAREST
 
TextureType texture_type = TEXTURE_SAME
 
Materialsource = nullptr
 
vec3 color = {1.0f, 1.0f, 1.0f}
 
float specular_weight = 0.0f
 
float specular_exponent = 1.0f
 
float specular_transparency = 0.0f
 
uint32_t width = 0
 
uint32_t height = 0
 
uint8_t channels = 0
 
uint8_t * texture_data = nullptr
 
size_t approx_vram_usage = 0
 
- Protected Attributes inherited from tram::Resource
Status status = UNLOADED
 
name_t name
 
bool load_fail = false
 
size_t references = 0
 

Properties

MaterialPropertyPROPERTY_METAL
 

Friends

class Sprite
 

Additional Inherited Members

- Public Types inherited from tram::Resource
enum  Status { UNLOADED , LOADED , READY }
 

Constructor & Destructor Documentation

◆ Material() [1/2]

tram::Render::Material::Material ( name_t  name)
inline

◆ Material() [2/2]

tram::Render::Material::Material ( name_t  name,
materialtype_t  type 
)

Member Function Documentation

◆ Find()

Material * tram::Render::Material::Find ( name_t  name)
static

Finds a Material.

Finds a Material by its associated name. If Material with that names does not exist, then it is created (with the TEXTURE_LIGHTMAP type). In addition, for a Material to be found, it must have been created with the LoadMaterialInfo(), Make() or Find() methods.

Returns
Always returns a pointer to a Material.

◆ GetColor()

vec3 tram::Render::Material::GetColor ( ) const
inline

◆ GetHeight()

uint32_t tram::Render::Material::GetHeight ( ) const
inline

◆ GetProperty()

MaterialProperty tram::Render::Material::GetProperty ( ) const
inline

◆ GetSpecularExponent()

float tram::Render::Material::GetSpecularExponent ( ) const
inline

◆ GetSpecularTransparency()

float tram::Render::Material::GetSpecularTransparency ( ) const
inline

◆ GetSpecularWeight()

float tram::Render::Material::GetSpecularWeight ( ) const
inline

◆ GetTexture()

texturehandle_t tram::Render::Material::GetTexture ( ) const
inline

◆ GetType()

materialtype_t tram::Render::Material::GetType ( ) const
inline

◆ GetWidth()

uint32_t tram::Render::Material::GetWidth ( ) const
inline

◆ LoadFromDisk()

void tram::Render::Material::LoadFromDisk ( )
virtual

Implements tram::Resource.

◆ LoadFromMemory()

void tram::Render::Material::LoadFromMemory ( )
virtual

Implements tram::Resource.

◆ LoadMaterialInfo()

void tram::Render::Material::LoadMaterialInfo ( const char *  filename)
static

Loads a Material definition file.

◆ Make()

Material * tram::Render::Material::Make ( name_t  name,
materialtype_t  type 
)
static

Creates a material.

If a Material already exists with that name, then the existing Material is returned.

Returns
Always returns a pointer to a Material.

◆ MakePattern()

void tram::Render::Material::MakePattern ( vec3  color1,
vec3  color2 
)

Makes Material a pattern.

This method does the same thing as LoadFromDisk(), but instead of loading the texture from disk, it will generate a 64x64 pixel checkerboard pattern, like the one used for errored materials.

◆ SetColor()

void tram::Render::Material::SetColor ( color_t  color)
inline

◆ SetMaterialFilter()

void tram::Render::Material::SetMaterialFilter ( MaterialFilter  filter)
inline

◆ SetMaterialProperty()

void tram::Render::Material::SetMaterialProperty ( MaterialProperty  property)
inline

◆ SetMaterialType()

void tram::Render::Material::SetMaterialType ( materialtype_t  type)
inline

◆ SetSource()

void tram::Render::Material::SetSource ( Material source)
inline

◆ SetSpecular()

void tram::Render::Material::SetSpecular ( float  weight,
float  exponent,
float  transparency 
)
inline

◆ SetTextureType()

void tram::Render::Material::SetTextureType ( TextureType  texture_type)
inline

◆ Unload()

void tram::Render::Material::Unload ( )
inlinevirtual

Implements tram::Resource.

Friends And Related Function Documentation

◆ Sprite

friend class Sprite
friend

Member Data Documentation

◆ approx_vram_usage

size_t tram::Render::Material::approx_vram_usage = 0
protected

◆ channels

uint8_t tram::Render::Material::channels = 0
protected

◆ color

vec3 tram::Render::Material::color = {1.0f, 1.0f, 1.0f}
protected

◆ filter

MaterialFilter tram::Render::Material::filter = FILTER_NEAREST
protected

◆ height

uint32_t tram::Render::Material::height = 0
protected

◆ source

Material* tram::Render::Material::source = nullptr
protected

◆ specular_exponent

float tram::Render::Material::specular_exponent = 1.0f
protected

◆ specular_transparency

float tram::Render::Material::specular_transparency = 0.0f
protected

◆ specular_weight

float tram::Render::Material::specular_weight = 0.0f
protected

◆ texture

texturehandle_t tram::Render::Material::texture = {.generic = 0}
protected

◆ texture_data

uint8_t* tram::Render::Material::texture_data = nullptr
protected

◆ texture_type

TextureType tram::Render::Material::texture_type = TEXTURE_SAME
protected

◆ type

materialtype_t tram::Render::Material::type = MATERIAL_TEXTURE
protected

◆ width

uint32_t tram::Render::Material::width = 0
protected

Property Documentation

◆ PROPERTY_METAL

MaterialProperty= tram::Render::Material::PROPERTY_METAL
protected

The documentation for this class was generated from the following files: