3ds Max C++ API Reference
VertexBufferHandle Class Reference

VertexBufferHandle is a memory buffer that contain vertex data. More...

#include <VertexBufferHandle.h>

+ Inheritance diagram for VertexBufferHandle:

Public Member Functions

GraphicsDriverAPI VertexBufferHandle ()
 
GraphicsDriverAPI VertexBufferHandle (const VertexBufferHandle &from)
 
GraphicsDriverAPI VertexBufferHandleoperator= (const VertexBufferHandle &from)
 
virtual GraphicsDriverAPI ~VertexBufferHandle ()
 
GraphicsDriverAPI bool Initialize (size_t stride, size_t numVertices, void *initialData=nullptr, BufferUsageType usage=BufferUsageStatic, AccessType access=ReadWriteAcess, BufferPoolType pool=BufferPoolTypeSystemBuffer, VertexFieldType dataType=VertexFieldTypeUnknown)
 Initialize a vertex buffer with initial data. More...
 
GraphicsDriverAPI void Clear ()
 Clear all vertices in the buffer and set the size of the buffer to zero. More...
 
GraphicsDriverAPI size_t GetVertexStride () const
 Get the size of each vertex of this buffer. More...
 
GraphicsDriverAPI size_t GetNumberOfVertices () const
 Get the real number of vertices in the buffer. More...
 
GraphicsDriverAPI void SetNumberOfVertices (size_t numberOfVertices)
 Sets the real number of vertices in the buffer. More...
 
GraphicsDriverAPI size_t GetCapacity () const
 Get the capacity of the buffer. More...
 
GraphicsDriverAPI unsigned char * Lock (size_t vertexIndex, size_t numberOfVertices, MaxSDK::Graphics::AccessType accessType=MaxSDK::Graphics::WriteAcess)
 This function is used for reading/writing data from/into the vertex buffer. More...
 
GraphicsDriverAPI void Unlock ()
 Unlock the buffer to update. More...
 
GraphicsDriverAPI BufferUsageType GetBufferUsageType () const
 Gets the buffer usage type. More...
 
GraphicsDriverAPI BufferPoolType GetBufferPoolType () const
 Gets the buffer pool type. More...
 
GraphicsDriverAPI AccessType GetBufferAccessType () const
 Gets the buffer access type. More...
 
GraphicsDriverAPI VertexBufferHandle Clone ()
 Clone the buffer. More...
 
GraphicsDriverAPI bool CopyFrom (SmartHandle &srcBuffer)
 Copy data from another vertex buffer Note the source buffer format must match this buffer. More...
 
GraphicsDriverAPI bool CopyFrom (SmartHandle &srcBuffer, size_t start, size_t numVertices, size_t destStart)
 Copy partial data from source buffer to specified location of this buffer Note both buffer should ensure they have enough space to copy the data. More...
 
GraphicsDriverAPI bool RealizeToSysMemory (bool keepHWBuffer=false)
 Copy data from hardware buffer to system buffer. More...
 
GraphicsDriverAPI bool RealizeToHWMemory (bool keepSysBuffer=false)
 Copy data from system buffer to hardware buffer. More...
 
- Public Member Functions inherited from SmartHandle
virtual GraphicsDriverAPI ~SmartHandle ()
 destructor More...
 
GraphicsDriverAPI bool IsValid () const
 Check if this handle is valid. More...
 
GraphicsDriverAPI void Release ()
 Release the underlying graphics objects. More...
 
GraphicsDriverAPI Identifier GetObjectID () const
 Get the underlying graphics object id. More...
 
GraphicsDriverAPI void SetPointer (IRefObject *pObject)
 
GraphicsDriverAPI IRefObjectGetPointer () const
 Get the underlying graphics object pointer. More...
 
bool operator== (const SmartHandle &rhs) const
 
bool operator!= (const SmartHandle &rhs) const
 
bool operator< (const SmartHandle &rhs) const
 
bool operator<= (const SmartHandle &rhs) const
 
bool operator> (const SmartHandle &rhs) const
 
bool operator>= (const SmartHandle &rhs) const
 
GraphicsDriverAPI SmartHandle (const SmartHandle &)
 
GraphicsDriverAPI SmartHandleoperator= (const SmartHandle &)
 

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 SmartHandle
GraphicsDriverAPI SmartHandle ()
 
- Protected Attributes inherited from SmartHandle
IRefObjectmpObject
 

Detailed Description

VertexBufferHandle is a memory buffer that contain vertex data.

Vertex buffers can contain any vertex type - transformed or untransformed, lit or unlit - that can be rendered through the use of the rendering methods.

Constructor & Destructor Documentation

◆ VertexBufferHandle() [1/2]

◆ VertexBufferHandle() [2/2]

◆ ~VertexBufferHandle()

virtual GraphicsDriverAPI ~VertexBufferHandle ( )
virtual

Member Function Documentation

◆ operator=()

◆ Initialize()

GraphicsDriverAPI bool Initialize ( size_t  stride,
size_t  numVertices,
void initialData = nullptr,
BufferUsageType  usage = BufferUsageStatic,
AccessType  access = ReadWriteAcess,
BufferPoolType  pool = BufferPoolTypeSystemBuffer,
VertexFieldType  dataType = VertexFieldTypeUnknown 
)

Initialize a vertex buffer with initial data.

Parameters
strideThe stride in bytes of each vertex of the newly created buffer.
numVerticesnumber of vertices in this buffer
initialDatainitial data, can be nullptr
usageusage of the buffer
accessaccess flag of the buffer
poolpool state of the buffer
dataTypeif this buffer is used as "buffer" shader type, then it must specify data type.
Returns
true if successfully initialized, false otherwise.

◆ Clear()

Clear all vertices in the buffer and set the size of the buffer to zero.

◆ GetVertexStride()

GraphicsDriverAPI size_t GetVertexStride ( ) const

Get the size of each vertex of this buffer.

Measured in bytes.

Returns
the size in bytes of each vertex.

◆ GetNumberOfVertices()

GraphicsDriverAPI size_t GetNumberOfVertices ( ) const

Get the real number of vertices in the buffer.

Returns
the number of vertices.

◆ SetNumberOfVertices()

GraphicsDriverAPI void SetNumberOfVertices ( size_t  numberOfVertices)

Sets the real number of vertices in the buffer.

Parameters
numberOfVerticesthe new number of vertices.

◆ GetCapacity()

GraphicsDriverAPI size_t GetCapacity ( ) const

Get the capacity of the buffer.

Returns
the capacity

◆ Lock()

GraphicsDriverAPI unsigned char* Lock ( size_t  vertexIndex,
size_t  numberOfVertices,
MaxSDK::Graphics::AccessType  accessType = MaxSDK::Graphics::WriteAcess 
)

This function is used for reading/writing data from/into the vertex buffer.

Remarks
if the input parameter is invalid (eg. vertexIndex + numberOfVertices is greater than the total number of vertices of the buffer), the function returns NULL.
Parameters
vertexIndexthe vertex index that the lock operation starts
numberOfVerticesthe number of vertices that this function will lock.
accessTypebehavior of the locking. Default is write access.
Returns
the buffer for developers to read/write vertex data. The size of the buffer is numberOfVertices * vertexStride.

◆ Unlock()

GraphicsDriverAPI void Unlock ( )

Unlock the buffer to update.

This function must be called after Lock. Once this function is called, the buffer that returned by Lock become invalid and should not be used any more.

◆ GetBufferUsageType()

GraphicsDriverAPI BufferUsageType GetBufferUsageType ( ) const

Gets the buffer usage type.

Returns
the usage type

◆ GetBufferPoolType()

GraphicsDriverAPI BufferPoolType GetBufferPoolType ( ) const

Gets the buffer pool type.

Returns
buffer pool type

◆ GetBufferAccessType()

GraphicsDriverAPI AccessType GetBufferAccessType ( ) const

Gets the buffer access type.

Returns
buffer access type

◆ Clone()

Clone the buffer.

Returns
the cloned buffer handle

◆ CopyFrom() [1/2]

GraphicsDriverAPI bool CopyFrom ( SmartHandle srcBuffer)

Copy data from another vertex buffer Note the source buffer format must match this buffer.

Parameters
srcBufferthe source buffer to copy to this buffer

◆ CopyFrom() [2/2]

GraphicsDriverAPI bool CopyFrom ( SmartHandle srcBuffer,
size_t  start,
size_t  numVertices,
size_t  destStart 
)

Copy partial data from source buffer to specified location of this buffer Note both buffer should ensure they have enough space to copy the data.

Parameters
srcBufferthe source buffer
startoffset of the source buffer
numVerticesnumber of vertices to copy
destStartstart offset of this buffer

◆ RealizeToSysMemory()

GraphicsDriverAPI bool RealizeToSysMemory ( bool  keepHWBuffer = false)

Copy data from hardware buffer to system buffer.

Parameters
keepHWBuffertrue to reserve hardware memory, false to release the memory.
Returns
true if the data copy is success. Otherwise false.

◆ RealizeToHWMemory()

GraphicsDriverAPI bool RealizeToHWMemory ( bool  keepSysBuffer = false)

Copy data from system buffer to hardware buffer.

Parameters
keepSysBuffertrue to reserve system memory, false to release the memory.
Returns
true if the data copy is success. Otherwise false.