overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Member Functions | Static Public Attributes
gameplay::MaterialParameter Class Reference

#include <MaterialParameter.h>

Inheritance diagram for gameplay::MaterialParameter:
gameplay::AnimationTarget gameplay::Ref

List of all members.

Classes

class  MethodArrayBinding
class  MethodBinding
class  MethodValueBinding

Public Member Functions

const char * getName () const
Texture::SamplergetSampler (unsigned int index=0) const
void setValue (float value)
void setValue (int value)
void setValue (const float *values, unsigned int count=1)
void setValue (const int *values, unsigned int count=1)
void setValue (const Vector2 &value)
void setValue (const Vector2 *values, unsigned int count=1)
void setValue (const Vector3 &value)
void setValue (const Vector3 *values, unsigned int count=1)
void setValue (const Vector4 &value)
void setValue (const Vector4 *values, unsigned int count=1)
void setValue (const Matrix &value)
void setValue (const Matrix *values, unsigned int count=1)
void setValue (const Texture::Sampler *sampler)
void setValue (const Texture::Sampler **samplers, unsigned int count)
Texture::SamplersetValue (const char *texturePath, bool generateMipmaps)
void setFloat (float value)
void setFloatArray (const float *values, unsigned int count, bool copy=false)
void setInt (int value)
void setIntArray (const int *values, unsigned int count, bool copy=false)
void setVector2 (const Vector2 &value)
void setVector2Array (const Vector2 *values, unsigned int count, bool copy=false)
void setVector3 (const Vector3 &value)
void setVector3Array (const Vector3 *values, unsigned int count, bool copy=false)
void setVector4 (const Vector4 &value)
void setVector4Array (const Vector4 *values, unsigned int count, bool copy=false)
void setMatrix (const Matrix &value)
void setMatrixArray (const Matrix *values, unsigned int count, bool copy=false)
Texture::SamplersetSampler (const char *texturePath, bool generateMipmaps)
void setSampler (const Texture::Sampler *value)
void setSamplerArray (const Texture::Sampler **values, unsigned int count, bool copy=false)
template<class ClassType , class ParameterType >
void bindValue (ClassType *classInstance, ParameterType(ClassType::*valueMethod)() const)
template<class ClassType , class ParameterType >
void bindValue (ClassType *classInstance, ParameterType(ClassType::*valueMethod)() const, unsigned int(ClassType::*countMethod)() const)
void bindValue (Node *node, const char *binding)
unsigned int getAnimationPropertyComponentCount (int propertyId) const
void getAnimationPropertyValue (int propertyId, AnimationValue *value)
void setAnimationPropertyValue (int propertyId, AnimationValue *value, float blendWeight=1.0f)

Static Public Attributes

static const int ANIMATE_UNIFORM = 1

Detailed Description

Defines a material parameter.

This class represents a parameter that can be set for a material. The methods in this class provide a mechanism to set parameters of all supported types. Some types support setting by value, while others only support setting by reference/pointer.

Setting a parameter by reference/pointer provides the ability to pass an array of values as well as a convenient way to support auto-binding of values to a material parameter. For example, by setting the parameter value to a pointer to a Matrix, any changes to the Matrix will automatically be reflected in the technique the next time the parameter is applied to the render state.

Note that for parameter values to arrays or pointers, the MaterialParameter will keep a long-lived reference to the passed in array/pointer. Therefore, you must ensure that the pointers you pass in are valid for the lifetime of the MaterialParameter object.


Member Function Documentation

template<class ClassType , class ParameterType >
void gameplay::MaterialParameter::bindValue ( ClassType *  classInstance,
ParameterType(ClassType::*)() const  valueMethod 
)

Binds the return value of a class method to this material parameter.

This method enables binding of arbitrary class methods to a material parameter. This is useful when you want to set a material parameter to a variable that is frequently changing (such as a world matrix).

By binding a method pointer, the method will be called automatically to retrieve the updated parameter value each time the material is bound for rendering.

Parameters:
classInstanceThe instance of the class containing the member method to bind.
valueMethodA pointer to the class method to bind (in the format '&class::method').
template<class ClassType , class ParameterType >
void gameplay::MaterialParameter::bindValue ( ClassType *  classInstance,
ParameterType(ClassType::*)() const  valueMethod,
unsigned int(ClassType::*)() const  countMethod 
)

Binds the return value of a class method to this material parameter.

This overloads the setBinding method to provide support for array parameters. The valueMethod parameter should return an array (pointer) of a supported material parameter type, such as Matrix* for an array of matrices. The countMethod should point to a method that returns the number of entries in the value returned from valueMethod.

Parameters:
classInstanceThe instance of the class containing the member method to bind.
valueMethodA pointer to the class method to bind (in the format '&class::method').
countMethodA pointer to a method that returns the number of entries in the array returned by valueMethod.
void gameplay::MaterialParameter::bindValue ( Node node,
const char *  binding 
)

Binds the return value of the supported class method for the given node to this material parameter.

Note: intended for use from Lua scripts.

Parameters:
nodeThe node containing the the member method to bind.
bindingThe name of the class method to bind (in the format '&class::method'). Note: this name must be one of the following supported methods:
  • "&Node::getBackVector"
  • "&Node::getDownVector"
  • "&Node::getTranslationWorld"
  • "&Node::getTranslationView"
  • "&Node::getForwardVector"
  • "&Node::getForwardVectorWorld"
  • "&Node::getForwardVectorView"
  • "&Node::getLeftVector"
  • "&Node::getRightVector"
  • "&Node::getRightVectorWorld"
  • "&Node::getUpVector"
  • "&Node::getUpVectorWorld"
  • "&Node::getActiveCameraTranslationWorld"
  • "&Node::getActiveCameraTranslationView"
  • "&Node::getScaleX"
  • "&Node::getScaleY"
  • "&Node::getScaleZ"
  • "&Node::getTranslationX"
  • "&Node::getTranslationY"
  • "&Node::getTranslationZ"
unsigned int gameplay::MaterialParameter::getAnimationPropertyComponentCount ( int  propertyId) const [virtual]
void gameplay::MaterialParameter::getAnimationPropertyValue ( int  propertyId,
AnimationValue value 
) [virtual]
See also:
AnimationTarget::getAnimationProperty

Implements gameplay::AnimationTarget.

const char* gameplay::MaterialParameter::getName ( ) const

Returns the name of this material parameter.

Texture::Sampler* gameplay::MaterialParameter::getSampler ( unsigned int  index = 0) const

Returns the texture sampler or NULL if this MaterialParameter is not a sampler type.

Parameters:
indexIndex of the sampler (if the parameter is a sampler array), or zero if it is a single sampler value.
Returns:
The texture sampler or NULL if this MaterialParameter is not a sampler type.
void gameplay::MaterialParameter::setAnimationPropertyValue ( int  propertyId,
AnimationValue value,
float  blendWeight = 1.0f 
) [virtual]
See also:
AnimationTarget::setAnimationProperty

Implements gameplay::AnimationTarget.

Stores a float value in this parameter.

Parameters:
valueThe value to set.
void gameplay::MaterialParameter::setFloatArray ( const float *  values,
unsigned int  count,
bool  copy = false 
)

Stores an array of float values in this parameter.

Parameters:
valuesThe array of values.
countThe number of values in the array.
copyTrue to make a copy of the array in the material parameter, or false to point to the passed in array/pointer (which must be valid for the lifetime of the MaterialParameter).

Stores an integer value in this parameter.

Parameters:
valueThe value to set.
void gameplay::MaterialParameter::setIntArray ( const int *  values,
unsigned int  count,
bool  copy = false 
)

Stores an array of integer values in this parameter.

Stores a Matrix value in this parameter.

Parameters:
valueThe value to set.
void gameplay::MaterialParameter::setMatrixArray ( const Matrix values,
unsigned int  count,
bool  copy = false 
)

Stores an array of Matrix values in this parameter.

Parameters:
valuesThe array of values.
countThe number of values in the array.
copyTrue to make a copy of the array in the material parameter, or false to point to the passed in array/pointer (which must be valid for the lifetime of the MaterialParameter).
Texture::Sampler* gameplay::MaterialParameter::setSampler ( const char *  texturePath,
bool  generateMipmaps 
)

Loads a texture sampler from the specified path and sets it as the value of this parameter.

Parameters:
texturePathThe path to the texture to set.
generateMipmapsTrue to generate a full mipmap chain for the texture, false otherwise.
Returns:
The texture sampler that was set for this material parameter.

Stores a Sampler value in this parameter.

Parameters:
valueThe value to set.
void gameplay::MaterialParameter::setSamplerArray ( const Texture::Sampler **  values,
unsigned int  count,
bool  copy = false 
)

Stores an array of Sampler values in this parameter.

Parameters:
valuesThe array of values.
countThe number of values in the array.
copyTrue to make a copy of the array in the material parameter, or false to point to the passed in array/pointer (which must be valid for the lifetime of the MaterialParameter).

Sets the value of this parameter to a float value.

Sets the value of this parameter to an integer value.

void gameplay::MaterialParameter::setValue ( const float *  values,
unsigned int  count = 1 
)

Stores a pointer/array of float values in this parameter.

void gameplay::MaterialParameter::setValue ( const int *  values,
unsigned int  count = 1 
)

Stores a pointer/array of integer values in this parameter.

Stores a copy of the specified Vector2 value in this parameter.

void gameplay::MaterialParameter::setValue ( const Vector2 values,
unsigned int  count = 1 
)

Stores a pointer/array of Vector2 values in this parameter.

Stores a copy of the specified Vector3 value in this parameter.

void gameplay::MaterialParameter::setValue ( const Vector3 values,
unsigned int  count = 1 
)

Stores a pointer/array of Vector3 values in this parameter.

Stores a copy of the specified Vector4 value in this parameter.

void gameplay::MaterialParameter::setValue ( const Vector4 values,
unsigned int  count = 1 
)

Stores a pointer/array of Vector4 values in this parameter.

Stores a copy of the specified Matrix value in this parameter.

void gameplay::MaterialParameter::setValue ( const Matrix values,
unsigned int  count = 1 
)

Stores a pointer/array of Matrix values in this parameter.

Sets the value of this parameter to the specified texture sampler.

void gameplay::MaterialParameter::setValue ( const Texture::Sampler **  samplers,
unsigned int  count 
)

Sets the value of this parameter to the specified texture sampler array.

Texture::Sampler* gameplay::MaterialParameter::setValue ( const char *  texturePath,
bool  generateMipmaps 
)

Loads a texture sampler from the specified path and sets it as the value of this parameter.

Parameters:
texturePathThe path to the texture to set.
generateMipmapsTrue to generate a full mipmap chain for the texture, false otherwise.
Returns:
The texture sampler that was set for this material parameter.

Stores a Vector2 value in this parameter.

Parameters:
valueThe value to set.
void gameplay::MaterialParameter::setVector2Array ( const Vector2 values,
unsigned int  count,
bool  copy = false 
)

Stores an array of Vector2 values in this parameter.

Parameters:
valuesThe array of values.
countThe number of values in the array.
copyTrue to make a copy of the array in the material parameter, or false to point to the passed in array/pointer (which must be valid for the lifetime of the MaterialParameter).

Stores a Vector3 value in this parameter.

Parameters:
valueThe value to set.
void gameplay::MaterialParameter::setVector3Array ( const Vector3 values,
unsigned int  count,
bool  copy = false 
)

Stores an array of Vector3 values in this parameter.

Stores a Vector4 value in this parameter.

Parameters:
valueThe value to set.
void gameplay::MaterialParameter::setVector4Array ( const Vector4 values,
unsigned int  count,
bool  copy = false 
)

Stores an array of Vector4 values in this parameter.

Parameters:
valuesThe array of values.
countThe number of values in the array.
copyTrue to make a copy of the array in the material parameter, or false to point to the passed in array/pointer (which must be valid for the lifetime of the MaterialParameter).

Member Data Documentation

Animates the uniform.

 All Classes Functions Variables Typedefs Enumerations Enumerator