OpenCMISS-Zinc C++ API Documentation
Public Types | Public Member Functions | Protected Attributes | List of all members
OpenCMISS::Zinc::Material Class Reference

Zinc materials specify colouring of graphics. More...

#include <material.hpp>

Public Types

enum  Attribute {
  ATTRIBUTE_INVALID = CMZN_MATERIAL_ATTRIBUTE_INVALID, ATTRIBUTE_ALPHA = CMZN_MATERIAL_ATTRIBUTE_ALPHA, ATTRIBUTE_AMBIENT = CMZN_MATERIAL_ATTRIBUTE_AMBIENT, ATTRIBUTE_DIFFUSE = CMZN_MATERIAL_ATTRIBUTE_DIFFUSE,
  ATTRIBUTE_EMISSION = CMZN_MATERIAL_ATTRIBUTE_EMISSION, ATTRIBUTE_SHININESS = CMZN_MATERIAL_ATTRIBUTE_SHININESS, ATTRIBUTE_SPECULAR = CMZN_MATERIAL_ATTRIBUTE_SPECULAR
}
 

Public Member Functions

 Material (cmzn_material_id material_id)
 
 Material (const Material &material)
 
Materialoperator= (const Material &material)
 
bool isValid () const
 
cmzn_material_id getId () const
 
bool isManaged ()
 
int setManaged (bool value)
 
double getAttributeReal (Attribute attribute)
 
int setAttributeReal (Attribute attribute, double value)
 
int getAttributeReal3 (Attribute attribute, double *valuesOut3)
 
int setAttributeReal3 (Attribute attribute, const double *valuesIn3)
 
char * getName ()
 
int setName (const char *name)
 
Field getTextureField (int textureNumber)
 
int setTextureField (int textureNumber, const Field &textureField)
 

Protected Attributes

cmzn_material_id id
 

Detailed Description

Zinc materials specify colouring of graphics.

Zinc materials specify colouring of graphics similarly to the original OpenGL shading model with diffuse, ambient, emission and specular colours, shininess and alpha/opacity. Image fields can be attached for texturing (and will be used by OpenGL shaders once enabled in a future release).

Member Enumeration Documentation

Labels of material attributes which may be set or obtained using generic get/set_attribute functions.

Enumerator
ATTRIBUTE_INVALID 

Unspecified material attribute.

ATTRIBUTE_ALPHA 

Opacity of the material. Transparent or translucent objects has lower alpha values then an opaque ones. Minimum acceptable value is 0 and maximum acceptable value is 1. Use attribute_real to get and set its values.

ATTRIBUTE_AMBIENT 

Ambient colour of the material. Ambient colour simulates the colour of the material when it does not receive direct illumination. Composed of RGB components. Use attribute_real3 to get and set its values. Minimum acceptable value is 0 and maximum acceptable value is 1.

ATTRIBUTE_DIFFUSE 

Diffuse colour of the material. Diffuse colour response to light that comes from one direction and this colour scattered equally in all directions once the light hits it. Composed of RGB components. Use attribute_real3 to get and set its values. Minimum acceptable value is 0 and maximum acceptable value is 1.

ATTRIBUTE_EMISSION 

Emissive colour of the material. Emissive colour simulates colours that is originating from the material itself. Composed of RGB components. Use attribute_real3 to get and set its values. Minimum acceptable value is 0 and maximum acceptable value is 1.

ATTRIBUTE_SHININESS 

Shininess determines the brightness of the highlight. Minimum acceptable value is 0 and maximum acceptable value is 1. Use attribute_real to get and set its values.

ATTRIBUTE_SPECULAR 

Specular colour of the material. Specular colour produces highlights. Unlike ambient and diffuse, specular colour depends on location of the viewpoint, it is brightest along the direct angle of reflection. Composed of RGB components. Use attribute_real3 to get and set its values. Minimum acceptable value is 0 and maximum acceptable value is 1.

Member Function Documentation

double OpenCMISS::Zinc::Material::getAttributeReal ( Attribute  attribute)
inline

Get a real value of an attribute of the material.

Parameters
attributeThe identifier of the real attribute to get.
Returns
Value of the attribute.
int OpenCMISS::Zinc::Material::getAttributeReal3 ( Attribute  attribute,
double *  valuesOut3 
)
inline

Get a 3 components vectors of an attribute of the material. <values> should be allocated with enough space for 3 components.

Parameters
attributeThe identifier of the vectors attribute to get.
Returns
Status OpenCMISS::Zinc::OK on success, any other value on failure.
cmzn_material_id OpenCMISS::Zinc::Material::getId ( ) const
inline

Return the C handle of the Material object.

Returns
C handle of Material if this objects is valid, 0 otherwise.
char* OpenCMISS::Zinc::Material::getName ( )
inline

Return an allocated string containing material name.

Returns
allocated string containing material name, otherwise NULL. Up to caller to free using cmzn_deallocate().
Field OpenCMISS::Zinc::Material::getTextureField ( int  textureNumber)
inline

Get field containing an image used for texturing the material.

Parameters
textureNumberThe number of the texture to get, from 1 to 4.
Returns
Handle to the field, or NULL/invalid handle if none or failed.
bool OpenCMISS::Zinc::Material::isManaged ( )
inline

Get managed status of material in its owning material module.

See also
Material::setManaged
Returns
true if material is managed, otherwise false.
bool OpenCMISS::Zinc::Material::isValid ( ) const
inline

Check if this is a valid Material object.

Returns
Status True if object is valid, false otherwise.
int OpenCMISS::Zinc::Material::setAttributeReal ( Attribute  attribute,
double  value 
)
inline

Set a real value for an attribute of the material.

Parameters
attributeThe identifier of the real attribute to set.
valueThe new value for the attribute.
Returns
Status OpenCMISS::Zinc::OK if attribute successfully set, any other value if failed or attribute not valid or unable to be set for this material object.
int OpenCMISS::Zinc::Material::setAttributeReal3 ( Attribute  attribute,
const double *  valuesIn3 
)
inline

Set a 3 components vectors of an attribute for the material. <values> should be a vectors with 3 components containg valid values.

Parameters
attributeThe identifier of the vectors attribute to get.
Returns
Status OpenCMISS::Zinc::OK if attribute successfully set, any other value if failed or attribute not valid or unable to be set for this material object.
int OpenCMISS::Zinc::Material::setManaged ( bool  value)
inline

Set managed status of material in its owning material module. If set (managed) the material will remain indefinitely in the material module even if no external references are held. If not set (unmanaged) the material will be automatically removed from the module when no longer referenced externally, effectively marking it as pending destruction. All new objects are unmanaged unless stated otherwise.

Parameters
valueThe new value for the managed flag: true or false.
Returns
Status OpenCMISS::Zinc::OK on success, otherwise OpenCMISS::Zinc::ERROR_ARGUMENT.
int OpenCMISS::Zinc::Material::setName ( const char *  name)
inline

Set/change name for <material>.

Parameters
namename to be set to the material
Returns
Status OpenCMISS::Zinc::OK if successfully set/change name for material, any other value on failure.
int OpenCMISS::Zinc::Material::setTextureField ( int  textureNumber,
const Field textureField 
)
inline

Set field containing an image used for texturing the material. Up to 4 textures can be used with a material.

Parameters
textureNumberThe number of the texture to set, from 1 to 4. Texture 1 is used for texture mapping with the legacy OpenGL shader model. Custom material shaders can use any of the textures explicitly.
textureFieldThe field supplying the texture image. Must be of type field_image.
Returns
Status OpenCMISS::Zinc::OK on success, otherwise OpenCMISS::Zinc::ERROR_ARGUMENT.

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