|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:

List of all members.

## Classes

class | MethodArrayBinding
class | MethodBinding
class | MethodValueBinding

## Public Member Functions

const char * | getName () const
Texture::Sampler * | getSampler (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::Sampler * | setValue (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::Sampler * | setSampler (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:

  classInstance | The instance of the class containing the member method to bind.
  valueMethod | A 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:

  classInstance | The instance of the class containing the member method to bind.
  valueMethod | A pointer to the class method to bind (in the format '&class::method').
  countMethod | A 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:

  node | The node containing the the member method to bind.

  binding

  The 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]`

See also:
  AnimationTarget::getAnimationPropertyComponentCount

Implements gameplay::AnimationTarget.

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:

  index | Index 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.

void gameplay::MaterialParameter::setFloat | ( | float | value | ) |

Stores a float value in this parameter.

Parameters:

  value | The 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:

  values | The array of values.
  count | The number of values in the array.
  copy | True 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).

void gameplay::MaterialParameter::setInt | ( | int | value | ) |

Stores an integer value in this parameter.

Parameters:

  value | The 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.

void gameplay::MaterialParameter::setMatrix | ( | const Matrix & | value | ) |

Stores a Matrix value in this parameter.

Parameters:

  value | The 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:

  values | The array of values.
  count | The number of values in the array.
  copy | True 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:

  texturePath | The path to the texture to set.
  generateMipmaps | True to generate a full mipmap chain for the texture, false otherwise.

Returns:
  The texture sampler that was set for this material parameter.

void gameplay::MaterialParameter::setSampler | ( | const Texture::Sampler * | value | ) |

Stores a Sampler value in this parameter.

Parameters:

  value | The 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:

  values | The array of values.
  count | The number of values in the array.
  copy | True 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).

void gameplay::MaterialParameter::setValue | ( | float | value | ) |

Sets the value of this parameter to a float value.

void gameplay::MaterialParameter::setValue | ( | int | 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.

void gameplay::MaterialParameter::setValue | ( | const Vector2 & | value | ) |

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.

void gameplay::MaterialParameter::setValue | ( | const Vector3 & | value | ) |

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.

void gameplay::MaterialParameter::setValue | ( | const Vector4 & | value | ) |

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.

void gameplay::MaterialParameter::setValue | ( | const Matrix & | value | ) |

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.

void gameplay::MaterialParameter::setValue | ( | const Texture::Sampler * | sampler | ) |

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:

  texturePath | The path to the texture to set.
  generateMipmaps | True to generate a full mipmap chain for the texture, false otherwise.

Returns:
  The texture sampler that was set for this material parameter.

void gameplay::MaterialParameter::setVector2 | ( | const Vector2 & | value | ) |

Stores a Vector2 value in this parameter.

Parameters:

  value | The 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:

  values | The array of values.
  count | The number of values in the array.
  copy | True 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).

void gameplay::MaterialParameter::setVector3 | ( | const Vector3 & | value | ) |

Stores a Vector3 value in this parameter.

Parameters:

  value | The 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.

void gameplay::MaterialParameter::setVector4 | ( | const Vector4 & | value | ) |

Stores a Vector4 value in this parameter.

Parameters:

  value | The 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:

  values | The array of values.
  count | The number of values in the array.
  copy | True 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

const int gameplay::MaterialParameter::ANIMATE_UNIFORM = 1`[static]`

Animates the uniform.

float* gameplay::MaterialParameter::floatPtrValue

float gameplay::MaterialParameter::floatValue

int* gameplay::MaterialParameter::intPtrValue

int gameplay::MaterialParameter::intValue

MethodBinding* gameplay::MaterialParameter::method

const Texture::Sampler** gameplay::MaterialParameter::samplerArrayValue

const Texture::Sampler* gameplay::MaterialParameter::samplerValue

All Classes Functions Variables Typedefs Enumerations Enumerator