vtlib library
Public Member Functions | List of all members
vtMaterialArray Class Reference

Inherits vector< vtMaterialPtr >, and Referenced.

Public Member Functions

int Find (vtMaterial *mat)
 
int AddTextureMaterial (osg::Image *pImage, bool bCulling, bool bLighting, bool bTransp=false, bool bAdditive=false, float fAmbient=0.0f, float fDiffuse=1.0f, float fAlpha=1.0f, float fEmissive=0.0f, bool bCompression=false)
 
int AddRGBMaterial (const RGBf &diffuse, bool bCulling=true, bool bLighting=true, bool bWireframe=false, float fAlpha=1.0f, float fEmissive=0.0f)
 
int FindByDiffuse (const RGBAf &rgba) const
 
int FindByImage (const osg::Image *image) const
 
void CopyFrom (vtMaterialArray *pFromMats)
 
int AppendMaterial (vtMaterial *pMat)
 Adds a material to this material array. More...
 

Detailed Description

Contains an array of materials. Provides useful methods for creating material easily.

Member Function Documentation

int vtMaterialArray::AddRGBMaterial ( const RGBf diffuse,
bool  bCulling = true,
bool  bLighting = true,
bool  bWireframe = false,
float  fAlpha = 1.0f,
float  fEmissive = 0.0f 
)

Create and add a simple colored material. This method takes diffuse color and let you control several other aspects of the material. Ambient color will be assumed to a be a dimmer shade of the supplied diffuse color (diffuse / 4).

Parameters
diffuseThe Diffuse color component of the material.
bCullingtrue to cull backfaces (only the front side of each polygon is rendered.)
bLightingtrue to "light" the material. This means it will use the material's color values, and any active lights to determine the color of the drawn geometry. If false, then only the material's diffuse color is used, and it is not affected by any lights.
bWireframeTrue for a material which will render only the edges of polygons.
fAlphaAlpha value (opacity), ranges from 0 (completely transparent) to 1 (opaque). Default is 1. If transparency is not enabled, this value is ignored.
fEmissiveEmmisive material value, ranges from 0 to 1 (default 0). If lighting is enabled, this value is added to the combined effect of each existing light. This is useful for geometry which is brighter than the existing light level, such as illuminated objects at night.
Returns
The index of the added material.
int vtMaterialArray::AddTextureMaterial ( osg::Image *  pImage,
bool  bCulling,
bool  bLighting,
bool  bTransp = false,
bool  bAdditive = false,
float  fAmbient = 0.0f,
float  fDiffuse = 1.0f,
float  fAlpha = 1.0f,
float  fEmissive = 0.0f,
bool  bCompression = false 
)

Create and add a simple textured material. This method takes a osg::Image and let you control many other aspects of the material. Only the first three parameters are required, the rest will be assumed with default values if desired.

Parameters
pImageA valid image (bitmap) which you have created.
bCullingtrue to cull backfaces (only the front side of each polygon is rendered.)
bLightingtrue to "light" the material. This means it will use the material's color values, and any active lights to determine the color of the drawn geometry. If false, then only the material's diffuse color is used, and it is not affected by any lights.
bTransptrue for a material with some transparency (default is false).
bAdditivetrue for an additive material (default is false). This means that the rendered color will be added to, rather than replace, the rendering surface. This is useful for some effects such as drawing stars against a twilight sky, in which the light of a dim star should be added to the background sky.
fAmbientAmbient material value, ranges from 0 to 1 (default 0). If lighting is enabled, this determines how this material is affected by the Ambient component of each existing light.
fDiffuseDiffuse material value, ranges from 0 to 1 (default 1). If lighting is enabled, this determines how this material is affected by the Diffuse component of each existing light. If lighting is not enabled, this indicates the exact lighting value to use for the material.
fAlphaAlpha value (opacity), ranges from 0 (completely transparent) to 1 (opaque). Default is 1. If transparency is not enabled, this value is ignored.
fEmissiveEmmisive material value, ranges from 0 to 1 (default 0). If lighting is enabled, this value is added to the combined effect of each existing light. This is useful for geometry which is brighter than the existing light level, such as illuminated objects at night.
bCompressionFor textured materials, requests texture compression.
Returns
The index of the added material.
int vtMaterialArray::AppendMaterial ( vtMaterial pMat)

Adds a material to this material array.

Returns
The index of the material that was added.
void vtMaterialArray::CopyFrom ( vtMaterialArray pFrom)

Copies all the materials from one vtMaterialArray to another.

The materials copied from the source are simply appending to this array.

int vtMaterialArray::Find ( vtMaterial mat)

Find a material in this array, by pointer

int vtMaterialArray::FindByDiffuse ( const RGBAf rgba) const

Find a material in an array by looking for a specific diffuse color.

Returns
The index of the material if found, otherwise -1.
int vtMaterialArray::FindByImage ( const osg::Image *  image) const

Find a material in an array by looking for a specific texture image.

Returns
The index of the material if found, otherwise -1.