HLSLMaterialHandle Class Reference
 
 
 
HLSLMaterialHandle Class Reference

#include <HLSLMaterialHandle.h>

Inheritance diagram for HLSLMaterialHandle:
BaseMaterialHandle SmartHandle Noncopyable MaxHeapOperators

Class Description

HLSLMaterialHandle is a material class to support HLSL custom material.

This class is used for viewport display and Quicksilver. It's used by RenderItemHandle::SetCustomMaterial() to describe HLSL custom material. It can also be used for realistic material display. see IHLSLMaterialTranslator for more details. How to use:

HLSLMaterialHandle hMaterial;
hMaterial.Initialize(shaderFileName);
hMaterial.SetFloatParameter(_M("myFloatShaderParam"), floatValue);
pItem->SetCustomMaterial(hMaterial); // pItem is an instance of RenderItemHandle

Classes

struct   ParameterDesc
  This is parameter description of HLSLMaterialHandle parameter. More...

Public Types

enum   ParameterType {
  ParameterTypeUnknown, ParameterTypeFloat, ParameterTypeInt, ParameterTypeBool,
  ParameterTypePoint3, ParameterTypePoint4, ParameterTypeMatrix, ParameterTypeTexture,
  ParameterTypeFloatArray, ParameterTypeIntArray, ParameterTypeBoolArray, ParameterTypePoint3Array,
  ParameterTypePoint4Array, ParameterTypeMatrixArray
}
  This is parameter type of HLSLMaterialHandle parameter. More...

Public Member Functions

GraphicsDriverAPI  HLSLMaterialHandle ()
GraphicsDriverAPI  HLSLMaterialHandle (const HLSLMaterialHandle &from)
GraphicsDriverAPI
HLSLMaterialHandle
operator= (const HLSLMaterialHandle &from)
virtual GraphicsDriverAPI  ~HLSLMaterialHandle ()
GraphicsDriverAPI bool  InitializeWithFile (const MSTR &fileName)
  Initialize an instance of HLSLMaterialHandle.
GraphicsDriverAPI bool  InitializeWithString (const CStr &shaderContent)
  Initialize an instance of HLSLMaterialHandle with shader string.
virtual GraphicsDriverAPI
const MaterialRequiredStreams
GetRequiredStreams () const
  Returns the material required streams to tell how to setup mesh data.
GraphicsDriverAPI int  GetParameterCount () const
  Returns the parameter count of material.
GraphicsDriverAPI bool  GetParameterDescription (int index, ParameterDesc &parameterDesc) const
  Returns the description of parameter.
GraphicsDriverAPI int  GetParameterIndex (const MSTR &parameterName) const
  Returns the index of parameter.
GraphicsDriverAPI void  SetIntParameter (const MSTR &parameterName, int value)
  Sets int parameter.
GraphicsDriverAPI void  SetIntParameter (int index, int value)
  Sets int parameter.
GraphicsDriverAPI void  SetIntArrayParameter (const MSTR &parameterName, const int *value, unsigned int count)
  Sets int array parameter.
GraphicsDriverAPI void  SetIntArrayParameter (int index, const int *value, unsigned int count)
  Sets int array parameter.
GraphicsDriverAPI void  SetFloatParameter (const MSTR &parameterName, float value)
  Sets float parameter.
GraphicsDriverAPI void  SetFloatParameter (int index, float value)
  Sets float parameter.
GraphicsDriverAPI void  SetFloatArrayParameter (const MSTR &parameterName, const float *value, unsigned int count)
  Sets float array parameter.
GraphicsDriverAPI void  SetFloatArrayParameter (int index, const float *value, unsigned int count)
  Sets float array parameter.
GraphicsDriverAPI void  SetBoolParameter (const MSTR &parameterName, BOOL value)
  Sets bool parameter.
GraphicsDriverAPI void  SetBoolParameter (int index, BOOL value)
  Sets bool parameter.
GraphicsDriverAPI void  SetBoolArrayParameter (const MSTR &parameterName, const BOOL *value, unsigned int count)
  Sets bool array parameter.
GraphicsDriverAPI void  SetBoolArrayParameter (int index, const BOOL *value, unsigned int count)
  Sets bool array parameter.
GraphicsDriverAPI void  SetFloat4Parameter (const MSTR &parameterName, const Point4 &value)
  Sets float4 parameter.
GraphicsDriverAPI void  SetFloat4Parameter (int index, const Point4 &value)
  Sets float4 parameter.
GraphicsDriverAPI void  SetFloat4ArrayParameter (const MSTR &parameterName, const Point4 *value, unsigned int count)
  Sets float4 array parameter.
GraphicsDriverAPI void  SetFloat4ArrayParameter (int index, const Point4 *value, unsigned int count)
  Sets float4 array parameter.
GraphicsDriverAPI void  SetFloat3Parameter (const MSTR &parameterName, const Point3 &value)
  Sets float3 parameter.
GraphicsDriverAPI void  SetFloat3Parameter (int index, const Point3 &value)
  Sets float3 parameter.
GraphicsDriverAPI void  SetFloat3ArrayParameter (const MSTR &parameterName, const Point3 *value, unsigned int count)
  Sets float3 array parameter.
GraphicsDriverAPI void  SetFloat3ArrayParameter (int index, const Point3 *value, unsigned int count)
  Sets float3 array parameter.
GraphicsDriverAPI void  SetMatrixParameter (const MSTR &parameterName, const Matrix44 &value)
  Sets matrix parameter.
GraphicsDriverAPI void  SetMatrixParameter (int index, const Matrix44 &value)
  Sets matrix parameter.
GraphicsDriverAPI void  SetMatrixArrayParameter (const MSTR &parameterName, const Matrix44 *value, unsigned int count)
  Sets matrix array parameter.
GraphicsDriverAPI void  SetMatrixArrayParameter (int index, const Matrix44 *value, unsigned int count)
  Sets matrix array parameter.
GraphicsDriverAPI void  SetTextureParameter (const MSTR &parameterName, const TextureHandle &textureHandle)
  Sets texture parameter.
GraphicsDriverAPI void  SetTextureParameter (int index, const TextureHandle &textureHandle)
  Sets texture parameter.
GraphicsDriverAPI void  SetMapChannelParameter (int textureCoordinateIndex, int maxMapChannel)
  Sets map channel parameter.
GraphicsDriverAPI void  SetActiveTechniqueName (const MSTR &techniqueName)
  Sets technique name parameter.

Member Enumeration Documentation

This is parameter type of HLSLMaterialHandle parameter.

Enumerator:
ParameterTypeUnknown 

unknown parameter type

ParameterTypeFloat 

float type

ParameterTypeInt 

int type

ParameterTypeBool 

BOOL type.

ParameterTypePoint3 

Point3 type.

ParameterTypePoint4 

Point4 type.

ParameterTypeMatrix 

Matrix type.

ParameterTypeTexture 

texture type

ParameterTypeFloatArray 

float array type

ParameterTypeIntArray 

int array type

ParameterTypeBoolArray 

BOOL array type.

ParameterTypePoint3Array 

Point3 array type.

ParameterTypePoint4Array 

Point4 array type.

ParameterTypeMatrixArray 

Matrix array type.


Constructor & Destructor Documentation

GraphicsDriverAPI HLSLMaterialHandle ( )
GraphicsDriverAPI HLSLMaterialHandle ( const HLSLMaterialHandle from )
virtual GraphicsDriverAPI ~HLSLMaterialHandle ( ) [virtual]

Member Function Documentation

GraphicsDriverAPI HLSLMaterialHandle& operator= ( const HLSLMaterialHandle from )
GraphicsDriverAPI bool InitializeWithFile ( const MSTR fileName )

Initialize an instance of HLSLMaterialHandle.

A HLSLMaterialHandle should be initialized before it's used.

Parameters:
[in] fileName HLSL shader file name.
Returns:
true if successfully initialized, false otherwise.
GraphicsDriverAPI bool InitializeWithString ( const CStr shaderContent )

Initialize an instance of HLSLMaterialHandle with shader string.

A HLSLMaterialHandle should be initialized before it's used.

Parameters:
[in] shaderContent HLSL shader content.
Returns:
true if successfully initialized, false otherwise.
virtual GraphicsDriverAPI const MaterialRequiredStreams* GetRequiredStreams ( ) const [virtual]

Returns the material required streams to tell how to setup mesh data.

Returns:
the material required streams.

Reimplemented from BaseMaterialHandle.

GraphicsDriverAPI int GetParameterCount ( ) const

Returns the parameter count of material.

Returns:
the parameter count.
GraphicsDriverAPI bool GetParameterDescription ( int  index,
ParameterDesc parameterDesc 
) const

Returns the description of parameter.

Parameters:
[in] index The parameter index.
[out] parameterDesc The parameter description
Returns:
true if successful, otherwise false.
GraphicsDriverAPI int GetParameterIndex ( const MSTR parameterName ) const

Returns the index of parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
Returns:
valid index if successful, otherwise -1
GraphicsDriverAPI void SetIntParameter ( const MSTR parameterName,
int  value 
)

Sets int parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The int parameter value.
GraphicsDriverAPI void SetIntParameter ( int  index,
int  value 
)

Sets int parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The int parameter value.
GraphicsDriverAPI void SetIntArrayParameter ( const MSTR parameterName,
const int *  value,
unsigned int  count 
)

Sets int array parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The pointer of int array parameter value.
[in] count The count of int array.
GraphicsDriverAPI void SetIntArrayParameter ( int  index,
const int *  value,
unsigned int  count 
)

Sets int array parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The pointer of int array parameter value.
[in] count The count of int array.
GraphicsDriverAPI void SetFloatParameter ( const MSTR parameterName,
float  value 
)

Sets float parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetFloatParameter ( int  index,
float  value 
)

Sets float parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetFloatArrayParameter ( const MSTR parameterName,
const float *  value,
unsigned int  count 
)

Sets float array parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The pointer of float array parameter value.
[in] count The count of float array.
GraphicsDriverAPI void SetFloatArrayParameter ( int  index,
const float *  value,
unsigned int  count 
)

Sets float array parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The pointer of float array parameter value.
[in] count The count of float array.
GraphicsDriverAPI void SetBoolParameter ( const MSTR parameterName,
BOOL  value 
)

Sets bool parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetBoolParameter ( int  index,
BOOL  value 
)

Sets bool parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetBoolArrayParameter ( const MSTR parameterName,
const BOOL *  value,
unsigned int  count 
)

Sets bool array parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The pointer of bool array parameter value.
[in] count The count of bool array.
GraphicsDriverAPI void SetBoolArrayParameter ( int  index,
const BOOL *  value,
unsigned int  count 
)

Sets bool array parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The pointer of bool array parameter value.
[in] count The count of bool array.
GraphicsDriverAPI void SetFloat4Parameter ( const MSTR parameterName,
const Point4 value 
)

Sets float4 parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetFloat4Parameter ( int  index,
const Point4 value 
)

Sets float4 parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetFloat4ArrayParameter ( const MSTR parameterName,
const Point4 value,
unsigned int  count 
)

Sets float4 array parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The pointer of float4 array parameter value.
[in] count The count of float4 array.
GraphicsDriverAPI void SetFloat4ArrayParameter ( int  index,
const Point4 value,
unsigned int  count 
)

Sets float4 array parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The pointer of float4 array parameter value.
[in] count The count of float4 array.
GraphicsDriverAPI void SetFloat3Parameter ( const MSTR parameterName,
const Point3 value 
)

Sets float3 parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetFloat3Parameter ( int  index,
const Point3 value 
)

Sets float3 parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetFloat3ArrayParameter ( const MSTR parameterName,
const Point3 value,
unsigned int  count 
)

Sets float3 array parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The pointer of float3 array parameter value.
[in] count The count of float3 array.
GraphicsDriverAPI void SetFloat3ArrayParameter ( int  index,
const Point3 value,
unsigned int  count 
)

Sets float3 array parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The pointer of float3 array parameter value.
[in] count The count of float3 array.
GraphicsDriverAPI void SetMatrixParameter ( const MSTR parameterName,
const Matrix44 value 
)

Sets matrix parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetMatrixParameter ( int  index,
const Matrix44 value 
)

Sets matrix parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The parameter value.
GraphicsDriverAPI void SetMatrixArrayParameter ( const MSTR parameterName,
const Matrix44 value,
unsigned int  count 
)

Sets matrix array parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The pointer of matrix array parameter value.
[in] count The count of matrix array.
GraphicsDriverAPI void SetMatrixArrayParameter ( int  index,
const Matrix44 value,
unsigned int  count 
)

Sets matrix array parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The pointer of matrix array parameter value.
[in] count The count of matrix array.
GraphicsDriverAPI void SetTextureParameter ( const MSTR parameterName,
const TextureHandle textureHandle 
)

Sets texture parameter.

Parameters:
[in] parameterName The unique parameter name of the parameter.
[in] value The parameter texture handle value.
GraphicsDriverAPI void SetTextureParameter ( int  index,
const TextureHandle textureHandle 
)

Sets texture parameter.

Parameters:
[in] index The parameter index of the parameter.
[in] value The parameter texture handle value.
GraphicsDriverAPI void SetMapChannelParameter ( int  textureCoordinateIndex,
int  maxMapChannel 
)

Sets map channel parameter.

Parameters:
[in] textureCoordinateIndex The texture coordinate index of shader.
[in] maxMapChannel Map channel value of 3ds max.
GraphicsDriverAPI void SetActiveTechniqueName ( const MSTR techniqueName )

Sets technique name parameter.

Parameters:
[in] techniqueName The active technique name.