Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Material Class Reference

Defines a Material used in a Milkshape3D Model. More...

#include <Material.h>

List of all members.

Public Methods

 Material (const MS3DMaterial *material)
 Initialize the Material using data from the corresponding Milkshape material.

const ColorgetAmbientColor () const
 Accessor for the ambient color.

const ColorgetDiffuseColor () const
 Accessor for the diffuse color.

const ColorgetSpecularColor () const
 Accessor for the specular color.

const ColorgetEmissiveColor () const
 Accessor for the emissive color.

float getSpecularShininess () const
 Accessor for the specular factor.

bool hasDetail () const
 Does this Material have a detail texture?

bool hasBumpmap () const
 Does this Material have a bumpmap texture?

unsigned int getDetailHandle () const
 Accessor for the Material detail texture handle.

unsigned int getBumpmapHandle () const
 Accessor for the Material bumpmap texture handle.

unsigned int getInvertedBumpmapHandle () const
 Accessor for the Material inverted bumpmap texture handle.

unsigned int getNormalmapHandle () const
 Accessor for the Material normalmap texture handle.


Private Methods

 Material (const Material &copy)
 Do not allow this Material to be copied.

Material & operator= (const Material &rhs)
 Do not allow this Material to be copied.

void initializeDetail (const Array3< unsigned char > &detailData)
 Initialize the m_detailHandle texture.

void initializeBumpmap (const Array3< unsigned char > &bumpmapData)
 Initialize the m_bumpmapHandle texture.

void initializeNormalmap (const Array3< unsigned char > &bumpmapData)
 Initialize the m_invertedBumpmapHandle texture.


Private Attributes

Color m_ambient
 The ambient color of this Material.

Color m_diffuse
 The diffuse color of this Material.

Color m_specular
 The specular color of this Material.

Color m_emissive
 The emissive color of this Material.

float m_shininess
 The specular factor of this Material.

std::string m_detailFileName
 The name of the file containing the detail texture.

std::string m_bumpmapFileName
 The name of the file containing the bumpmap texture.

bool m_hasDetail
 Does this material have a detail texture?

bool m_hasBumpmap
 Does this material have a bumpmap texture?

unsigned int m_detailHandle
 The handle to the detail texture.

unsigned int m_bumpmapHandle
 The handle to the bumpmap (heightmap) texture.

unsigned int m_invertedBumpmapHandle
 The handle to the inverted bumpmap (heightmap) texture.

unsigned int m_normalmapHandle
 The handle to the normalmap texture.


Detailed Description

Defines a Material used in a Milkshape3D Model.


Constructor & Destructor Documentation

Material::Material const MS3DMaterial *    material
 

Initialize the Material using data from the corresponding Milkshape material.


Member Data Documentation

unsigned int Material::m_bumpmapHandle [private]
 

The handle to the bumpmap (heightmap) texture.

Each RGB element in this texture represents the height of the corresponding texel in the detail texture.

The texture is generated with 50% luminance (divides all R, G and B components by two) because, when the bumpmap textures are combined with the detail texture, the blending equation multiplies everything by two.

unsigned int Material::m_invertedBumpmapHandle [private]
 

The handle to the inverted bumpmap (heightmap) texture.

Each RGB element in this texture represents the negative height of the corresponding texel in the bumpmap texture. The negative height is computed by subtracting the bumpmap height from 255.

The texture is generated with 50% luminance (divides all R, G and B components by two) because, when the bumpmap textures are combined with the detail texture, the blending equation multiplies everything by two.

unsigned int Material::m_normalmapHandle [private]
 

The handle to the normalmap texture.

Each RGB element in the normalmap texture corresponds to the perturbed normal vector extracted from a heightmap. The perturbed normal is computed by computing the cross product of two tangent vectors at each entry in the heightmap.

The tangent vectors are computed as:

        Vector s(1, 0, strength * (bumpmap(i + 1, j, 0) - bumpmap(i - 1, j, 0)));
        Vector t(0, 1, strength * (bumpmap(i, j + 1, 0) - bumpmap(i, j - 1, 0)));
        

where strength is a scaling factor (default 0.01).

The normal vector is the cross product of the two tangent vectors above, normalized (Vector#normalize), range compressed (Vector#rangeCompress) and scaled by 255 in order to fill a byte.


The documentation for this class was generated from the following files:
Generated on Sat Mar 22 15:12:07 2003 for Bumpmap by doxygen1.3-rc2