BlankMat 0.1.0
Free open-source 3D texture creation application
Loading...
Searching...
No Matches
Material Class Reference

Class that stores all texture and render information for a material. More...

Inheritance diagram for Material:
Collaboration diagram for Material:

Public Member Functions

bool IsInternal ()
 Returns whether the material is for internal use only or not.
 
unsigned int UpdateShader (Shader *shader)
 Updates the given shader with this material's properties.
 
void LoadShaderTextures (State *state, Material *defaultMat)
 Loads the textures of this material into the OpenGL context.
 
void LoadMaterialTextures (TextureContainer *textures)
 Loads the textures of the material from the scene's texture list.
 
 Material (TextureContainer *textures)
 Constructs the default material.
 
 Material (const std::string &name, const std::string &scope, TextureContainer *textures, const glm::vec3 &color=glm::vec3(1.0f), bool internal=false)
 Constructs a material out of a single color (diffuse)
 
 Material (const std::string &name, const std::string &scope, Config *config, Texture *map_kd, Texture *map_ka, Texture *map_ks, Texture *map_bump, Texture *map_ns, Texture *map_d)
 Constructs a material out of a config file and preloaded textures.
 
 Material (const std::string &name, const std::string &scope, Texture *map_kd, Texture *map_ka, Texture *map_ks, Texture *map_bump, Texture *map_ns, Texture *map_d, const glm::vec3 &ka=glm::vec3(), const glm::vec3 &kd=glm::vec3(), const glm::vec3 &ks=glm::vec3(), float ns=0, float ni=1, float d=1, const glm::vec3 &ke=glm::vec3(), int illum=2)
 Constructs a material out of preloaded textures.
 
 Material (const std::string &name, const std::string &scope, const std::vector< Texture * > &map_kd, const std::vector< Texture * > &map_ka, const std::vector< Texture * > &map_ks, const std::vector< Texture * > &map_bump, const std::vector< Texture * > &map_ns, const std::vector< Texture * > &map_d, const glm::vec3 &ka=glm::vec3(), const glm::vec3 &kd=glm::vec3(), const glm::vec3 &ks=glm::vec3(), float ns=0, float ni=1, float d=1, const glm::vec3 &ke=glm::vec3(), int illum=2)
 Constructs a material out of lists of preloaded textures.
 
 Material (const std::string &name, const std::string &scope, const std::string &map_kd, const std::string &map_ka, const std::string &map_ks, const std::string &map_bump, const std::string &map_ns, const std::string &map_d, const glm::vec3 &ka=glm::vec3(), const glm::vec3 &kd=glm::vec3(), const glm::vec3 &ks=glm::vec3(), float ns=0, float ni=1, float d=1, const glm::vec3 &ke=glm::vec3(), int illum=2)
 Constructs a material out of unloaded texture names.
 
- Public Member Functions inherited from ISelectable
virtual SelectableType GetSelectableType ()
 Returns the type of the selectable.
 
 ISelectable (SelectableType type=SelectableType::NONE)
 Sets the type of the selectable.
 
- Public Member Functions inherited from INameable
virtual void Rename (const std::string &newName, bool includeScope=true)
 Renames the object, setting the scope to be the scoped part of the name.
 
virtual void SetName (const std::string &name)
 Sets the name of the object. Note: Does not set the scope variable. If renaming based on raw input, use Rename() instead to set the scope.
 
virtual void SetScope (const std::string &scope)
 Sets the scope of the object.
 
std::string GetUnscopedName ()
 Returns the unscoped name of the object.
 
std::string GetScope ()
 Returns the scope of the object.
 
std::string GetScopedName ()
 Returns the scoped name of the object.
 
void InitName (const std::string &name, const std::string &scope="")
 Initializes the nameable object with the given name and scope.
 
 INameable ()
 Creates a default nameable object without name or scope.
 

Public Attributes

glm::vec3 mKA
 Ambient color.
 
glm::vec3 mKD
 Diffuse color.
 
glm::vec3 mKS
 Specular color.
 
glm::vec3 mKE
 Emissive color.
 
float mNS
 Specular exponent.
 
float mNI
 Index of Refraction.
 
float mD
 Dissolve, AKA. transparency.
 
int mIllum
 Illumination mode.
 
TexturemMapKD
 Diffuse color texture.
 
TexturemMapKA
 Ambient color texture.
 
TexturemMapKS
 Specular color texture.
 
TexturemMapBump
 Bump/Normal texture.
 
TexturemMapNS
 Specular highlight texture.
 
TexturemMapD
 Alpha (dissolve) texture.
 

Protected Attributes

glm::vec3 mCurKD = glm::vec3(1.0f)
 
glm::vec3 mCurKA = glm::vec3(0.0f)
 
glm::vec3 mCurKS = glm::vec3(1.0f)
 
glm::vec3 mCurKE = glm::vec3(0.0f)
 
bool mShadowsEnabled = true
 
bool mIsInternal = false
 
std::vector< Texture * > mCurTextures
 
std::vector< std::string > mCurTextureNames
 
std::string mTargetMapKD = "default_diffuse"
 
std::string mTargetMapKA = "default_ambient"
 
std::string mTargetMapKS = "default_specular"
 
std::string mTargetMapBump = "default_normal"
 
std::string mTargetMapNS = "default_height"
 
std::string mTargetMapD = "default_alpha"
 
std::vector< Texture * > mTextures
 List of textures that are part of this material.
 
- Protected Attributes inherited from ISelectable
SelectableType mSelectableType = SelectableType::NONE
 Type of the selectable.
 
- Protected Attributes inherited from INameable
std::string mName = ""
 Name of the object.
 
std::string mScope = ""
 Scope of the object.
 

Detailed Description

Class that stores all texture and render information for a material.

Constructor & Destructor Documentation

◆ Material() [1/6]

Material::Material ( TextureContainer textures)
explicit

Constructs the default material.

Parameters
texturesTexture container for the scene

◆ Material() [2/6]

Material::Material ( const std::string &  name,
const std::string &  scope,
TextureContainer textures,
const glm::vec3 &  color = glm::vec3(1.0f),
bool  internal = false 
)
explicit

Constructs a material out of a single color (diffuse)

Parameters
nameName of the material
scopeScope of the material
texturesTexture container for the scene
colorDiffuse color of the material
internalWhether the material is for internal use only

◆ Material() [3/6]

Material::Material ( const std::string &  name,
const std::string &  scope,
Config config,
Texture map_kd,
Texture map_ka,
Texture map_ks,
Texture map_bump,
Texture map_ns,
Texture map_d 
)
explicit

Constructs a material out of a config file and preloaded textures.

Parameters
nameName of the material
scopeScope of the material
configConfig to build material from
map_kdDiffuse texture
map_kaAmbient texture
map_ksSpecular texture
map_bumpNormal/Bump texture
map_nsSpecular highlight/Height texture
map_dAlpha texture

◆ Material() [4/6]

Material::Material ( const std::string &  name,
const std::string &  scope,
Texture map_kd,
Texture map_ka,
Texture map_ks,
Texture map_bump,
Texture map_ns,
Texture map_d,
const glm::vec3 &  ka = glm::vec3(),
const glm::vec3 &  kd = glm::vec3(),
const glm::vec3 &  ks = glm::vec3(),
float  ns = 0,
float  ni = 1,
float  d = 1,
const glm::vec3 &  ke = glm::vec3(),
int  illum = 2 
)
explicit

Constructs a material out of preloaded textures.

Parameters
nameName of the material
scopeScope of the material
map_kdDiffuse texture
map_kaAmbient texture
map_ksSpecular texture
map_bumpNormal/Bump texture
map_nsSpecular highlight/Height texture
map_dAlpha texture
kaAlpha color
kdDiffuse color
ksSpecular color
nsSpecular exponent
niIndex of refraction
dAlpha
keEmissive color
illumIllumination mode

◆ Material() [5/6]

Material::Material ( const std::string &  name,
const std::string &  scope,
const std::vector< Texture * > &  map_kd,
const std::vector< Texture * > &  map_ka,
const std::vector< Texture * > &  map_ks,
const std::vector< Texture * > &  map_bump,
const std::vector< Texture * > &  map_ns,
const std::vector< Texture * > &  map_d,
const glm::vec3 &  ka = glm::vec3(),
const glm::vec3 &  kd = glm::vec3(),
const glm::vec3 &  ks = glm::vec3(),
float  ns = 0,
float  ni = 1,
float  d = 1,
const glm::vec3 &  ke = glm::vec3(),
int  illum = 2 
)
explicit

Constructs a material out of lists of preloaded textures.

Parameters
nameName of the material
scopeScope of the material
map_kdDiffuse textures
map_kaAmbient textures
map_ksSpecular textures
map_bumpNormal/Bump textures
map_nsSpecular highlight/Height textures
map_dAlpha textures
kaAlpha color
kdDiffuse color
ksSpecular color
nsSpecular exponent
niIndex of refraction
dAlpha
keEmissive color
illumIllumination mode

◆ Material() [6/6]

Material::Material ( const std::string &  name,
const std::string &  scope,
const std::string &  map_kd,
const std::string &  map_ka,
const std::string &  map_ks,
const std::string &  map_bump,
const std::string &  map_ns,
const std::string &  map_d,
const glm::vec3 &  ka = glm::vec3(),
const glm::vec3 &  kd = glm::vec3(),
const glm::vec3 &  ks = glm::vec3(),
float  ns = 0,
float  ni = 1,
float  d = 1,
const glm::vec3 &  ke = glm::vec3(),
int  illum = 2 
)
explicit

Constructs a material out of unloaded texture names.

Parameters
nameName of the material
scopeScope of the material
map_kdDiffuse texture
map_kaAmbient texture
map_ksSpecular texture
map_bumpNormal/Bump texture
map_nsSpecular highlight/Height texture
map_dAlpha texture
kaAlpha color
kdDiffuse color
ksSpecular color
nsSpecular exponent
niIndex of refraction
dAlpha
keEmissive color
illumIllumination mode

Member Function Documentation

◆ IsInternal()

bool Material::IsInternal ( )

Returns whether the material is for internal use only or not.

Returns
Whether the material is internal

◆ LoadMaterialTextures()

void Material::LoadMaterialTextures ( TextureContainer textures)

Loads the textures of the material from the scene's texture list.

Parameters
texturesTexture container for the scene

◆ LoadShaderTextures()

void Material::LoadShaderTextures ( State state,
Material defaultMat 
)

Loads the textures of this material into the OpenGL context.

Parameters
stateGlobal state of the application
defaultMatDefault material

◆ UpdateShader()

unsigned int Material::UpdateShader ( Shader shader)

Updates the given shader with this material's properties.

Parameters
shaderShader to use for this material
Returns
Index of next available GL texture

Member Data Documentation

◆ mCurKA

glm::vec3 Material::mCurKA = glm::vec3(0.0f)
protected

◆ mCurKD

glm::vec3 Material::mCurKD = glm::vec3(1.0f)
protected

◆ mCurKE

glm::vec3 Material::mCurKE = glm::vec3(0.0f)
protected

◆ mCurKS

glm::vec3 Material::mCurKS = glm::vec3(1.0f)
protected

◆ mCurTextureNames

std::vector<std::string> Material::mCurTextureNames
protected

◆ mCurTextures

std::vector<Texture*> Material::mCurTextures
protected

◆ mD

float Material::mD

Dissolve, AKA. transparency.

◆ mIllum

int Material::mIllum

Illumination mode.

◆ mIsInternal

bool Material::mIsInternal = false
protected

◆ mKA

glm::vec3 Material::mKA

Ambient color.

◆ mKD

glm::vec3 Material::mKD

Diffuse color.

◆ mKE

glm::vec3 Material::mKE

Emissive color.

◆ mKS

glm::vec3 Material::mKS

Specular color.

◆ mMapBump

Texture* Material::mMapBump

Bump/Normal texture.

◆ mMapD

Texture* Material::mMapD

Alpha (dissolve) texture.

◆ mMapKA

Texture* Material::mMapKA

Ambient color texture.

◆ mMapKD

Texture* Material::mMapKD

Diffuse color texture.

◆ mMapKS

Texture* Material::mMapKS

Specular color texture.

◆ mMapNS

Texture* Material::mMapNS

Specular highlight texture.

◆ mNI

float Material::mNI

Index of Refraction.

◆ mNS

float Material::mNS

Specular exponent.

◆ mShadowsEnabled

bool Material::mShadowsEnabled = true
protected

◆ mTargetMapBump

std::string Material::mTargetMapBump = "default_normal"
protected

◆ mTargetMapD

std::string Material::mTargetMapD = "default_alpha"
protected

◆ mTargetMapKA

std::string Material::mTargetMapKA = "default_ambient"
protected

◆ mTargetMapKD

std::string Material::mTargetMapKD = "default_diffuse"
protected

◆ mTargetMapKS

std::string Material::mTargetMapKS = "default_specular"
protected

◆ mTargetMapNS

std::string Material::mTargetMapNS = "default_height"
protected

◆ mTextures

std::vector<Texture*> Material::mTextures
protected

List of textures that are part of this material.