Classes | Private Member Functions | Private Attributes | Friends

VR3Material Class Reference

The material class. More...

#include <VR3Material.h>

Collaboration diagram for VR3Material:
Collaboration graph
[legend]

List of all members.

Classes

struct  MatTexture
 Texture container for the current material. More...

Public Member Functions

Constructor
 VR3Material (const char *file_name, const char *mat_name=0, int matID=-1, const char *multimat_name=0, int submatID=-1)
 Constructor of the class.
Destroying Function
void Destroy ()
 Pseudo-Destructor for the VR3Material Class.
Get and Set Functions
void SetEmission (GLfloat r, GLfloat g, GLfloat b)
 Sets the material emission color using the given values.
void SetEmission (const GLfloat *color)
 Sets the material emission color using the given vector.
void GetEmission (GLfloat *color)
 Gets the material emission color into the given vector.
void SetAmbient (GLfloat r, GLfloat g, GLfloat b)
 Sets the material ambient color using the given values.
void SetAmbient (const GLfloat *color)
 Sets the material ambient color using the given vector.
void GetAmbient (GLfloat *color)
 Gets the material ambient color into the given vector.
void SetDiffuse (GLfloat r, GLfloat g, GLfloat b)
 Sets the material diffuse color using the given values.
void SetDiffuse (const GLfloat *color)
 Sets the material diffuse color using the given vector.
void GetDiffuse (GLfloat *color)
 Gets the material diffuse color into the given vector.
void SetSpecular (GLfloat r, GLfloat g, GLfloat b)
 Sets the material specular color using the given values.
void SetSpecular (const GLfloat *color)
 Sets the material specular color using the given vector.
void GetSpecular (GLfloat *color)
 Gets the material specular color into the given vector.
void SetTransparency (GLfloat trans)
 Sets the material transparency.
GLfloat GetTransparency ()
 Gets the material transparency.
void SetShininess (GLfloat shin)
 Sets the material shininess.
GLfloat GetShininess ()
 Gets the shininess transparency.
void GetTextureTransf (int slot, GLfloat *rot, GLfloat *off, GLfloat *til)
 Gets texture transformation parameters.
void SetTextureTransf (int slot, const GLfloat *rot, const GLfloat *off, const GLfloat *til)
 Sets texture transformation parameters.
GLfloat GetTextureIntensity (int slot)
 Gets the texture intensity.
void SetTextureIntensity (int slot, GLfloat in)
 Sets the texture intensity.
const char * GetTextureFiltering (int slot)
 Gets the texture filtering mode.
void SetTextureFiltering (int slot, const char *fil)
 Sets the texture filtering mode.
VR3TextureGetTexture (int slot)
 Gets one of the material textures.
void SetTexture (int slot, VR3Texture *tex)
 Sets one of the enabled material textures.
int GetID ()
 Gets the ID of the material.
int GetSubID ()
 Gets the ID of the material as a submaterial of its container.
bool IsSubMaterial ()
 Checks if the material is part of a multimaterial.
const char * GetName ()
 Gets the name of the material.
const char * GetClass ()
 Gets the class of the material.
const char * GetMultiName ()
 Gets the name of the multimaterial containing this material (if any)
const char * GetFileName ()
 Gets the name of the file the material was extracted from.

Private Member Functions

 VR3Material (const VR3Material &)
 Disable default copy constructor.
VR3Materialoperator= (const VR3Material &)
 Disable default assignment operator.
Destructor
 ~VR3Material ()
 Destructor of the class.

Private Attributes

int m_ID
 ID of the material extracted from the file.
int m_subID
 ID of this material as a submaterial of a multimaterial.
std::string m_multiname
 Name of the material object containing this material.
std::string m_name
 Name of the material object, extracted from the file.
std::string m_matfile
 Name of the file the material was loaded from (absolute path)
std::string m_class
 Material class (currently not used)
GLfloat m_emission [3]
 Material emission color.
GLfloat m_ambient [3]
 Material ambient reflectance.
GLfloat m_diffuse [3]
 Material diffuse reflectance.
GLfloat m_specular [3]
 Material specular reflectance.
GLfloat m_transparency
 Material transparency.
GLfloat m_shininess
 Material shininess.
MatTexturem_ptex
 Material primary texture (0 if none)
MatTexturem_stex
 Material self-illumination texture (the light map, 0 if none)
MatTexturem_ntex
 Material normal map (0 if none)
MatTexturem_dtex
 Material displacement map (0 if none)

Friends

class VR3MaterialManager
class VR3Mesh
 Friend class VR3Mesh to access the private data members.
class VR3MeshManager
 Friend class VR3MeshManager to figure out the rendering flags values.

Detailed Description

The material class.

The VR3Material class allows to have direct access to material objects, which can be created and handled independently from other visual entities. An object of the VR3Material class represents a simple material, it may be a simple global material or a material loaded as a submaterial of a multimaterial.

Definition at line 34 of file VR3Material.h.


Constructor & Destructor Documentation

VR3Material::VR3Material ( const VR3Material  ) [private]

Disable default copy constructor.

VR3Material::~VR3Material (  ) [private]

Destructor of the class.

Deletes a VR3Material object. This is a private destructor because a VR3Material object may only be deleted by the VR3MaterialManager static module, this will happen when the number of references to this material object drops to 0.

VR3Material::VR3Material ( const char *  file_name,
const char *  mat_name = 0,
int  matID = -1,
const char *  multimat_name = 0,
int  submatID = -1 
)

Constructor of the class.

Creates a new VR3Material object and initializes the object by loading data from the file specified through file_name. Currently, only AAM files are supported. The function parameters are used to identify the specific material to load from the AAM file. Default values cause the selection of the first material found in the AAM file. Only one or some of this parameters may be passed in order to identify the desired material. A value of VR3MAT_NOSUB may be passed as submatID in order to specify that the built material should not be part of a multimaterial.

Parameters:
[in]file_nameThe name of the file where to load from
[in]mat_nameThe material name inside the AAM file (0 if any)
[in]matIDThe material ID inside the AAM file (-1 if any)
[in]multimat_nameThe name of the material containing the desired one
[in]submatIDThe submaterial ID if the material is part of a multimaterial (use VR3MAT_NOSUB to specify to avoid loading a submaterial).

Member Function Documentation

void VR3Material::Destroy (  )

Pseudo-Destructor for the VR3Material Class.

When a dynamic instance to the VRMaterial class is not used anymore by the programmer or by a VR3Obj instace, we cannot delete the whole dynamic instance. Other entities may be using the object in dynamic memory and the only thing we must do is call the Destroy() functions in order to notify the VR3MaterialManager that a reference to a material object has been deleted. If the material is to be destroyed, the VR3MaterialManager will handle that.

void VR3Material::GetAmbient ( GLfloat *  color )

Gets the material ambient color into the given vector.

Gets the ambient color for the material.

Parameters:
[out]colorThe material ambient color
const char* VR3Material::GetClass (  ) [inline]

Gets the class of the material.

This function may be used to retrieve the material class read from the file it was extracted from.

Returns:
The class of the material (this pointer is only valid until the material object is destroyed)

Definition at line 484 of file VR3Material.h.

void VR3Material::GetDiffuse ( GLfloat *  color )

Gets the material diffuse color into the given vector.

Gets the diffuse color for the material.

Parameters:
[out]colorThe material diffuse color
void VR3Material::GetEmission ( GLfloat *  color )

Gets the material emission color into the given vector.

Gets the emission color for the material.

Parameters:
[out]colorThe material emission color
const char* VR3Material::GetFileName (  ) [inline]

Gets the name of the file the material was extracted from.

This function may be used to retrieve the file name of the file the material was extracted from. Many different materials from the same file may be loaded. The retrieved file name is the absolute path to the file.

Returns:
The name of the material file (this pointer is only valid until the material object is destroyed)

Definition at line 508 of file VR3Material.h.

int VR3Material::GetID (  ) [inline]

Gets the ID of the material.

This function may be used to retrieve the material ID that identifies the material in the material file it was extracted from. If the material is a submaterial, the ID of the multimaterial containing it is returned.

Returns:
The ID of the material

Definition at line 445 of file VR3Material.h.

const char* VR3Material::GetMultiName (  ) [inline]

Gets the name of the multimaterial containing this material (if any)

This function may be used to retrieve the name of the multimaterial containing this material. If this material is not part of a multimaterial, 0 will be returned.

Returns:
The name of the multimaterial containing this material (this pointer is only valid until the material object is destroyed)

Definition at line 496 of file VR3Material.h.

const char* VR3Material::GetName (  ) [inline]

Gets the name of the material.

This function may be used to retrieve the material name in the file it was extracted from. Material names are not unique and only IDs ans subIDs may be used to identify a material in a particular file (but not across files).

Returns:
The name of the material (this pointer is only valid until the material object is destroyed)

Definition at line 474 of file VR3Material.h.

GLfloat VR3Material::GetShininess (  ) [inline]

Gets the shininess transparency.

Gets the shininess for the material

Returns:
The material shininess

Definition at line 301 of file VR3Material.h.

void VR3Material::GetSpecular ( GLfloat *  color )

Gets the material specular color into the given vector.

Gets the specular color for the material.

Parameters:
[out]colorThe material specular color
int VR3Material::GetSubID (  ) [inline]

Gets the ID of the material as a submaterial of its container.

This function may be used to retrieve the material ID that identifies the material inside the multimaterial it was extracted from. If VR3MAT_NOSUB is returned, the material is not part of other materials.

Returns:
The subID of the material

Definition at line 455 of file VR3Material.h.

VR3Texture* VR3Material::GetTexture ( int  slot )

Gets one of the material textures.

4 different textures may be associated with a single material, they are used differently depending on the texture type in the current material. Each material has 4 different texture slots:

  • Diffuse texture
  • Light map
  • Normal map
  • Displacement map This function is used to get the VR3Texture object associated with a particular texture type. This operation does not carry in the result the texture slot or the material texture application parameters.
Parameters:
[in]slotSlot of the texture in the material, one of:

  • VR3TEX_DIFFUSE
  • VR3TEX_LIGHT
  • VR3TEX_NORMAL
  • VR3TEX_DISPLACEMENT
Returns:
One of the current material textures (0 if not found)
const char* VR3Material::GetTextureFiltering ( int  slot )

Gets the texture filtering mode.

This function is used to obtain texture filtering mode for this material, given a texture slot, this function returns the filtering mode used to apply the texture to this material. The filtering parameter is currently ignored during rendering.

Parameters:
[in]slotSlot of the texture in the material, one of:

  • VR3TEX_DIFFUSE
  • VR3TEX_LIGHT
  • VR3TEX_NORMAL
  • VR3TEX_DISPLACEMENT
Returns:
The texture filtering mode (this string is only valid until a new filtering mode is specified or the material destroyed, 0 is returned if the specified slot is not available)
GLfloat VR3Material::GetTextureIntensity ( int  slot )

Gets the texture intensity.

This function is used to obtain texture intensity for this material, given a texture slot, this function returns the intensity used to apply the texture to this material. The intensity parameter is currently ignored during rendering.

Parameters:
[in]slotSlot of the texture in the material, one of:

  • VR3TEX_DIFFUSE
  • VR3TEX_LIGHT
  • VR3TEX_NORMAL
  • VR3TEX_DISPLACEMENT
Returns:
The texture intensity (if not available, 0.0 will be returned)
void VR3Material::GetTextureTransf ( int  slot,
GLfloat *  rot,
GLfloat *  off,
GLfloat *  til 
)

Gets texture transformation parameters.

This function is used to obtain texture transformation parameters for this material, given a texture slot, this function returns tiling, rotation and offset information for this texture.

Parameters:
[in]slotSlot of the texture in the material, one of:

  • VR3TEX_DIFFUSE
  • VR3TEX_LIGHT
  • VR3TEX_NORMAL
  • VR3TEX_DISPLACEMENT
[out]rotThe 3 rotation angles (3 elements)
[out]offThe 2 offset values (2 elements)
[out]tilThe 2 tiling values (2 elements)
GLfloat VR3Material::GetTransparency (  ) [inline]

Gets the material transparency.

Gets the transparency for the material

Returns:
The material transparency

Definition at line 285 of file VR3Material.h.

bool VR3Material::IsSubMaterial (  ) [inline]

Checks if the material is part of a multimaterial.

Returns:
The subID of the material is part of a multimaterial, false otherways.

Definition at line 462 of file VR3Material.h.

VR3Material& VR3Material::operator= ( const VR3Material  ) [private]

Disable default assignment operator.

void VR3Material::SetAmbient ( GLfloat  r,
GLfloat  g,
GLfloat  b 
)

Sets the material ambient color using the given values.

Sets the new ambient color for the material.

Parameters:
[in]r,g,bThe components of the new material color
void VR3Material::SetAmbient ( const GLfloat *  color )

Sets the material ambient color using the given vector.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
[in]colorThe new material ambient color
void VR3Material::SetDiffuse ( GLfloat  r,
GLfloat  g,
GLfloat  b 
)

Sets the material diffuse color using the given values.

Sets the diffuse new color for the material.

Parameters:
[in]r,g,bThe components of the new material diffuse color
void VR3Material::SetDiffuse ( const GLfloat *  color )

Sets the material diffuse color using the given vector.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
[in]colorThe new material diffuse color
void VR3Material::SetEmission ( const GLfloat *  color )

Sets the material emission color using the given vector.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
[in]colorThe new material emission color
void VR3Material::SetEmission ( GLfloat  r,
GLfloat  g,
GLfloat  b 
)

Sets the material emission color using the given values.

Sets the new emission color for the material.

Parameters:
[in]r,g,bThe components of the new emission color
void VR3Material::SetShininess ( GLfloat  shin ) [inline]

Sets the material shininess.

Sets the shininess for the material (used in flat and phong shading).

Parameters:
[in]shinThe new material transparency

Definition at line 293 of file VR3Material.h.

void VR3Material::SetSpecular ( GLfloat  r,
GLfloat  g,
GLfloat  b 
)

Sets the material specular color using the given values.

Sets the new specular color for the material.

Parameters:
[in]r,g,bThe components of the new material specular color
void VR3Material::SetSpecular ( const GLfloat *  color )

Sets the material specular color using the given vector.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
[in]colorThe new material specular color
void VR3Material::SetTexture ( int  slot,
VR3Texture tex 
)

Sets one of the enabled material textures.

The user may set the texture image used for one of the texture slots in the current material. Only a texture slot already active in the material may be chosen. This function effectively change the texture image used for the texture type, but does not change the application parameters of the texture on the material.

Parameters:
[in]slotSlot of the texture in the material, one of:

  • VR3TEX_DIFFUSE
  • VR3TEX_LIGHT
  • VR3TEX_NORMAL
  • VR3TEX_DISPLACEMENT
[in]texThe texture image to apply
void VR3Material::SetTextureFiltering ( int  slot,
const char *  fil 
)

Sets the texture filtering mode.

This function is used to set the texture filtering mode for this material, given a texture slot, this function sets the filtering mode used to apply the texture to this material. The filtering parameter is currently ignored during rendering.

Parameters:
[in]slotSlot of the texture in the material, one of:

  • VR3TEX_DIFFUSE
  • VR3TEX_LIGHT
  • VR3TEX_NORMAL
  • VR3TEX_DISPLACEMENT
[in]filThe desired filtering mode
void VR3Material::SetTextureIntensity ( int  slot,
GLfloat  in 
)

Sets the texture intensity.

This function is used to set texture intensity for this material, given a texture slot, this function sets the intensity used to apply the texture to this material. The intensity parameter is currently ignored during rendering.

Parameters:
[in]slotSlot of the texture in the material, one of:

  • VR3TEX_DIFFUSE
  • VR3TEX_LIGHT
  • VR3TEX_NORMAL
  • VR3TEX_DISPLACEMENT
[in]inThe texture intensity
void VR3Material::SetTextureTransf ( int  slot,
const GLfloat *  rot,
const GLfloat *  off,
const GLfloat *  til 
)

Sets texture transformation parameters.

This function is used to set texture cooridinate transformation parameters for this material, given a texture slot, this function sets tiling, rotation and offset information for this texture.

Parameters:
[in]slotSlot of the texture in the material, one of:

  • VR3TEX_DIFFUSE
  • VR3TEX_LIGHT
  • VR3TEX_NORMAL
  • VR3TEX_DISPLACEMENT
[in]rotThe 3 rotation angles (3 elements)
[in]offThe 2 offset values (2 elements)
[in]tilThe 2 tiling values (2 elements)
void VR3Material::SetTransparency ( GLfloat  trans ) [inline]

Sets the material transparency.

Sets the transparency for the material

Parameters:
[in]transThe new material transparency

Definition at line 277 of file VR3Material.h.


Friends And Related Function Documentation

friend class VR3MaterialManager [friend]

Friend class VR3MaterialManager to access all private data members and the destructor

Definition at line 37 of file VR3Material.h.

friend class VR3Mesh [friend]

Friend class VR3Mesh to access the private data members.

Definition at line 39 of file VR3Material.h.

friend class VR3MeshManager [friend]

Friend class VR3MeshManager to figure out the rendering flags values.

Definition at line 41 of file VR3Material.h.


Member Data Documentation

GLfloat VR3Material::m_ambient[3] [private]

Material ambient reflectance.

Definition at line 96 of file VR3Material.h.

std::string VR3Material::m_class [private]

Material class (currently not used)

Definition at line 91 of file VR3Material.h.

GLfloat VR3Material::m_diffuse[3] [private]

Material diffuse reflectance.

Definition at line 98 of file VR3Material.h.

Material displacement map (0 if none)

Definition at line 113 of file VR3Material.h.

GLfloat VR3Material::m_emission[3] [private]

Material emission color.

Definition at line 94 of file VR3Material.h.

int VR3Material::m_ID [private]

ID of the material extracted from the file.

Definition at line 75 of file VR3Material.h.

std::string VR3Material::m_matfile [private]

Name of the file the material was loaded from (absolute path)

Definition at line 89 of file VR3Material.h.

std::string VR3Material::m_multiname [private]

Name of the material object containing this material.

This ID will be 0 if the material has no container because it's not a multimaterial (i.e. is a simple global material).

Definition at line 85 of file VR3Material.h.

std::string VR3Material::m_name [private]

Name of the material object, extracted from the file.

Definition at line 87 of file VR3Material.h.

Material normal map (0 if none)

Definition at line 111 of file VR3Material.h.

Material primary texture (0 if none)

Definition at line 107 of file VR3Material.h.

GLfloat VR3Material::m_shininess [private]

Material shininess.

Definition at line 104 of file VR3Material.h.

GLfloat VR3Material::m_specular[3] [private]

Material specular reflectance.

Definition at line 100 of file VR3Material.h.

Material self-illumination texture (the light map, 0 if none)

Definition at line 109 of file VR3Material.h.

int VR3Material::m_subID [private]

ID of this material as a submaterial of a multimaterial.

This ID will be VR3MAT_NOSUB if the material is not a submaterial of a multimaterial (i.e. is a simple global material).

Definition at line 80 of file VR3Material.h.

GLfloat VR3Material::m_transparency [private]

Material transparency.

Definition at line 102 of file VR3Material.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines