Class PolyObject

3DS Max Plug-In SDK

Class PolyObject

See Also: Class GeomObject., Class MNMesh

class PolyObject: public GeomObject

Description:

This class is available in release 4.0 and later only.

3ds max 4 introduces a new type of pipeline object, the polygon-based mesh object, or PolyObject for short. This object is based on the MNMesh which has been present in the SDK for some time and used for 3ds max effects like MeshSmooth, Boolean, and Connect.

PolyObjects are more restricted than TriObjects in that they only support "manifold topology". That is to say, you can't create "rat's nest" meshes out of polygon meshes. Each edge in a polygon mesh can be referenced only once on each "side", with a well defined "outside" and "inside" direction for every element of polygons. In TriObjects, you could create a mesh with 5 vertices and 3 faces: (0,1,2), (0,1,3), and (0,1,4). This would be illegal in PolyObjects because the edge (0,1) is referenced in the (0->1) direction by three different faces. (0,1,2), (1,0,3) would be a legal pair of faces, however, because the (0,1) edge is referenced only once in each direction. This implies also that the two faces have consistent normals - there's a well-defined inside and outside at the edge. It's impossible to have neighboring faces have inconsistent normals in a PolyObject, which is why the FlipNormals method in Editable Poly only works on entire elements.

PolyObjects have a complete edge list present virtually all the time. They also have full topological links - the edges reference the vertices and faces they use, the faces reference the vertices and edges, and the vertices also reference the edges and faces. This is somewhat wasteful of memory, but it makes it very easy to navigate the mesh and do complex algorithms like subdivision or Booleans. (Of course this also means there's more to keep track of in these operations.)

Mesh objects flowing up the pipeline should be freely convertible between TriObjects and PolyObjects. Virtually all data should be preserved in converting back and forth between these types. Exceptions include PolyObject edge data, such as crease values, which are lost upon conversion to TriObjects (since TriObjects have no edge lists).

Virtually all the public methods of PolyObject are based on the equivalent methods in TriObject. class PolyObject provides implementations of all the required methods of Animatable, ReferenceMaker, ReferenceTarget, Base Object, Object, and GeomObject. All methods of this class are implemented by the system.

 

Data Members:

public:

MNMesh mm;

See class MNMesh for information about manipulating the mesh.

The following global functions are not part of this class but are available for use:

Function:

ClassDesc* GetPolyObjDescriptor();

Remarks:

Gets the class descriptor for the PolyObject.

Function:

void RegisterEditPolyObjDesc(ClassDesc* desc);

Remarks:

Allows a plugin to register an Editable Poly object. (This is done by epoly.dlo in the standard 3ds max distribution.) This is the object which is collapsed to when the stack is collapsed. The default if no such object is registered is to simply collapse to a PolyObject (which has no UI parameters).

Parameters:

ClassDesc* desc

A pointer to the class descriptor.

Function:

ClassDesc* GetEditPolyObjDesc();

Remarks:

This method is available in release 4.0 and later only.

Gets the class descriptor for the currently registered Editable Poly object.

Function:

PolyObject *CreateEditablePolyObject();

Remarks:

This method is available in release 4.0 and later only.

Returns an Editable Poly object from the currently registered EPoly descriptor, cast as a PolyObject.

Methods:

public:

Prototype:

DWORD GetSubselState();

Remarks:

This method returns the selection levels defined for class MNMesh: MNM_SL_OBJECT (0), MNM_SL_VERTEX (1), MNM_SL_EDGE (2), and MNM_SL_FACE (3).

Prototype:

void SetSubSelState(DWORD s);

Remarks:

This method allows you to set the selection levels defined for class MNMesh: MNM_SL_OBJECT (0), MNM_SL_VERTEX (1), MNM_SL_EDGE (2), and MNM_SL_FACE (3).

Parameters:

DWORD s

The selection level to set.

Prototype:

BOOL CheckObjectIntegrity();

Remarks:

Uses the MNMesh::CheckAllData() method, which uses DebugPrint() to give details about any errors that it finds.

Prototype:

MNMesh& GetMesh();

Remarks:

Accessor for the MNMesh mm data member.

Displacement mapping subdivision methods in PolyObject

Displacement mapping in materials can be enhanced by a subdivision algorithm which subdivides as needed based on the map. This algorithm is implemented in class TriObject, but can be accessed by PolyObjects since they need to convert to TriObjects for rendering anyway. The following methods are used to access and set the displacement mapping parameters.

Prototype:

BOOL CanDoDisplacementMapping();

Remarks:

Implementation of a class GeomObject method which indicates whether or not this object supports displacement mapping. It returns true as long as GetDisplacementDisable() returns false.

Prototype:

void SetDisplacementApproxToPreset(int preset);

Remarks:

Sets displacement subdivision parameters to match one of the standard displacement approximation presets.

Parameters:

int preset

Should be 0 for low, 1 for medium, or 2 for high.

Prototype:

void SetDisplacementDisable (bool disable);

Remarks:

Disables displacement subdivision (without altering the parameters).

Parameters:

bool disable

TRUE to disable; FALSE to enable.

Prototype:

void SetDisplacementParameters (TessApprox & params);

Remarks:

Sets most of the displacement parameters. See class TessApprox for details.

Parameters:

TessApprox & params

The tessellation approximation data.

Prototype:

void SetDisplacementSplit (bool split);

Remarks:

Controls displacement subdivision splitting.

Parameters:

bool split

TRUE to set; FALSE to unset.

Prototype:

void SetDisplacement (bool displace);

Remarks:

Turns displacement on or off.

Parameters:

bool displace

TRUE to turn on; FALSE to turn off.

Prototype:

bool GetDisplacementDisable () const;

Remarks:

Indicates whether displacement subdivision is currently disabled.

Prototype:

TessApprox GetDisplacementParameters () const;

Remarks:

Accesses most of the displacement parameters. See class TessApprox for details.

Prototype:

bool GetDisplacementSplit () const;

Remarks:

Indicates whether displacement subdivision splitting is on.

Prototype:

bool GetDisplacement () const;

Remarks:

Indicates whether displacement subdivision is on.

Prototype:

TessApprox &DispParams();

Remarks:

Accessor method for the displacement subdivision parameters that can be quicker to use than SetDisplacementParameters() and GetDisplacementParameters().

 

Prototype:

  BOOL IsPointSelected(int i)

 Remarks:

This method is available in release 4.2 and later only.

Returns TRUE if the 'i-th' point is selected; otherwise FALSE.

Parameters:

 int i

The zero based index of the point to check.

Prototype:

 float PointSelection(int i);

 

Remarks:

This method is available in release 4.2 and later only.

Returns a floating point weighted point selection.

Parameters:

 int i

The zero based index of the point to check.

Return Value:

Returns 1.0f if selected and 0.0f if not.

Prototype:

 float BOOL PolygonCount(TimeValue t, int& numFaces, int& numVerts);

 

Remarks:

This method is available in release 4.2 and later only.

Retreives the number of faces and vertices of the polyginal mesh representation of the object. Note: Plug-In developers should use the global function GetPolygonCount(Object*, int&, int&) to retrieve the number f vertices and faces in an arbitrary object.

 

Parameters:

 

TimeValue t

The time at which to compute the number of faces and vertices.

 int& numFaces

The number of faces is returned here.

 int& numVerts

The number of vertices is returned here.

 

Default Implementation:

 { return TRUE; }