Required Changes To Geometric Objects

3DS Max Plug-In SDK

Required Changes To Geometric Objects

See Also: What's New in the MAX 3.0 SDK, Required Changes to MAX 2.0 Plug-Ins for MAX 3.0.

Overview

This section discusses the changes to Geometric Objects. Note that not all these changes are required of every object. It depends on the type of object and whether the default behavior is undesirable. A brief description of the new or changed methods is provided here. Please refer to the reference section for the method for details.

Mapping Methods

The new multiple mapping methods are for object which support mapping channels. These methods describe how many mapping channels are available and how many are currently used. Both are from Class Object.

virtual int NumMapChannels();

virtual int NumMapsUsed();

Counting Face and Vertex Quantities

There are many places in 3ds max that compute face and vertex counts of objects in the scene. For instance the object properties dialog, summary info, the polygon counter utility, and on file saving to write that info into the file. This was previously done by doing a ConvertToType() to a TriObject representation and counting up the faces and vertices. For certain object types, for instance NURBS, this could be very expensive since the code would need to re-tessellate the whole object. This would also consume a great deal of memory.

There is now a new method in the Object class used to compute the number of faces and vertices in the mesh representation of the Object. This is:

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

Rather than doing a ConvertToType() many objects can simply iterate over their cached mesh to compute this. Geometric objects that represent themselves as a Mesh can also compute this quickly. Therefore developers of Geometric objects that are mesh-based should implement this method. See Class Object for the details.

There is also a global function developers can call to get this information from any geometric object. It is:

void GetPolygonCount(TimeValue t, Object* pObj, int& numFaces, int& numVerts);

Multiple Parametric Surface Access

Methods have been added for accessing multiple parametric surfaces within an object. Previously, only one surface within each object could be accessed. The new methods are:

virtual int NumSurfaces(TimeValue t);

virtual Point3 GetSurfacePoint(TimeValue t, int surface, float u, float v,Interval &iv);

virtual void SurfaceClosed(TimeValue t, int surface, BOOL &uClosed, BOOL &vClosed);

Please see Class Object for details.

Access to Selected Point Information

Geometric Object which support the selection of points (verticies, control points, etc) can make the selection data availalble to other plug-ins via two new methods of Class Object. These are:

virtual BOOL IsPointSelected(int i);

virtual float PointSelection(int i);

Aborting Generating a Mesh

Geometric Object which implement GeomObject::GetRenderMesh() may wish to check for aborted renderings while they generate the render mesh. Some plug-ins do extensive calculations inside this method and to allow 3ds max to respond more rapidly to user abort reqeusts these calcualtions should be stopped as soon as possble. By calling a methods of the View class, CheckForRenderAbort(), inside of GetRenderMesh(), 3ds max can be made to feel all the more responsive. See Class GeomObject and Class View for details.

IMeshSelectData Change

The return types of the GetVertSel(), GetFaceSel() and GetEdgeSel() methods of the Class IMeshSelectData class have changed. They no longer return a referece to a BitArray but rather a BitArray itself.

Supporting AutoGrid

AutoGrid allows for on-the-fly creation of a constuction plane during another object's creation mode. This reults in objects aligning to one another during creation. Objects which handle their own creation will need to add some code to their creation proc. To make it work you can do the following in the creation proc.

...

case MOUSE_FREEMOVE:

 vpt->TrackImplicitGrid(m);

...

case MOUSE_POINT:

if (point == 0)

 vpt>CommitImplicitGrid(m, flag );

...

if( "returning" CREATE_STOP)

 vpt>ReleaseImplicitGrid();

See AutoGrid Related Methods in class ViewExp for information on these methods.