Class ShapeObject

3DS Max Plug-In SDK

Class ShapeObject

See Also: Class GeomObject, Class PolyShape.

class ShapeObject : public GeomObject

Description:

ShapeObjects are open or closed hierarchical shapes made up of one or more pieces. This base class defines a set of methods that plug-in shapes must implement.

Note: Many plug-in shapes may be derived from Class SimpleSpline rather than this class and have fewer methods to implement. See that class for more details.

In release 2.0 and later of 3ds max, ShapeObjects are now renderable. This has introduced a couple of important ramifications. First, any classes subclassing off of ShapeObject should be sure to call the ShapeObject constructor in their constructor, in order to properly initialize the fields contained in the ShapeObject. At present, this is the thickness field, which specifies the thickness of the mesh generated from the shape at rendering time. For example:

LinearShape::LinearShape() : ShapeObject() {

...

}

Second, the ShapeObject now contains Load and Save methods, which handle the storage of the data contained within the ShapeObject. In order to properly store this information, classes which subclass off of ShapeObject need to call the ShapeObject Load and Save methods before storing their information. For example:

IOResult LinearShape::Save(ISave *isave) {

 IOResult res = ShapeObject::Save(isave);

 if(res != IO_OK)

  return res;

...

 }

 

IOResult LinearShape::Load(ILoad *iload) {

 IOResult res = ShapeObject::Load(iload);

 if(res != IO_OK)

  return res;

...

 }

The number of ShapeObject references/subanims are defined as SHAPE_OBJ_NUM_REFS and SHAPE_OBJ_NUM_SUBS in \include\object.h and are set to the number of references and subanims in the ShapeObject class, you can use them to make your code more bullet-proof should the number of references change in the future. See maxsdk\include\splshape.h for an example of how they can be used.

Methods:

Prototype:

void CopyBaseData(ShapeObject &from);

Remarks:

This method is available in release 2.0 and later only.

In order to simplify things for subclasses of ShapeObject, this method is now available. It should be called whenever the ShapeObject-based object is copied. It takes care of copying all the data to the ShapeObject from another ShapeObject-based object

Implemented by the System.

Parameters:

ShapeObject &from

The ShapeObject to copy from.

Prototype:

virtual int IntersectRay(TimeValue t, Ray& ray, float& at, Point3& norm)

Remarks:

Implemented by the Plug-In.

Computes the intersection point of the ray passed and the shape.

Note: In release 3 and later this method has a default implementation and it is no longer necessary to define this method in classes derived from ShapeObject.

Parameters:

TimeValue t

The time to compute the intersection.

Ray& ray

Ray to intersect.

float& at

The point of intersection.

Point3& norm

This parameter is available in release 3.0 and later only.

The surface normal at the point of intersection.

Return Value:

Nonzero if a point of intersection was found; otherwise 0.

Default Implementation:

{return FALSE;}

Access methods

Prototype:

virtual BOOL GetRenderable();

Remarks:

This method is available in release 2.0 and later only.

Implemented by the System.

The ShapeObject class now has a "renderable" flag contained within it. Access to this is via this method and SetRenderable(). If this is set to TRUE and the node is set to renderable, the spline will be rendered. This defaults to FALSE.

Prototype:

virtual void SetRenderable(BOOL sw);

Remarks:

This method is available in release 2.0 and later only.

Implemented by the System.

Sets the rendering flag to the specified value.

Parameters:

BOOL sw

TRUE for on; FALSE for off.

Prototype:

virtual float GetThickness(TimeValue t, Interval &ivalid);

Remarks:

Implemented by the System.

Returns the shape's thickness setting.

Parameters:

TimeValue t

This parameter is available in release 4.0 and later only.

The time to obtain the thickness.

Interval &ivalid

This parameter is available in release 4.0 and later only.

The validity interval.

Prototype:

virtual void SetThickness(TimeValue t, float thick);

Remarks:

Implemented by the System.

Sets the thickness setting of the shape to the specified value.

Parameters:

TimeValue t

This parameter is available in release 4.0 and later only.

The time at which to set the thickness.

float thick

The new thickness setting for the shape.

Prototype:

int GetSides(TimeValue t, Interval &ivalid);

Remarks:

This method is available in release 4.0 and later only.

This method returns the number of sides for the cross-section of the rendering mesh version of the shape for the specified time.

Parameters:

TimeValue t

The time to obtain the thickness.

Interval &ivalid

The validity interval.

Prototype:

void SetSides(TimeValue t, int s);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to set the number of sides for the rendering mesh version of the shape for the specified time. The allowable ranges for this parameter are 3-100.

Parameters:

TimeValue t

The time at which to set the number of sides.

int s

The number of sides you wish to set.

Prototype:

float GetAngle(TimeValue t, Interval &ivalid);

Remarks:

This method is available in release 4.0 and later only.

This method returns the angle that the cross-section of the rendering mesh will be rotated to, for the specified time.

Parameters:

TimeValue t

The time to obtain the thickness.

Interval &ivalid

The validity interval.

Prototype:

void SetAngle(TimeValue t, float a);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to set the cross-section rotation angle for the rendering mesh version of the shape, in degrees, for the specified time.

Parameters:

TimeValue t

The time at which to set the angle.

float a

The angle you wish to set, in degrees.

Prototype:

float GetViewportThickness();

Remarks:

This method is available in release 4.0 and later only.

This method returns the thickness of the viewport version of the rendering mesh. This is not an animated parameter.

Prototype:

int GetViewportSides();

Remarks:

This method is available in release 4.0 and later only.

This method returns the number of sides for the cross-section for the viewport version of the rendering mesh. This is not an animated parameter.

Prototype:

void SetViewportSides(int s);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to set the number of sides for the viewport version of the rendering mesh. This is not an animated parameter.

Parameters:

int s

The number of viewport sides you wish to set.

Prototype:

float GetViewportAngle();

Remarks:

This method is available in release 4.0 and later only.

This method returns the angle that the cross-section of the viewport version of the rendering mesh will be rotated to. This is not an animated parameter.

Prototype:

void SetViewportAngle(float a);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to set the angle that the cross-section of the viewport version of the rendering mesh will be rotated to, in degrees. This is not an animated parameter.

Parameters:

float a

The viewport angle you wish to set, in degrees.

Prototype:

BOOL GetDispRenderMesh();

Remarks:

This method is available in release 4.0 and later only.

This method returns TRUE if the "Display Render Mesh" switch is on. FALSE when the switch is off.

Prototype:

void SetDispRenderMesh(BOOL sw);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to turn the "Display Render Mesh" switch on or off.

Parameters:

BOOL sw

TRUE or FALSE to set or unset the "Display Render Mesh" switch.

Prototype:

BOOL GetUseViewport();

Remarks:

This method is available in release 4.0 and later only.

This method returns TRUE if the "Use Viewport Settings" switch is on. FALSE when the switch is off.

Prototype:

void SetUseViewport(BOOL sw);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to turn the "Use Viewport Settings" switch on or off.

Parameters:

BOOL sw

TRUE or FALSE to set or unset the "Use Viewport Settings" switch.

Prototype:

BOOL GetViewportOrRenderer();

Remarks:

This method is available in release 4.0 and later only.

This method returns the value of the Viewport/Render switch and either returns GENMESH_VIEWPORT or GENMESH_RENDER.

Prototype:

void SetViewportOrRenderer(BOOL sw);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to set the value of the Viewport/Render switch.

Parameters:

BOOL sw

Set this parameter to GENMESH_VIEWPORT or GENMESH_RENDER.

Prototype:

virtual BOOL GetGenUVs();

Remarks:

This method is available in release 2.0 and later only.

Implemented by the System.

Returns TRUE if the generate UVs switch is on; FALSE if off.

Prototype:

virtual void SetGenUVs(BOOL sw);

Remarks:

This method is available in release 2.0 and later only.

Implemented by the System.

Pass TRUE to set the generate UVs switch to on; FALSE to set it off.

Parameters:

BOOL sw

TRUE for on; FALSE for off.

Prototype:

void GetRenderMeshInfo(TimeValue t, INode *inode, View& view, int &nverts, int &nfaces);

Remarks:

This method is available in release 2.0 and later only.

Returns information on the rendering mesh.

Implemented by the System.

Parameters:

TimeValue t

The time to get the information.

INode *inode

The node associated with the mesh.

View& view

Describes properties of the view associated with the render. See Class View.

int &nverts

The number of vertices in the render mesh.

int &nfaces

The number of faces in the render mesh.

Prototype:

virtual int NumberOfVertices(TimeValue t, int curve = -1);

Remarks:

This method is available in release 3.0 and later only.

Implemented by the Plug-In.

This method is used by the Summary Info and Object Properties dialogs to inform the user how many vertices or CVs are in the object. The method is passed a TimeValue and a curve index; if the curve index is <0, the function should return the number of vertices/CVs in the entire shape. Otherwise, it should return the number of vertices/CVs in the specified curve.

Parameters:

TimeValue t

The time at which the number of vertices is to be computed.

int curve = -1

The curve index. See note above.

Default Implementation:

{ return 0; }

Prototype:

virtual int NumberOfCurves()=0;

Remarks:

Implemented by the Plug-In.

Returns the number of polygons in the shape.

Prototype:

virtual BOOL CurveClosed(TimeValue t, int curve)=0;

Remarks:

Implemented by the Plug-In.

This method is called to determine if the specified curve of the shape is closed at the time passed.

Parameters:

TimeValue t

The time to check.

int curve

The index of the curve to check.

Return Value:

TRUE if the curve is closed; otherwise FALSE.

Prototype:

virtual Point3 InterpCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE)=0;

Remarks:

Implemented by the Plug-In.

This method returns a point interpolated on the entire curve. This method returns the point but you don't know which segment the point falls on. See method InterpPiece3D().

Parameters:

TimeValue t

The time to evaluate.

int curve

The index of the curve to evaluate.

float param

The 'distance' along the curve where 0 is the start and 1 is the end.

int ptype=PARAM_SIMPLE

The parameter type for spline interpolation. See List of Parameter Types for Shape Interpolation.

Return Value:

The interpolated point on the curve.

Prototype:

virtual Point3 TangentCurve3D(TimeValue t, int curve, float param, int ptye=PARAM_SIMPLE)=0;

Remarks:

Implemented by the Plug-In.

This method returns a tangent vector interpolated on the entire curve. Also see method TangentPiece3D().

Parameters:

TimeValue t

The time at which to evaluate the curve.

int curve

The index of the curve to evaluate.

float param

The 'distance' along the curve where 0.0 is the start and 1.0 is the end.

int ptype=PARAM_SIMPLE

The parameter type for spline interpolation. See List of Parameter Types for Shape Interpolation.

Return Value:

The tangent vector

Prototype:

virtual float LengthOfCurve(TimeValue t, int curve)=0;

Remarks:

Implemented by the Plug-In.

Returns the length of the specified curve.

Note: This method makes no allowance for non-uniform scaling in the object transform. To do that, see the following code fragment (os is the ObjectState with the shape object and xfm is the NodeTM of the shape object node).

 if (os.obj->SuperClassID() == SHAPE_CLASS_ID) {

  ShapeObject *sobj;

  sobj = (ShapeObject *) os.obj;

  int cct = sobj->NumberOfCurves();

  PolyShape workShape;

  sobj->MakePolyShape(ip->GetTime(), workShape);

  workShape.Transform(xfm);

  float len = 0.0f;

  for (int i=0; i<cct; i++)

   len += workShape.lines[i].CurveLength();

 }

Parameters:

TimeValue t

The time at which to compute the length.

int curve

The index of the curve.

Prototype:

virtual int NumberOfPieces(TimeValue t, int curve)=0;

Remarks:

Implemented by the Plug-In.

Returns the number of sub-curves in a curve.

Parameters:

TimeValue t

The time at which to check.

int curve

The index of the curve.

Prototype:

virtual Point3 InterpPiece3D(TimeValue t, int curve,

int piece, float param, int ptye=PARAM_SIMPLE)=0;

Remarks:

Implemented by the Plug-In.

This method returns the interpolated point along the specified sub-curve (segment). For example consider a shape that is a single circle with four knots. If you called this method with curve=0 and piece=0 and param=0.0 you'd get back the point at knot 0. If you passed the same parameters except param=1.0 you'd get back the point at knot 1.

Parameters:

TimeValue t

The time to evaluate the sub-curve.

int curve

The curve to evaluate.

int piece

The segment to evaluate.

float param

The position along the curve to return where 0.0 is the start and 1.0 is the end.

int ptype=PARAM_SIMPLE

The parameter type for spline interpolation. See List of Parameter Types for Shape Interpolation.

Return Value:

The point in world space.

Prototype:

virtual Point3 TangentPiece3D(TimeValue t, int curve,

int piece, float param, int ptye=PARAM_SIMPLE)=0;

Remarks:

Implemented by the Plug-In.

Returns the tangent vector on a sub-curve at the specified 'distance' along the curve.

Parameters:

TimeValue t

The time to evaluate the sub-curve.

int curve

The curve to evaluate.

int piece

The sub-curve (segment) to evaluate.

float param

The position along the curve to return where 0 is the start and 1 is the end.

int ptype=PARAM_SIMPLE

The parameter type for spline interpolation. See List of Parameter Types for Shape Interpolation.

Return Value:

The tangent vector.

Prototype:

virtual MtlID GetMatID(TimeValue t, int curve, int piece);

Remarks:

Implemented by the Plug-In.

This method is available in release 3.0 and later only.

This method provides access to the material IDs of the shape. It returns the material ID of the specified segment of the specified curve of this shape at the time passed. There is a default implementation so there is no need to implement this method if the shape does not support material IDs.

Note: typedef unsigned short MtlID;

Parameters:

TimeValue t

The time to evaluate the sub-curve.

int curve

The zero based index of the curve to evaluate.

int piece

The sub-curve (segment) to evaluate.

Default Implementation:

{ return 0; }

Prototype:

virtual BOOL CanMakeBezier()

Remarks:

Implemented by the Plug-In.

This method is called to determine if the shape can be converted to a bezier representation.

Return Value:

TRUE if the shape can turn into a bezier representation; otherwise FALSE.

Default Implementation:

{ return FALSE; }

Prototype:

virtual void MakeBezier(TimeValue t, BezierShape &shape);

Remarks:

Implemented by the Plug-In.

Creates the bezier representation of the shape.

Parameters:

TimeValue t

The time to convert.

BezierShape &shape

The bezier representation is stored here.

Default Implementation:

{}

Prototype:

virtual ShapeHierarchy &OrganizeCurves(TimeValue t, ShapeHierarchy *hier=NULL)=0

Remarks:

Implemented by the Plug-In.

This method is called to prepare the shape for lofting, extrusion, etc. This methods looks at the shape organization, and puts together a shape hierarchy. This provides information on how the shapes are nested.

Parameters:

TimeValue t

The time to organize the curves.

ShapeHierarchy *hier=NULL

This class provides information about the hierarchy. See Class ShapeHierarchy.

Prototype:

virtual void MakePolyShape(TimeValue t, PolyShape &shape,

int steps = PSHAPE_BUILTIN_STEPS, BOOL optimize = FALSE)=0;

Remarks:

Implemented by the Plug-In.

Create a PolyShape representation with optional fixed steps.

Parameters:

TimeValue t

The time to make the PolyShape.

PolyShape &shape

The PolyShape representation is stored here.

int steps = PSHAPE_BUILTIN_STEPS

The number of steps between knots. Values >=0 indicates the use of fixed steps:

PSHAPE_BUILTIN_STEPS

Use the shape's built-in steps/adaptive settings (default).

PSHAPE_ADAPTIVE_STEPS

Force adaptive steps.

BOOL optimize = FALSE

If TRUE intermediate steps are removed from linear segments.

Prototype:

virtual int MakeCap(TimeValue t, MeshCapInfo &capInfo, int capType)=0;

Remarks:

Implemented by the Plug-In.

This method generates a mesh capping info for the shape.

Parameters:

TimeValue t

The time to create the cap info.

MeshCapInfo &capInfo

The cap info to update.

int capType

See List of Cap Types.

Return Value:

Nonzero if the cap info was generated; otherwise zero.

Prototype:

virtual int MakeCap(TimeValue t, PatchCapInfo &capInfo)

Remarks:

Implemented by the Plug-In.

This method creates a patch cap info out of the shape. Only implement this method if CanMakeBezier() returns TRUE.

Parameters:

TimeValue t

The time to create the cap info.

PatchCapInfo &capInfo

The cap info to update.

Return Value:

Nonzero if the cap info was generated; otherwise zero.

Default Implementation:

{ return 0; }

Prototype:

virtual BOOL AttachShape(TimeValue t, INode *thisNode, INode *attachNode, BOOL weldEnds=FALSE, float weldThreshold=0.0f);

Remarks:

This method is available in release 2.0 and later only.

This method is called to attach the shape of attachNode to thisNode at the specified time. If any endpoints of the curves in the shape being attached are within the threshold distance to endpoints of an existing curve, and the weld flag is TRUE, they should be welded.

Parameters:

TimeValue t

The time to attach.

INode *thisNode

This is the node associated with this shape object.

INode *attachNode

The node of the shape to attach.

BOOL weldEnds=FALSE

This parameter is available in release 3.0 and later only.

If TRUE the endpoints of the shape should be welded together (based on the threshold below). If FALSE no welding is necessary.

float weldThreshold=0.0f

This parameter is available in release 3.0 and later only.

If any endpoints of the curves in the shape being attached are within this threshold distance to endpoints of an existing curve, and the weld flag is TRUE, they should be welded

Return Value:

Return TRUE if attached; otherwise FALSE.

Default Implementation:

{ return FALSE; }

Prototype:

virtual IOResult Save(ISave *isave);

Remarks:

Implemented by the System.

This method handles the storage of the data contained within the ShapeObject. In order to properly store this information, classes which subclass off of ShapeObject need to call this methods before storing their information.

Parameters:

ISave *isave

An interface for saving data. See Class ISave.

Prototype:

virtual IOResult Load(ILoad *iload);

Remarks:

Implemented by the System.

This method handles the loading of the data contained within the ShapeObject. In order to properly load this information, classes which subclass off of ShapeObject need to call this methods before loading their information.

Parameters:

ILoad *iload

An interface for loading data. See Class ILoad.

Prototype:

virtual Class_ID PreferredCollapseType();

Remarks:

Implemented by the System.

This is an implementation of the Object method. It simply returns splineShapeClassID.

Prototype:

virtual BOOL GetExtendedProperties(TimeValue t, TSTR &prop1Label, TSTR &prop1Data, TSTR &prop2Label, TSTR &prop2Data);

Remarks:

This method is available in release 3.0 and later only.

Implemented by the System.

This is an implementation of the Object method. It fills in the property fields with the number of vertices and curves in the shape.

Prototype:

virtual void RescaleWorldUnits(float f);

Remarks:

This method is available in release 3.0 and later only.

Implemented by the System.

Objects derived from this class which have RescaleWorldUnits methods implemented need to call this method. The following example is the SplineShape implementation of this method from core.

void SplineShape::RescaleWorldUnits(float f) {

 if (TestAFlag(A_WORK1))

  return;

 // Call the base class's rescale (this sets the A_WORK1 flag)

 ShapeObject::RescaleWorldUnits(f);

 // Now rescale stuff inside our data structures

 Matrix3 stm = ScaleMatrix(Point3(f, f, f));

 shape.Transform(stm);

 }

Note that the A_WORK1 flags is tested first to be sure it isn't processing the rescale twice. The code then calls ShapeObject::RescaleWorldUnits, which sets the A_WORK1 flag and performs the necessary rescale methods for all references for the object, and scales the renderable thickness value.

Parameters:

float f

The parameter to scale.

Prototype:

virtual void GenerateMesh(TimeValue t, int option, Mesh *mesh);

Remarks:

This method is available in release 4.0 and later only.

This method will generate a mesh based on either the viewport or rendering parameters for the specified time.

Parameters:

TimeValue t

The time at which to generate the mesh.

int option

The option can be either GENMESH_VIEWPORT, GENMESH_RENDER, or GENMESH_DEFAULT. When using the default definition the mesh generator will use whatever is in the Viewport/Render switch in the parameter block.

Mesh *mesh

A pointer to a Mesh object. If this is set to NULL, the mesh will be generated and cached, but not returned.

Prototype:

virtual RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message);

Remarks:

This method is available in release 4.0 and later only.

Implemented by the Plug-In.

This method will notify the Shape Object of changes in values in its parameter block. The ShapeObject�s parameter block is reference number zero. If subclasses implement this method, they should pass any messages referring to the ShapeObject�s parameter block to it. For example:

// If this isn't one of our references, pass it on to the ShapeObject...

if(hTarget == GetReference(0))

return ShapeObject::NotifyRefChanged(

changeInt, hTarget, partID, message);

This is a vital part of the mechanism; When a parameter in the parameter block changes, the ShapeObject must be able to flush its cached mesh which will no longer be valid.

Parameters:

Interval changeInt

This is the interval of time over which the message is active.

RefTargetHandle hTarget

This is the handle of the reference target the message was sent by. The reference maker uses this handle to know specifically which reference target sent the message.

PartID& partID

This contains information specific to the message passed in. Some messages don't use the partID at all. See the section List of Reference Messages for more information about the meaning of the partID for some common messages.

RefMessage message

The msg parameter passed into this method is the specific message which needs to be handled. See List of Reference Messages.

Return Value:

The return value from this method is of type RefResult. This is usually REF_SUCCEED indicating the message was processed. Sometimes, the return value may be REF_STOP. This return value is used to stop the message from being propagated to the dependents of the item.

Prototype:

virtual RefTargetHandle GetReference(int i);

Remarks:

This method is available in release 4.0 and later only.

This method allows the ShapeObject to return a pointer to its parameter block. Any subclasses implementing this method must pass on the call if it indicates the ShapeObject�s reference. For example:

RefTargetHandle SomeShape::GetReference(int i) {

If(i == 0) return ShapeObject::GetReference(i);

}

Parameters:

int i

The reference handle to retrieve.

Return Value:

The handle to the Reference Target.

Prototype:

virtual void SetReference(int i, RefTargetHandle rtarg);

Remarks:

This method is available in release 4.0 and later only.

This method sets the ShapeObject�s parameter block pointer. Any subclasses implementing this method must pass on the call to the ShapeObject if it refers to index 0. For example:

void SomeShape::SetReference(int i, RefTargetHandle rtarg) {

if(i == 0) ShapeObject::SetReference(i, rtarg);

}

Parameters:

int i

The virtual array index of the reference to store.

RefTargetHandle rtarg

The reference handle to store.

Prototype:

virtual Animatable* SubAnim(int i);

Remarks:

This method is available in release 4.0 and later only.

This method returns the ShapeObject�s animatable pointer. Derived classes implementing this method must pass on references to index 0 to the ShapeObject. For example::

Animatable* SomeShape::SubAnim(int i) {

if(i == 0) return ShapeObject::SubAnim(i);

}

Parameters:

int i

This is the index of the sub-anim to return.

Prototype:

virtual TSTR SubAnimName(int i);

Remarks:

This method is available in release 4.0 and later only.

This method returns the name of the animatable�s name. Derived classes implementing this method must pass on references to index 0 to the ShapeObject. For example:

TSTR SomeShape::SubAnimName(int i) {

if(i == 0) return ShapeObject::SubAnimName(i);

}

Parameters:

int i

This is the index of the sub-anim�s name to return.

Prototype:

ParamDimension *GetParameterDim(int pbIndex);

Remarks:

This method is available in release 4.0 and later only.

This method returns the parameter dimension of the parameter whose index is passed.

Parameters:

int pbIndex

The index of the parameter to return the dimension of.

Return Value:

Pointer to a ParamDimension.

Prototype:

TSTR GetParameterName(int pbIndex);

Remarks:

This method is available in release 4.0 and later only.

This method returns the name of the parameter whose index is passed.

Parameters:

int pbIndex

The index of the parameter to return the dimension of.

Prototype:

virtual int RemapRefOnLoad(int iref);

Remarks:

This method is available in release 4.0 and later only.

This method remaps references at load time so that files saved from previous versions of 3ds max get their references adjusted properly to allow for the new ShapeObject reference. If derived classes implement this method, they must properly pass on the call to the ShapeObject�s code. An example from the SplineShape code:

int SplineShape::RemapRefOnLoad(int iref) {

// Have the ShapeObject do its thing first...

iref = ShapeObject::RemapRefOnLoad(iref); 

 if(loadRefVersion == ES_REF_VER_0)

return iref+1;

 return iref;

}

Note that the SplineShape first calls ShapeObject�s remapper, then applies its remapping operation to the index returned by the ShapeObject code. IMPORTANT NOTE: For this remapping to operate properly, the derived class MUST call ShapeObject::Save as the first thing in its ::Save method, and must call ShapeObject::Load as the first thing in its ::Load method. This allows the ShapeObject to determine file versions and the need for remapping references.

Parameters:

int iref

The input index of the reference.

Return Value:

The output index of the reference.

Prototype:

virtual int NumRefs();

Remarks:

This method is available in release 4.0 and later only.

The ShapeObject makes 1 reference; this is where it tells the system. Any derived classes implementing this method must take this into account when returning the number of references they make. A good idea is to implement NumRefs in derived classes as:

Int SomeShape::NumRefs() {

return myNumRefs + ShapeObject::NumRefs();

}

Default Implementation:

{return 1;}

Prototype:

void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev);

Remarks:

This method is available in release 4.0 and later only.

This method allows the ShapeObject to create its new "Rendering" rollup. To use it, the derived class simply calls it first thing in its own BeginEditParams method. An example from the SplineShape code:

void SplineShape::BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev )

{

ShapeObject::BeginEditParams(ip, flags, prev);

 // �

}

Parameters:

IObjParam *ip

The interface pointer passed to the plug-in.

ULONG flags

The flags passed along to the plug-in in Animatable::BeginEditParams().

Animatable *prev

The pointer passed to the plug-in in Animatable::BeginEditParams().

Prototype:

void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next);

Remarks:

This method is available in release 4.0 and later only.

Similarly to BeginEditParams, this method allows the ShapeObject to remove its "Rendering" rollup. A derived class simply calls this first thing in its own EndEditParams. An example from the SplineShape code:

void SplineShape::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next )

{

ShapeObject::EndEditParams(ip, flags, next);

// �

}

Parameters:

IObjParam *ip

The interface pointer passed to the plug-in.

ULONG flags

The flags passed along to the plug-in in Animatable::BeginEditParams().

Animatable *prev

The pointer passed to the plug-in in Animatable::BeginEditParams().

Prototype:

Interval GetShapeObjValidity(TimeValue t);

Remarks:

This method is available in release 4.0 and later only.

This method gets the validity interval for the ShapeObject�s internal parameters only. It DOES NOT include those of the derived classes. So, if you called this method on a ShapeObject that was a circle with an animated radius, you wouldn�t see the effect of the animated radius on the interval � All you�d see would be the interval of the ShapeObject�s rendering parameters. To get the entire ShapeObject�s interval, you would call ShapeObject::ObjectShapeObjValidity(t).

Parameters:

TimeValue t

The time about which the interval is computed.

Prototype:

int Display(TimeValue t, INode *inode, ViewExp* vpt, int flags);

Remarks:

This method is available in release 4.0 and later only.

This method displays the shape's generated mesh if necessary. Objects derived from ShapeObject will want to have the ShapeObject code display the rendering mesh in the viewport; this method will do that for them. Simply set the viewport transform and call this method. An example from the SplineShape code:

int SplineShape::Display(TimeValue t, INode *inode, ViewExp* vpt, int flags)

{

Eval(t);

GraphicsWindow *gw = vpt->getGW();

gw->setTransform(inode->GetObjectTM(t));

ShapeObject::Display(t, inode, vpt, flags);

// �

}

If the ShapeObject�s "Display Render Mesh" switch is off, it will do nothing. Otherwise, it will display the proper mesh as specified by its parameter block.

Parameters:

TimeValue t

The time to display the object.

INode* inode

The node to display.

ViewExp *vpt

An interface pointer that may be used to call methods associated with the viewports.

int flags

See List of Display Flags.

Return Value:

The return value is not currently used.

Prototype:

virtual Box3 GetBoundingBox(TimeValue t, Matrix3 *tm=NULL);

Remarks:

This method is available in release 4.0 and later only.

This method returns a bounding box for the shape, if it�s active, if the "Display Render Mesh" switch is on. It is necessary to include this box when computing the bounding box for a shape, otherwise the viewport display will not work properly.

Parameters:

TimeValue t

The time to get the bounding box.

Matrix3 *tm

The points of ShapeObject are transformed by this matrix prior to the bounding box computations.

Prototype:

virtual void InvalidateGeomCache();

Remarks:

This method is available in release 4.0 and later only.

This method is very important � It causes the ShapeObject to flush its cached rendering mesh. Most objects have their own "InvalidateGeomCache" methods; simply call this when a shape derived from ShapeObject changes and it will ensure that the rendering mesh is regenerated the next time it is evaluated. Failure to call this method will result in improper rendering mesh updates.