3ds Max C++ API Reference
MaterialRequiredStreams Class Reference

This class is used for describing the mesh stream requirements of a material. More...

#include <MaterialRequiredStreams.h>

+ Inheritance diagram for MaterialRequiredStreams:

Public Member Functions

DataBridgeAPI MaterialRequiredStreams ()
 
DataBridgeAPI MaterialRequiredStreams (const MaterialRequiredStreams &from)
 
DataBridgeAPI MaterialRequiredStreamsoperator= (const MaterialRequiredStreams &from)
 
DataBridgeAPI ~MaterialRequiredStreams ()
 
DataBridgeAPI void Clear ()
 Remove all streams from this requirement. More...
 
DataBridgeAPI size_t AddStream (const MaterialRequiredStreamElement &streamElement)
 Add a stream to this requirement. More...
 
DataBridgeAPI size_t FindStream (const MaterialRequiredStreamElement &streamElement) const
 Find the index of a stream element. More...
 
DataBridgeAPI void RemoveStream (size_t index)
 Remove the stream element specified by the given index from this requirement. More...
 
DataBridgeAPI size_t GetNumberOfStreams () const
 Get the number of streams of the requirement. More...
 
DataBridgeAPI const MaterialRequiredStreamElementGetStreamElement (size_t i) const
 Get the field of the i-th stream. More...
 
DataBridgeAPI int Compare (const MaterialRequiredStreams &rhs) const
 Compare two MaterialRequiredStreams. More...
 
DataBridgeAPI unsigned long GetFlags () const
 Get extra flags of this requirement. More...
 
DataBridgeAPI void SetFlags (unsigned long flags)
 Set extra flags of this requirement. More...
 
DataBridgeAPI void Swap (MaterialRequiredStreams &from)
 Swap another MaterialRequiredStreams with this one. More...
 
DataBridgeAPI void SetMaxMaterialID (MtlID value)
 Set the max material ID of a multi-sub material. More...
 
DataBridgeAPI MtlID GetMaxMaterialID () const
 Get the max material ID of a multi-sub material. More...
 
bool operator== (const MaterialRequiredStreams &rhs) const
 
bool operator!= (const MaterialRequiredStreams &rhs) const
 
bool operator< (const MaterialRequiredStreams &rhs) const
 
bool operator<= (const MaterialRequiredStreams &rhs) const
 
bool operator> (const MaterialRequiredStreams &rhs) const
 
bool operator>= (const MaterialRequiredStreams &rhs) const
 

Protected Attributes

MaterialRequiredStreamsImpl * mpImpl
 

Friends

class VirtualDeviceImp
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

This class is used for describing the mesh stream requirements of a material.

By default, 3ds Max automatically generates MaterialRequiredStreams for all materials. However if a material plugin wants to provide customized hardware shaders, it must
provide a MaterialRequiredStreams as well. Other plugins like the object plugin, will provide render items that suffice the requirement.

We create this class for two reasons:

First, a mesh contains a lot of channels however a material may be interested in a few channels of that mesh (eg. Position and the first texture coordinate channel). Converting a mesh channel to vertex buffer is a time and memory consuming job, therefore the material provide a MaterialRequiredStreams to indicate which channel is used by the material to minimize the number of vertex buffers we created.

Second, after we converted mesh channels to vertex buffers, it is necessary to indicate details like how is the vertex buffers are organized in hardware streams and the usage index of the channels. The usage index is used by hardware shaders of the material to differentiate the channels with the same type and usage. For example, if a material wants uv map channel 99 be treated as TEX0 in hardware shaders and uv map channel 32 may be treated as TEX1. Then the following code may be necessary:

// add position, normal and other streams.
...
MaterialRequiredStreamElement texCoord99;
texCoord99.SetType(EVertexType_Float3);
texCoord99.SetUsage(EVertexUsage_Texcoord);
texCoord99.SetChannelID(99); // set the max channel id
texCoord99.SetUsageIndex(0);
requirement.AddStream(texCoord99); // uv channel 99 is TEX0 in shaders
MaterialRequiredStreamElement texCoord32;
texCoord32.SetType(EVertexType_Float3);
texCoord32.SetUsage(EVertexUsage_Texcoord);
texCoord32.SetChannelID(32); // set the max channel id
texCoord99.SetUsageIndex(1);
requirement.AddStream(texCoord32); // uv channel 32 is TEX1 in shaders

Constructor & Destructor Documentation

◆ MaterialRequiredStreams() [1/2]

◆ MaterialRequiredStreams() [2/2]

◆ ~MaterialRequiredStreams()

Member Function Documentation

◆ operator=()

◆ Clear()

DataBridgeAPI void Clear ( )

Remove all streams from this requirement.

◆ AddStream()

DataBridgeAPI size_t AddStream ( const MaterialRequiredStreamElement streamElement)

Add a stream to this requirement.

Simply return existing stream index if the stream to be added is already in the array.

Parameters
streamElementthe stream element to add.
Returns
the newly added stream index, or the existing stream index.

◆ FindStream()

DataBridgeAPI size_t FindStream ( const MaterialRequiredStreamElement streamElement) const

Find the index of a stream element.

Parameters
streamElementthe element to find
Returns
the index to the found element, if not found, returns (size_t)-1

◆ RemoveStream()

DataBridgeAPI void RemoveStream ( size_t  index)

Remove the stream element specified by the given index from this requirement.

Parameters
indexthe index to the stream element.

◆ GetNumberOfStreams()

DataBridgeAPI size_t GetNumberOfStreams ( ) const

Get the number of streams of the requirement.

Returns
the number of streams.

◆ GetStreamElement()

DataBridgeAPI const MaterialRequiredStreamElement& GetStreamElement ( size_t  i) const

Get the field of the i-th stream.

Parameters
ithe index to the stream.
Returns
the field of the i-th stream.

◆ Compare()

DataBridgeAPI int Compare ( const MaterialRequiredStreams rhs) const

Compare two MaterialRequiredStreams.

Parameters
rhsthe "right-hand-side" MaterialRequiredStreams of the compare function.
Returns
1 if this object is greater than rhs, -1 if this object is less than rhs, zero otherwise.

◆ GetFlags()

DataBridgeAPI unsigned long GetFlags ( ) const

Get extra flags of this requirement.

The extra flag should be a combination of MaterialRequirementFlags.

Returns
the extra flags.

◆ SetFlags()

DataBridgeAPI void SetFlags ( unsigned long  flags)

Set extra flags of this requirement.

The extra flag should be a combination of MaterialRequirementFlags.

Parameters
flagsextra flags.

◆ Swap()

Swap another MaterialRequiredStreams with this one.

Parameters
fromanother MaterialRequiredStreams.

◆ SetMaxMaterialID()

DataBridgeAPI void SetMaxMaterialID ( MtlID  value)

Set the max material ID of a multi-sub material.

Parameters
valuethe max material ID of a multi-sub material.

◆ GetMaxMaterialID()

DataBridgeAPI MtlID GetMaxMaterialID ( ) const

Get the max material ID of a multi-sub material.

Returns
the max material ID of a multi-sub material. Default value is 0.

◆ operator==()

bool operator== ( const MaterialRequiredStreams rhs) const
inline
370 {
371  return Compare(rhs) == 0;
372 }
DataBridgeAPI int Compare(const MaterialRequiredStreams &rhs) const
Compare two MaterialRequiredStreams.

◆ operator!=()

bool operator!= ( const MaterialRequiredStreams rhs) const
inline
375 {
376  return Compare(rhs) != 0;
377 }

◆ operator<()

bool operator< ( const MaterialRequiredStreams rhs) const
inline
380 {
381  return Compare(rhs) < 0;
382 }

◆ operator<=()

bool operator<= ( const MaterialRequiredStreams rhs) const
inline
385 {
386  return Compare(rhs) <= 0;
387 }

◆ operator>()

bool operator> ( const MaterialRequiredStreams rhs) const
inline
390 {
391  return Compare(rhs) > 0;
392 }

◆ operator>=()

bool operator>= ( const MaterialRequiredStreams rhs) const
inline
395 {
396  return Compare(rhs) >= 0;
397 }

Friends And Related Function Documentation

◆ VirtualDeviceImp

friend class VirtualDeviceImp
friend

Member Data Documentation

◆ mpImpl

MaterialRequiredStreamsImpl* mpImpl
protected