Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Engine::Material Class Reference

#include <Material.hpp>

Classes

struct  MaterialData
 

Public Member Functions

 Material ()=default
 
 Material (const aiScene *scene, uint32_t materialIndex, eastl::string modelName)
 Creates a new material from the material data stored in the scene at the given index. Doesn't load any data if the index is larger than the amount of materials contained in. Use this function in the mesh loading code to create the meshes with the default materials for that mesh. More...
 
virtual ~Material ()
 
virtual void SetDiffuseTexture (eastl::string diffuseTextureName)
 Changes the diffuse texture of the material. NOTE: Texture will be loaded in, if it doesn't excist yet. More...
 
virtual void SetDiffuseTexture (eastl::shared_ptr< Texture > diffuseTexture)
 Changes the diffuse texture of the material. Pass a nullptr to clear the current texture. More...
 
eastl::weak_ptr< TextureGetDiffuseTexture ()
 Returns the diffuse texture of the material. Returns nullptr if the current material doesn't have a diffuse texture. More...
 
eastl::weak_ptr< TextureGetDefaultDiffuseTexture ()
 Returns the diffuse texture that was defined by the model this material was created from. Returns nullptr if no diffuse texture was specified for the material. More...
 
bool IsDiffuseLoaded () const
 Indicates if the material has a diffuse texture loaded or not. More...
 
virtual void SetBumpMapTexture (eastl::string bumpMapTextureName)
 Changes the bump map texture of the material. NOTE: Texture will be loaded in, if it doesn't excist yet. More...
 
virtual void SetBumpMapTexture (eastl::shared_ptr< Texture > bumpMapTexture)
 Changes the bump map texture of the material. Pass a nullptr to clear the current texture. More...
 
eastl::weak_ptr< TextureGetBumpMapTexture () const
 Returns the bump map texture of the material. Returns nullptr if the current material doesn't have a bump map texture. More...
 
eastl::weak_ptr< TextureGetDefaultBumpMapTexture () const
 Returns the bump map texture that was defined by the model this material was created from. Returns nullptr if no bump map texture was specified for the material. More...
 
bool IsBumpMapLoaded () const
 Indicates if the material has a bump map texture loaded or not. More...
 
virtual void SetSpecularTexture (eastl::shared_ptr< Texture > specularTexture)
 Changes the specular texture of the material. Pass a nullptr to clear the current texture. More...
 
eastl::weak_ptr< TextureGetSpecularTexture () const
 Returns the specular texture of the material. Returns nullptr if the current material doesn't have a specular texture. More...
 
eastl::weak_ptr< TextureGetDefaultSpecularTexture () const
 Returns the specular texture that was defined by the model this material was created from. Returns nullptr if no specular texture was specified for the material. More...
 
bool IsSpecularLoaded () const
 Indicates if the material has a specular texture loaded or not. More...
 
virtual void SetDiffuseColor (glm::vec3 diffuseColor)
 Sets the material's diffuse color. More...
 
glm::vec3 GetDiffuseColor () const
 Returns the material's diffuse color. More...
 
glm::vec3 GetDefaultDiffuseColor () const
 Returns the diffuse color that was defined by the model this material was created from. More...
 
virtual void SetSpecularColor (glm::vec3 specularColor)
 Sets the material's specular color. More...
 
glm::vec3 GetSpecularColor () const
 Returns the material's specular color. More...
 
glm::vec3 GetDefaultSpecularColor () const
 Returns the specular color that was defined by the model this material was created from. More...
 
void SetSpecularScale (float scale)
 Sets the scale of the specular highlights (strength) of the material. More...
 
float GetSpecularScale () const
 Returns the scale of the specular highlights (strength). More...
 
float GetDefaultSpecularScale () const
 Returns the scale of the specular highlights (strength) that was defined by the model this material was created from. More...
 
void SetSpecularExponent (float exponent)
 Sets the specular exponent of the material (shinyness). More...
 
float GetSpecularExponent () const
 Returns the specular exponent of the material. More...
 
float GetDefaultSpecularExponent () const
 Returns the specular exponent of the material that was defined by the model this material was created from. More...
 
bool operator== (const Material &other) const
 Returns whether or not two materials are the same. More...
 

Protected Types

typedef struct Engine::Material::MaterialData MaterialData_t
 

Protected Member Functions

virtual void UpdateMaterialData ()
 
eastl::weak_ptr< TextureLoadTexture (const aiScene *scene, aiMaterial *material, aiTextureType textureType)
 

Protected Attributes

MaterialData_t materialData_
 
MaterialData_t defaultMaterialData_
 
eastl::string modelName
 
eastl::weak_ptr< TexturediffuseTexture
 
eastl::weak_ptr< TexturedefaultDiffuseTexture
 
eastl::weak_ptr< TexturebumpMapTexture
 
eastl::weak_ptr< TexturedefaultBumpMapTexture
 
eastl::weak_ptr< TexturespecularTexture
 
eastl::weak_ptr< TexturedefaultSpecularTexture
 
eastl::weak_ptr< TexturemissingTexture
 

Detailed Description

Definition at line 19 of file Material.hpp.

Member Typedef Documentation

Constructor & Destructor Documentation

Engine::Material::Material ( )
default
Engine::Material::Material ( const aiScene *  scene,
uint32_t  materialIndex,
eastl::string  modelName 
)

Creates a new material from the material data stored in the scene at the given index. Doesn't load any data if the index is larger than the amount of materials contained in. Use this function in the mesh loading code to create the meshes with the default materials for that mesh.

Parameters
sceneThe scene (model) to load the material from.
materialIndexThe specific material from the material array to load.
modelNameThe name of the model. This is used for naming any embedded textures found in the file.

Definition at line 9 of file Material.cpp.

Engine::Material::~Material ( )
virtual

Definition at line 79 of file Material.cpp.

Member Function Documentation

eastl::weak_ptr< Texture > Engine::Material::GetBumpMapTexture ( ) const

Returns the bump map texture of the material. Returns nullptr if the current material doesn't have a bump map texture.

Returns
The bump map texture used by the material. NOTE: Will return a temporary texture in case the default bump map texture hasn't been assigned.

Definition at line 164 of file Material.cpp.

eastl::weak_ptr< Texture > Engine::Material::GetDefaultBumpMapTexture ( ) const

Returns the bump map texture that was defined by the model this material was created from. Returns nullptr if no bump map texture was specified for the material.

Returns
The default bump map texture for the material. NOTE: Will return a temporary texture in case the default bump map texture hasn't been assigned.

Definition at line 172 of file Material.cpp.

glm::vec3 Engine::Material::GetDefaultDiffuseColor ( ) const

Returns the diffuse color that was defined by the model this material was created from.

Returns
The default diffuse color.

Definition at line 226 of file Material.cpp.

eastl::weak_ptr< Texture > Engine::Material::GetDefaultDiffuseTexture ( )

Returns the diffuse texture that was defined by the model this material was created from. Returns nullptr if no diffuse texture was specified for the material.

Returns
The default diffuse texture for the material. NOTE: Will return a temporary texture in case the default diffuse texture hasn't been assigned.

Definition at line 121 of file Material.cpp.

glm::vec3 Engine::Material::GetDefaultSpecularColor ( ) const

Returns the specular color that was defined by the model this material was created from.

Returns
The default specular color.

Definition at line 242 of file Material.cpp.

float Engine::Material::GetDefaultSpecularExponent ( ) const

Returns the specular exponent of the material that was defined by the model this material was created from.

Returns
The default exponent as a float.

Definition at line 274 of file Material.cpp.

float Engine::Material::GetDefaultSpecularScale ( ) const

Returns the scale of the specular highlights (strength) that was defined by the model this material was created from.

Returns
The default scale as a float.

Definition at line 258 of file Material.cpp.

eastl::weak_ptr< Texture > Engine::Material::GetDefaultSpecularTexture ( ) const

Returns the specular texture that was defined by the model this material was created from. Returns nullptr if no specular texture was specified for the material.

Returns
The default specular texture for the material.

Definition at line 205 of file Material.cpp.

glm::vec3 Engine::Material::GetDiffuseColor ( ) const

Returns the material's diffuse color.

Returns
The diffuse color.

Definition at line 221 of file Material.cpp.

eastl::weak_ptr< Texture > Engine::Material::GetDiffuseTexture ( )

Returns the diffuse texture of the material. Returns nullptr if the current material doesn't have a diffuse texture.

Returns
The diffuse texture used by the material. NOTE: Will return a temporary texture in case the default diffuse texture hasn't been assigned.

Definition at line 113 of file Material.cpp.

glm::vec3 Engine::Material::GetSpecularColor ( ) const

Returns the material's specular color.

Returns
The specular color.

Definition at line 237 of file Material.cpp.

float Engine::Material::GetSpecularExponent ( ) const

Returns the specular exponent of the material.

Returns
The exponent as a float.

Definition at line 269 of file Material.cpp.

float Engine::Material::GetSpecularScale ( ) const

Returns the scale of the specular highlights (strength).

Returns
The scale as a float.

Definition at line 253 of file Material.cpp.

eastl::weak_ptr< Texture > Engine::Material::GetSpecularTexture ( ) const

Returns the specular texture of the material. Returns nullptr if the current material doesn't have a specular texture.

Returns
The specular texture used by the material.

Definition at line 200 of file Material.cpp.

bool Engine::Material::IsBumpMapLoaded ( ) const

Indicates if the material has a bump map texture loaded or not.

Returns
Whether or not the material has a bump map texture.

Definition at line 180 of file Material.cpp.

bool Engine::Material::IsDiffuseLoaded ( ) const

Indicates if the material has a diffuse texture loaded or not.

Returns
Whether or not the material has a diffuse texture.

Definition at line 129 of file Material.cpp.

bool Engine::Material::IsSpecularLoaded ( ) const

Indicates if the material has a specular texture loaded or not.

Returns
Whether or not the material has a specular texture.

Definition at line 210 of file Material.cpp.

eastl::weak_ptr< Texture > Engine::Material::LoadTexture ( const aiScene *  scene,
aiMaterial *  material,
aiTextureType  textureType 
)
protected

Definition at line 297 of file Material.cpp.

bool Engine::Material::operator== ( const Material other) const

Returns whether or not two materials are the same.

Parameters
otherThe material to compare to.
Returns
Whether or not the materials are equal.

Definition at line 279 of file Material.cpp.

void Engine::Material::SetBumpMapTexture ( eastl::string  bumpMapTextureName)
virtual

Changes the bump map texture of the material. NOTE: Texture will be loaded in, if it doesn't excist yet.

Parameters
bumpMapTextureNameThe texture you want to create. NOTE: The texture needs to be located under 'Resources/Textures/'. You then give the texture name + extension. The texture can be in a subfolder of of 'Resources/Textures/'.

Definition at line 134 of file Material.cpp.

void Engine::Material::SetBumpMapTexture ( eastl::shared_ptr< Texture bumpMapTexture)
virtual

Changes the bump map texture of the material. Pass a nullptr to clear the current texture.

Parameters
bumpMapTextureThe new bump map texture.

Definition at line 149 of file Material.cpp.

void Engine::Material::SetDiffuseColor ( glm::vec3  diffuseColor)
virtual

Sets the material's diffuse color.

Parameters
diffuseColorThe new color.

Definition at line 215 of file Material.cpp.

void Engine::Material::SetDiffuseTexture ( eastl::string  diffuseTextureName)
virtual

Changes the diffuse texture of the material. NOTE: Texture will be loaded in, if it doesn't excist yet.

Parameters
diffuseTextureNameThe texture you want to create. NOTE: The texture needs to be located under 'Resources/Textures/'. You then give the texture name + extension. The texture can be in a subfolder of of 'Resources/Textures/'.

Definition at line 83 of file Material.cpp.

void Engine::Material::SetDiffuseTexture ( eastl::shared_ptr< Texture diffuseTexture)
virtual

Changes the diffuse texture of the material. Pass a nullptr to clear the current texture.

Parameters
diffuseTextureThe new diffuse texture.

Definition at line 98 of file Material.cpp.

void Engine::Material::SetSpecularColor ( glm::vec3  specularColor)
virtual

Sets the material's specular color.

Parameters
specularColorThe new color.

Definition at line 231 of file Material.cpp.

void Engine::Material::SetSpecularExponent ( float  exponent)

Sets the specular exponent of the material (shinyness).

Parameters
exponentThe new exponent.

Definition at line 263 of file Material.cpp.

void Engine::Material::SetSpecularScale ( float  scale)

Sets the scale of the specular highlights (strength) of the material.

Parameters
scaleThe new scale.

Definition at line 247 of file Material.cpp.

void Engine::Material::SetSpecularTexture ( eastl::shared_ptr< Texture specularTexture)
virtual

Changes the specular texture of the material. Pass a nullptr to clear the current texture.

Parameters
specularTextureThe new specular texture.

Definition at line 185 of file Material.cpp.

void Engine::Material::UpdateMaterialData ( )
protectedvirtual

Definition at line 293 of file Material.cpp.

Member Data Documentation

eastl::weak_ptr<Texture> Engine::Material::bumpMapTexture
protected

Definition at line 230 of file Material.hpp.

eastl::weak_ptr<Texture> Engine::Material::defaultBumpMapTexture
protected

Definition at line 231 of file Material.hpp.

eastl::weak_ptr<Texture> Engine::Material::defaultDiffuseTexture
protected

Definition at line 229 of file Material.hpp.

MaterialData_t Engine::Material::defaultMaterialData_
protected

Definition at line 224 of file Material.hpp.

eastl::weak_ptr<Texture> Engine::Material::defaultSpecularTexture
protected

Definition at line 233 of file Material.hpp.

eastl::weak_ptr<Texture> Engine::Material::diffuseTexture
protected

Definition at line 228 of file Material.hpp.

MaterialData_t Engine::Material::materialData_
protected

Definition at line 223 of file Material.hpp.

eastl::weak_ptr<Texture> Engine::Material::missingTexture
protected

Definition at line 235 of file Material.hpp.

eastl::string Engine::Material::modelName
protected

Definition at line 226 of file Material.hpp.

eastl::weak_ptr<Texture> Engine::Material::specularTexture
protected

Definition at line 232 of file Material.hpp.


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