3ds Max C++ API Reference
IMeshFlattener Class Referenceabstract

Utility interface for creating a flattened representation of a mesh. More...

#include <IMeshFlattener.h>

+ Inheritance diagram for IMeshFlattener:

Classes

struct  TextureCoordChannel
 Contains the vertex UVW coordinates for a single texture coordinate channel. More...
 

Public Member Functions

virtual ~IMeshFlattener ()
 
virtual size_t GetNumSubMeshes ()=0
 Returns the number of sub-meshes that may be queried with GetSubMesh() More...
 
virtual void GetSubMesh (const size_t subMeshIndex, MtlID &materialId, std::vector< IPoint3 > &faceIndices, std::vector< Point3 > &vertices, std::vector< Point3 > &normals, std::vector< TextureCoordChannel > &textureCoordChannels)=0
 Returns the flattened representation of the sub-mesh with the given index. More...
 

Static Public Member Functions

static RenderingAPIExport std::unique_ptr< IMeshFlattenerAllocateInstance (INode &node, const View &render_view, const TimeValue t, Interval &validity)
 Allocates a new mesh flattener and performs the flattening process. More...
 
- 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

Utility interface for creating a flattened representation of a mesh.

3ds Max meshes (class Mesh) are represented in a way that is optimized for manipulation and modelling. Renderers typically need a flattened representation, with separate arrays for vertices, normals, uvs, etc. - all with a one-to-one relationship. This interface performs this flattening process, as well as correctly evaluating the mesh (with normals, uvs, etc.) for the purpose of rendering.

Constructor & Destructor Documentation

◆ ~IMeshFlattener()

virtual ~IMeshFlattener ( )
inlinevirtual
67 {}

Member Function Documentation

◆ AllocateInstance()

static RenderingAPIExport std::unique_ptr<IMeshFlattener> AllocateInstance ( INode node,
const View render_view,
const TimeValue  t,
Interval validity 
)
static

Allocates a new mesh flattener and performs the flattening process.

The mesh flattener, return by this method, should be treated as a temporary object. The mesh attributes should be extracted immediately, followed by immediate discarding of the flattener. This is because the mesh flattener maintains references to the node and mesh, which could become dangling if the flattener were kept around while other components were to evaluate the node.

Parameters
nodeThe (geometric) node from which to evaluate the mesh.
render_viewThe view to be passed to GeomObject::GetRenderMesh(). This view should implement View::CheckForRenderAbort() to always return false, because the mesh flattener has no provisions for correctly supporting an abort while evaluating a mesh.
tThe time at which to evaluate the mesh.
validity[in, out] The validity of the mesh is intersected into this interval.
Returns
A new instance of a mesh flattener.

◆ GetNumSubMeshes()

virtual size_t GetNumSubMeshes ( )
pure virtual

Returns the number of sub-meshes that may be queried with GetSubMesh()

◆ GetSubMesh()

virtual void GetSubMesh ( const size_t  subMeshIndex,
MtlID materialId,
std::vector< IPoint3 > &  faceIndices,
std::vector< Point3 > &  vertices,
std::vector< Point3 > &  normals,
std::vector< TextureCoordChannel > &  textureCoordChannels 
)
pure virtual

Returns the flattened representation of the sub-mesh with the given index.

The mesh flattener splits the mesh into multiple sub-meshes, according to material ID. Each material ID gets its own sub-mesh. This enables renderers, which may not support multiple materials per mesh, to easily support the multi-material feature by creating separate geometric instances for each material used by the object.

Parameters
subMeshIndexThe index of the sub-mesh to fetch.
[out]materialIdReturns the material ID associated with this sub-mesh.
[out]faceIndicesReturns the face definitions, with each face defined as a set of three indices into the vertices array.
[out]verticesReturns the set of vertices.
[out]normalsThe set of vertex normals, one for each vertex found in vertices.
[out]textureCoordChannelsThe set of texture coordinate channel found on the mesh, each defining the vertex UVWs of a single channel.