3ds Max C++ API Reference
SplineRenderItem Class Reference

Base class for spline render items. More...

#include <SplineRenderItem.h>

+ Inheritance diagram for SplineRenderItem:

Public Member Functions

DefaultRenderItemAPI SplineRenderItem ()
 
virtual DefaultRenderItemAPI ~SplineRenderItem ()
 
DefaultRenderItemAPI DWORD CheckFlags (DWORD flag)
 Return value of the flag. More...
 
DefaultRenderItemAPI void ClearFlags (DWORD flag)
 Set the specified flag to 0. More...
 
DefaultRenderItemAPI void SetFlags (DWORD flag)
 Set the specified flag to 1. More...
 
virtual DefaultRenderItemAPI void Realize (DrawContext &drawContext)
 Default realize function. More...
 
virtual DefaultRenderItemAPI void Display (DrawContext &drawContext)
 Default display function This class is used for immediate consolidation. More...
 
virtual DefaultRenderItemAPI void HitTest (HitTestContext &hittestContext, DrawContext &drawContext)
 Hit Test function for this render item Since the splines are always rendered by consolidation item, in the render item's hit test function we need to build separate data to draw the item. More...
 
virtual DefaultRenderItemAPI size_t GetPrimitiveCount () const
 Get primitive count of this item. More...
 
DefaultRenderItemAPI bool HasLineData ()
 Return whether this item contains line data Empty item will be skipped when consolidation. More...
 
DefaultRenderItemAPI void AddLineList (MaxSDK::Array< Point3 > &positionArray, MaxSDK::Array< DWORD > &colorArray, MaxSDK::Array< int > &indexArray, bool isHitTestPrimitive)
 Add line data by array The position array and color array must has same length. More...
 
DefaultRenderItemAPI void AddLineStrip (const Point3 *positionArray, const Color *colorArray, size_t count, bool closed, bool isHitTestPrimitive)
 Add line strip data by raw pointers with custom vertex color. More...
 
DefaultRenderItemAPI void AddLineStrip (const Point3 *positionArray, const Color &color, size_t count, bool closed, bool isHitTestPrimitive)
 Add line strip data by raw pointers, with same color for all vertices. More...
 
DefaultRenderItemAPI void ClearLines ()
 Clear line data. More...
 
DefaultRenderItemAPI MaxSDK::Array< Point3 > & GetLinePositionArray ()
 Get position array. More...
 
DefaultRenderItemAPI MaxSDK::Array< DWORD > & GetLineColorArray ()
 Get color array. More...
 
DefaultRenderItemAPI MaxSDK::Array< int > & GetLineIndexArray ()
 Get line list index array. More...
 
- Public Member Functions inherited from ICustomRenderItem
virtual void OnHit (HitTestContext &, DrawContext &)
 This function will be called when the render item is hit. More...
 
- Public Member Functions inherited from ARefObject
GraphicsUtilityAPI ARefObject ()
 
virtual GraphicsUtilityAPI long AddRef ()
 from IRefObject, see comments in IRefObject More...
 
virtual GraphicsUtilityAPI long Release ()
 decrease reference count of this object by one, if the decreased reference count equals zero, the object will be deleted. More...
 
GraphicsUtilityAPI IRefObjectQueryInterface (Interface_ID classID)
 Try query an interface from the ref object using a given interface id. More...
 
- Public Member Functions inherited from IRefObject
GraphicsUtilityAPI IRefObject ()
 
virtual GraphicsUtilityAPI ~IRefObject ()
 
- Public Member Functions inherited from BaseInterfaceServer
virtual UtilExport BaseInterfaceGetInterface (Interface_ID id)
 
virtual UtilExport int NumInterfaces () const
 
virtual UtilExport BaseInterfaceGetInterfaceAt (int i) const
 
virtual UtilExport ~BaseInterfaceServer ()
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
template<class InterfaceType >
InterfaceType * GetTypedInterface ()
 

Protected Attributes

size_t mPrimitiveCount
 
MaxSDK::Array< Point3mLinePositionArray
 
MaxSDK::Array< DWORD > mLineColorArray
 
MaxSDK::Array< intmLineIndexArray
 
MaxSDK::Array< intmHitTestIndexArray
 
MaxSDK::Graphics::VertexBufferHandleArray mLineVB
 
MaxSDK::Graphics::IndexBufferHandle mLineIB
 
MaxSDK::Graphics::IndexBufferHandle mHitTestIB
 
DWORD mdwDirtyFlags
 
- Protected Attributes inherited from BaseInterfaceServer
Tab< BaseInterface * > interfaces
 

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...
 
- Protected Member Functions inherited from ARefObject
virtual GraphicsUtilityAPI void DeleteThis ()
 This function will be called when the reference count of an ARefObject equals zero. More...
 
virtual GraphicsUtilityAPI ~ARefObject ()
 
- Protected Member Functions inherited from Noncopyable
 Noncopyable ()
 
 ~Noncopyable ()
 

Detailed Description

Base class for spline render items.

This class is also an alternate solution for polyline functions in GraphicsWindow. Usually plugins needs to inherit this class and implement Realize() function to generate line data unless the plugin has static data that never changes after creation. This class is designed for simple line data that can be immediate consolidated. So it actually doesn't need to implement Display() fucntion because the display part is handled by SplineConsolidationItem. This item simply store data in system memory arrays, which has fast read performance.

If plugin's data is too complex and can't be generated in real time, we suggest the plugin to implements both Realize() and Display() functions. Then use a non-immediate consolidation strategy. So that the complex line item won't slow down other line items. A reference complexity of the line item is if it has more than 10K primitives, we suggest to disable immediate consolidation.

Constructor & Destructor Documentation

◆ SplineRenderItem()

◆ ~SplineRenderItem()

virtual DefaultRenderItemAPI ~SplineRenderItem ( )
virtual

Member Function Documentation

◆ CheckFlags()

DefaultRenderItemAPI DWORD CheckFlags ( DWORD  flag)

Return value of the flag.

Parameters
flagspecifies the flag to set

◆ ClearFlags()

DefaultRenderItemAPI void ClearFlags ( DWORD  flag)

Set the specified flag to 0.

Parameters
flagthe flag to clear

◆ SetFlags()

DefaultRenderItemAPI void SetFlags ( DWORD  flag)

Set the specified flag to 1.

Parameters
flagthe flag to set

◆ Realize()

virtual DefaultRenderItemAPI void Realize ( DrawContext drawContext)
virtual

Default realize function.

Plugins should implement Realize() function to handle object changes. In this function, plugins need to fill position, color and index buffers, and set mbIsDirty to true to notify consolidation item.

Parameters
drawContext

Implements ICustomRenderItem.

◆ Display()

virtual DefaultRenderItemAPI void Display ( DrawContext drawContext)
virtual

Default display function This class is used for immediate consolidation.

So it doesn't need display function.

Parameters
drawContext

Implements ICustomRenderItem.

◆ HitTest()

virtual DefaultRenderItemAPI void HitTest ( HitTestContext hittestContext,
DrawContext drawContext 
)
virtual

Hit Test function for this render item Since the splines are always rendered by consolidation item, in the render item's hit test function we need to build separate data to draw the item.

Parameters
hittestContextcontext which contains hit test related information
drawContextcontext which contains rendering related information

Reimplemented from ICustomRenderItem.

◆ GetPrimitiveCount()

virtual DefaultRenderItemAPI size_t GetPrimitiveCount ( ) const
virtual

Get primitive count of this item.

Returns
primitive count of this item

Implements ICustomRenderItem.

◆ HasLineData()

DefaultRenderItemAPI bool HasLineData ( )
inline

Return whether this item contains line data Empty item will be skipped when consolidation.

Returns
true if there's line data. Otherwise false.
176 {return mLineIndexArray.length() > 0;}
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array.
Definition: Array.inline.h:159
MaxSDK::Array< int > mLineIndexArray
Definition: SplineRenderItem.h:119

◆ AddLineList()

DefaultRenderItemAPI void AddLineList ( MaxSDK::Array< Point3 > &  positionArray,
MaxSDK::Array< DWORD > &  colorArray,
MaxSDK::Array< int > &  indexArray,
bool  isHitTestPrimitive 
)

Add line data by array The position array and color array must has same length.

The index array must contain zero-based line list data. This function automatically increase the index based on existing vertex counts.

Parameters
positionArrayarray contains line position data
colorArrayarray contains DWORD color data. Can be generated by Color.toRGB().
indexArrayarray contains zero-based line list data
isHitTestPrimitiveindicate whether these primitives are also used for hit test.

◆ AddLineStrip() [1/2]

DefaultRenderItemAPI void AddLineStrip ( const Point3 positionArray,
const Color colorArray,
size_t  count,
bool  closed,
bool  isHitTestPrimitive 
)

Add line strip data by raw pointers with custom vertex color.

Internally the function converts line strip to line list. And build index data for the strip.

Parameters
positionArraypointers of position data
colorArraypointers of color data. The function will automatically handle color shift in DX11 mode.
countnumber of positions to add.
closedindicate whether this line strip is closed. The function will build index for closed strip.
isHitTestPrimitiveindicate whether these primitives are also used for hit test.

◆ AddLineStrip() [2/2]

DefaultRenderItemAPI void AddLineStrip ( const Point3 positionArray,
const Color color,
size_t  count,
bool  closed,
bool  isHitTestPrimitive 
)

Add line strip data by raw pointers, with same color for all vertices.

Internally the function converts line strip to line list. And build index data for the strip.

Parameters
positionArraypointers of position data
colorreference of color data. The function will automatically handle color shift in DX11 mode.
countnumber of positions to add.
closedindicate whether this line strip is closed. The function will build index for closed strip.
isHitTestPrimitiveindicate whether these primitives are also used for hit test.

◆ ClearLines()

DefaultRenderItemAPI void ClearLines ( )

Clear line data.

◆ GetLinePositionArray()

DefaultRenderItemAPI MaxSDK::Array<Point3>& GetLinePositionArray ( )
inline

Get position array.

Returns
position array
230 {return mLinePositionArray;}
MaxSDK::Array< Point3 > mLinePositionArray
Definition: SplineRenderItem.h:117

◆ GetLineColorArray()

DefaultRenderItemAPI MaxSDK::Array<DWORD>& GetLineColorArray ( )
inline

Get color array.

Returns
color array
235 {return mLineColorArray;}
MaxSDK::Array< DWORD > mLineColorArray
Definition: SplineRenderItem.h:118

◆ GetLineIndexArray()

DefaultRenderItemAPI MaxSDK::Array<int>& GetLineIndexArray ( )
inline

Get line list index array.

Returns
line list index array
240 {return mLineIndexArray;}

Member Data Documentation

◆ mPrimitiveCount

size_t mPrimitiveCount
protected

◆ mLinePositionArray

MaxSDK::Array<Point3> mLinePositionArray
protected

◆ mLineColorArray

MaxSDK::Array<DWORD> mLineColorArray
protected

◆ mLineIndexArray

MaxSDK::Array<int> mLineIndexArray
protected

◆ mHitTestIndexArray

MaxSDK::Array<int> mHitTestIndexArray
protected

◆ mLineVB

◆ mLineIB

◆ mHitTestIB

◆ mdwDirtyFlags

DWORD mdwDirtyFlags
protected