class MVaryingParameter

Jump to documentation

Geometric data cache. (OpenMayaRender) (OpenMayaRender.py)

public members:

typedef enum {//Warning-makesureyoumodifytheinternalversionwhenchangingthis!///kInvalidParameter=-1,///kStructure=0,///kFloat}MVaryingParameterType
typedef enum {//Warning-makesureyoumodifytheinternalversionwhenchangingthis!///kNoSemantic=0,///kPosition,///kNormal,///kTexCoord,///kColor,///kWeight,///kTangent=kWeight+2,///kBinormal,}MVaryingParameterSemantic
MVaryingParameter ()
MVaryingParameter ( const MString & name , MVaryingParameterType type , int minElements = 1, int maxElements = 1, MVaryingParameterSemantic semantic = kNoSemantic, bool invertTexCoords = false)
~MVaryingParameter ()
const MVaryingParameter & operator= ( const MVaryingParameter & other)
const MString & name () const
MVaryingParameter::MVaryingParameterType type () const
MVaryingParameter::MVaryingParameterSemantic semantic () const
MStatus getBuffer ( MGeometry & geometry, const void*& data, unsigned int& elements, unsigned int& count) const
MVaryingParameter::MVaryingParameterSemantic getSourceType () const
MString getSourceSetName () const
MStatus setSource ( MVaryingParameter::MVaryingParameterSemantic type , const MString & setName)
unsigned int getElementSize () const
unsigned int getMaximumStride () const
MStatus addElement ( const MVaryingParameter & child)
unsigned int numElements () const
MVaryingParameter getElement ( unsigned int i) const
MStatus removeElements ()

Documentation

This class holds the set of data elements which represent a Maya surface
Description

The MVaryingParameter class provides a high-level interface to hardware shader varying parameters. By defining your shader's varying data through this class, you allow Maya to handle the attributes, editing, serialisation, requirements setup, and cache management for you in a standard way that ensure you'll be able to leverage future performance and functionlity improvements.

At setup time (either initial load or when the effect/technique is changed), your shader simply creates the list of parameters it requires, specifying the name, type, semantic of the parameters. At render time, you can then use the parameters to directly access the appropriate buffers for that surface data.

If you include a custom Attribute Editor template for your shader node, you can include these surface parameters by calling the AEhwShaderTemplateParameters script function. The following sample code provides a basic template you can modify - however your AE template can use as much or as little of this as you like:


global int $yourShaderNameTemplateInitialised = 0;

global proc AEyourShaderNameTemplate ( string $node )
{
	global int $yourShaderNameTemplateInitialised;
	if( $yourShaderNameTemplateInitialised == 0)
	{
		source "AEhwShaderTemplate.mel";
		$yourShaderNameTemplateInitialised = 1;
	}

	AEhwShaderTemplateHeader( $node);
	
	// Insert custom attributes between the swatch and the parameters here

	AEhwShaderTemplateParameters( $node);

	// Insert custom attributes after the parameters here 

	AEhwShaderTemplateFooter( $node);
}

Functions

MVaryingParameter:: MVaryingParameter ()

Description

Create an uninitialised (i.e. NULL) geometry parameter.

MVaryingParameter:: MVaryingParameter ( const MString & name , MVaryingParameterType type , int minElements, int maxElements, MVaryingParameterSemantic semantic , bool invertTexCoords)

Description

Create a new geometry parameter.

Arguments

  • name the name of the new parameter. For independently configurable inputs, this must be unique across all parameters on the shader. If multiple parameters share the same name, only a single input will be presented to the user, and the value used to populate the set of commonly named parameters.
  • type the type of the new parameter. This can either be an atomic type (e.g. float), or a structure containing other parameters. Vectors of atomic types (e.g. float4) are defined by setting the atomic type to kFloat, and specifying the maxElements value of 4.
  • minElements specifies the minimum number of elements of the specified atomic type that should be used to populate this parameter. Many hardware channels allow binding of a variable number of elements per value; for example you can bind a stream of float3s or float4s to a color register. In this case, you would specify a minElements value of 3, and a maxElements value of 4. This value is ignored for structures and elements inside structures (elements inside a structure are always maxElements size).
  • maxElements specifies the maximum number of elements of the specified atomic type that should be used to populate this parameter. See minElements for more information. This value is ignored for structures.
  • semantic specifies the expected usage of the paramter (e.g. we expect this to be a colour, or a tangent, etc). This gives Maya a hint as to how the input should be presented to the user, and possibly even which input data is valid for this parameter. This value is ignored for structures.

MVaryingParameter:: ~MVaryingParameter ()

Description

Class destructor.

const MVaryingParameter & MVaryingParameter:: operator= ( const MVaryingParameter & src)

Description

Assignment operator

const MString & MVaryingParameter:: name () const

Description

Get the name of this parameter

Arguments

  • None

Return Value

  • The name of this parameter

MVaryingParameter::MVaryingParameterType MVaryingParameter:: type () const

Description

Get the type of this parameter

Arguments

  • None

Return Value

  • The type of this parameter

MVaryingParameter::MVaryingParameterSemantic MVaryingParameter:: semantic () const

Description

Get the semantic of this parameter

Arguments

  • None

Return Value

  • The semantic of this parameter

MStatus MVaryingParameter:: addElement ( const MVaryingParameter & child)

Description

Add a child element to this parameter. This operation is only valid for parameters of type kStructure.

Arguments

  • child the parameter to add to the structure.

Return Value

  • MS::kFailure if an error occured (e.g. the parameter is not a structure)
  • MS::kSuccess otherwise.

unsigned int MVaryingParameter:: numElements () const

Description

Get the number of elements in this structure. This operation is only valid for parameters of type kStructure.

Arguments

Return Value

  • the number of elements in this structure.

MVaryingParameter MVaryingParameter:: getElement ( unsigned int i) const

Description

Get an element within a structure. This operation is only valid for parameters of type kStructure.

Arguments

  • the index of the structure element to return.

Return Value

  • the structure element. This will be a NULL element if an invalid index was specified.

MStatus MVaryingParameter:: removeElements ()

Description

Remove all child elements from a structure. This operation is only valid for parameters of type kStructure.

Arguments

Return Value

  • MS::kFailure if an error occured (e.g. the parameter is not a structure)
  • MS::kSuccess otherwise.

MStatus MVaryingParameter:: getBuffer ( MGeometry & geometry, const void*& data, unsigned int& elements, unsigned int& count) const

Description

Get the data for this parameter as a system memory buffer.

Arguments

  • geometry the geometry cache the data should be retrieved from. This corresponds to the shape (e.g. mesh) you want the data for.
  • data returns a pointer to the data (or NULL if the parameter is not available).
  • elements the number of elements specified for this parameter (e.g. is it 3 floats or 4 floats?)
  • count the number of values returned for this parameter (e.g. there are 426 normals)

Return Value

  • MS::kFailure if the parameter could not be retrieved.
  • MS::kSuccess otherwise.

MVaryingParameter::MVaryingParameterSemantic MVaryingParameter:: getSourceType () const

Description

Get the type of data (e.g. position, normal, uv) currently populating this parameter. This method will only return a useful value when called on leaf-level parameters (e.g. structures do not have sources, only the elements of a structure have sources).

Arguments

  • None

Return Value

  • The current data type populating of this parameter

MString MVaryingParameter:: getSourceSetName () const

Description

If the current data type supports data sets (e.g. uv sets, color sets), get the name of the data set populating this parameter. This method will only return a useful value when called on leaf-level parameters (e.g. structures do not have sources, only the elements of a structure have sources).

Arguments

  • None

Return Value

  • The current source set of this parameter

MStatus MVaryingParameter:: setSource ( MVaryingParameter::MVaryingParameterSemantic type , const MString & setName)

Description

While the source of geometry parameters is usually configured by the artist through Maya's user interface, this method allows you to programatically set the source of a geometry parameter, including both the data type (e.g. position, normal, etc) and an optional set name (e.g. UV set "map1"). This is useful for implementing custom default values or shader operations.

Arguments

  • type the type of data to populate this parameter with
  • setName the specific data set to use for parameter types which support data sets, such as UV and color.

Return Value

  • MS::kFailure if the source could not be set (e.g. the parameter is invalid).
  • MS::kSuccess otherwise.

unsigned int MVaryingParameter:: getElementSize () const

Description

Get the size in bytes of one element of this parameter.

Arguments

  • None

Return Value

  • The size in bytes of one element of this parameter.

unsigned int MVaryingParameter:: getMaximumStride () const

Description

Get the maximum stride of this parameter in bytes. For parameter that accept a range of element counts, this corresponds to the maximum number of elements the parameter supports.

Arguments

  • None

Return Value

  • The maximum stride of this parameter in bytes.

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright