Public Member Functions | Public Attributes | Protected Member Functions

LinearShape Class Reference

This reference page is linked to from the following overview topics: Plug-in Base Classes, Deformable Objects, Shape and Spline Principal Classes.


Search for all occurrences

Detailed Description

See also:
Class ShapeObject, Class PolyShape, Working with Shapes and Splines.

Description:
This class represents a linear shape object. This class is similar to a SplineShape except this class uses a PolyShape as its data while a SplineShape uses a BezierShape as its data. Therefore this is a shape made up of entirely linear segments. All methods of this class are implemented by the system.
Data Members:
PolyShape shape;

The PolyShape that holds the linear shape.

#include <linshape.h>

Inheritance diagram for LinearShape:
Inheritance graph
[legend]

List of all members.

Public Member Functions

CoreExport  LinearShape ()
CoreExport  ~LinearShape ()
CoreExport LinearShape operator= (LinearShape &from)
CoreExport int  HitTest (TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt)
  This method is called to determine if the specified screen point intersects the item.
CoreExport void  Snap (TimeValue t, INode *inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt)
  Checks the point passed for a snap and updates the SnapInfo structure.
CoreExport int  Display (TimeValue t, INode *inode, ViewExp *vpt, int flags)
  This method displays the shape's generated mesh if necessary.
CoreExport CreateMouseCallBack GetCreateMouseCallBack ()
  This method allows the system to retrieve a callback object used in creating an object in the 3D viewports.
CoreExport RefTargetHandle  Clone (RemapDir &remap)
  This method is used by 3ds Max to clone an object.
CoreExport ObjectState  Eval (TimeValue time)
  This method is called to evaluate the object and return the result as an ObjectState.
CoreExport Interval  ObjectValidity (TimeValue t)
  This method returns the validity interval of the object as a whole at the specified time.
CoreExport Interval  ConvertValidity (TimeValue t)
CoreExport Interval  ChannelValidity (TimeValue t, int nchan)
  Retrieve the current validity interval for the nchan channel of the object.
CoreExport void  SetChannelValidity (int i, Interval v)
  Sets the validity interval of the specified channel.
CoreExport void  InvalidateChannels (ChannelMask channels)
  This method invalidates the intervals for the given channel mask.
int  IsDeformable ()
  Indicates whether this object is deformable.
CoreExport int  NumPoints ()
  The points of a deformable object are accessed through a virtual array interface.
CoreExport Point3  GetPoint (int i)
  The points of a deformable object are accessed through a virtual array interface.
CoreExport void  SetPoint (int i, const Point3 &p)
  The points of a deformable object are accessed through a virtual array interface.
CoreExport BOOL  IsPointSelected (int i)
  Returns TRUE if the 'i-th' point is selected; otherwise FALSE.
CoreExport void  PointsWereChanged ()
  Informs the object that its points have been deformed, so it can invalidate its cache.
CoreExport void  GetDeformBBox (TimeValue t, Box3 &box, Matrix3 *tm=NULL, BOOL useSel=FALSE)
  This method computes the bounding box in the objects local coordinates or the optional space defined by tm.
CoreExport void  Deform (Deformer *defProc, int useSel)
  This is the method used to deform the object with a deformer.
CoreExport int  CanConvertToType (Class_ID obtype)
  Indicates whether the object can be converted to the specified type.
CoreExport Object ConvertToType (TimeValue t, Class_ID obtype)
  This method converts this object to the type specified and returns a pointer it.
CoreExport void  FreeChannels (ChannelMask chan)
  This method deletes the memory associated with the specified channels and set the intervals associated with the channels to invalid (empty).
CoreExport Object MakeShallowCopy (ChannelMask channels)
  This method must make a copy of its "shell" and then shallow copy (see below) only the specified channels.
CoreExport void  ShallowCopy (Object *fromOb, ChannelMask channels)
  This method copies the specified channels from the fromOb to this and copies the validity intervals.
CoreExport void  NewAndCopyChannels (ChannelMask channels)
  This method replaces the locked channels with newly allocated copies.
CoreExport DWORD  GetSubselState ()
  For objects that have sub selection levels, this method returns the current selection level of the object.
CoreExport ObjectHandle  CreateTriObjRep (TimeValue t)
CoreExport void  GetWorldBoundBox (TimeValue t, INode *inode, ViewExp *vpt, Box3 &box)
  This method returns the world space bounding box for Objects (see below for the Sub-object gizmo or Modifiers gizmo version).
CoreExport void  GetLocalBoundBox (TimeValue t, INode *inode, ViewExp *vpt, Box3 &box)
  This is the object space bounding box, the box in the object's local coordinates.
CoreExport int  NumberOfVertices (TimeValue t, int curve)
  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.
CoreExport int  NumberOfCurves ()
  Returns the number of polygons in the shape.
CoreExport BOOL  CurveClosed (TimeValue t, int curve)
  This method is called to determine if the specified curve of the shape is closed at the time passed.
CoreExport Point3  InterpCurve3D (TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE)
  This method returns a point interpolated on the entire curve.
CoreExport Point3  TangentCurve3D (TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE)
  This method returns a tangent vector interpolated on the entire curve.
CoreExport float  LengthOfCurve (TimeValue t, int curve)
  Returns the length of the specified curve.
CoreExport int  NumberOfPieces (TimeValue t, int curve)
  Returns the number of sub-curves in a curve.
CoreExport Point3  InterpPiece3D (TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE)
  This method returns the interpolated point along the specified sub-curve (segment).
CoreExport Point3  TangentPiece3D (TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE)
  Returns the tangent vector on a sub-curve at the specified 'distance' along the curve.
CoreExport MtlID  GetMatID (TimeValue t, int curve, int piece)
BOOL  CanMakeBezier ()
  This method is called to determine if the shape can be converted to a bezier representation.
CoreExport void  MakeBezier (TimeValue t, BezierShape &shape)
  Creates the bezier representation of the shape.
CoreExport ShapeHierarchy OrganizeCurves (TimeValue t, ShapeHierarchy *hier=NULL)
  This method is called to prepare the shape for lofting, extrusion, etc.
CoreExport void  MakePolyShape (TimeValue t, PolyShape &shape, int steps=PSHAPE_BUILTIN_STEPS, BOOL optimize=FALSE)
  Create a PolyShape representation with optional fixed steps.
CoreExport int  MakeCap (TimeValue t, MeshCapInfo &capInfo, int capType)
  This method generates a mesh capping info for the shape.
CoreExport int  MakeCap (TimeValue t, PatchCapInfo &capInfo)
  This method creates a patch cap info out of the shape.
PolyShape GetShape ()
CoreExport void  SetPointFlags ()
CoreExport void  DeleteThis ()
  Deletes an instance of this class.
void  FreeCaches ()
Class_ID  ClassID ()
  Retrieves a constant that uniquely identifies the plugin class.
CoreExport void  GetClassName (MSTR &s)
  Retrieves the name of the plugin class.
void  NotifyMe (Animatable *subAnim, int message)
int  IsKeyable ()
int  Update (TimeValue t)
BOOL  BypassTreeView ()
CoreExport MCHAR *  GetObjectName ()
CoreExport IOResult  Save (ISave *isave)
  Implemented by the System.
CoreExport IOResult  Load (ILoad *iload)
  Implemented by the System.
CoreExport void  RescaleWorldUnits (float f)
  Implemented by the System.
CoreExport void  InvalidateGeomCache ()
  This method is very important - It causes the ShapeObject to flush its cached rendering mesh.

Public Attributes

PolyShape  shape

Protected Member Functions

RefResult  NotifyRefChanged (Interval changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message)
  This method will notify the Shape Object of changes in values in its parameter block.

Constructor & Destructor Documentation

CoreExport LinearShape ( )
Remarks:
Constructor.
CoreExport ~LinearShape ( )
Remarks:
Destructor.

Member Function Documentation

RefResult NotifyRefChanged ( Interval  changeInt,
RefTargetHandle  hTarget,
PartID partID,
RefMessage  message 
) [protected, virtual]

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:
changeInt This is the interval of time over which the message is active.
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 This contains information specific to the message passed in. Some messages don't use the partID at all. See the section Reference Messages for more information about the meaning of the partID for some common messages.
message The msg parameter passed into this method is the specific message which needs to be handled. See Reference Messages.
Returns:
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.

Reimplemented from ShapeObject.

CoreExport LinearShape& operator= ( LinearShape from )
CoreExport int HitTest ( TimeValue  t,
INode inode,
int  type,
int  crossing,
int  flags,
IPoint2 p,
ViewExp vpt 
) [virtual]

This method is called to determine if the specified screen point intersects the item.

The method returns nonzero if the item was hit; otherwise 0.

Parameters:
t The time to perform the hit test.
inode A pointer to the node to test.
type The type of hit testing to perform. See Scene and Node Hit Test Types. for details.
crossing The state of the crossing setting. If TRUE crossing selection is on.
flags The hit test flags. See Scene and Node Hit Testing Flags for details.
p The screen point to test.
vpt An interface pointer that may be used to call methods associated with the viewports.
Returns:
Nonzero if the item was hit; otherwise 0.

Reimplemented from BaseObject.

CoreExport void Snap ( TimeValue  t,
INode inode,
SnapInfo snap,
IPoint2 p,
ViewExp vpt 
) [virtual]

Checks the point passed for a snap and updates the SnapInfo structure.

Note:
Developers wanting to find snap points on an Editable Mesh object should see the method XmeshSnap::Snap() in /MAXSDK/SAMPLES/SNAPS/XMESH/XMESH.CPP.
Parameters:
t The time to check.
inode The node to check.
snap The snap info structure to update.
p The screen point to check.
vpt An interface pointer that may be used to call methods associated with the viewports.

Reimplemented from BaseObject.

CoreExport int Display ( TimeValue  t,
INode inode,
ViewExp vpt,
int  flags 
) [virtual]

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:
t The time to display the object.
inode The node to display.
vpt An interface pointer that may be used to call methods associated with the viewports.
flags See Display Flags.
Returns:
The return value is not currently used.

Reimplemented from ShapeObject.

CoreExport CreateMouseCallBack* GetCreateMouseCallBack ( ) [virtual]

This method allows the system to retrieve a callback object used in creating an object in the 3D viewports.

This method returns a pointer to an instance of a class derived from CreateMouseCallBack. This class has a method proc() which is where the programmer defines the user/mouse interaction during the object creation phase.

Returns:
A pointer to an instance of a class derived from CreateMouseCallBack.

Implements BaseObject.

CoreExport RefTargetHandle Clone ( RemapDir remap ) [virtual]

This method is used by 3ds Max to clone an object.

See also:
CloneRefHierarchy(), class RemapDir This method is called by 3ds Max to have the plugin clone itself. The plug-in's implementation of this method should copy both the data structure and all the data residing in the data structure of this reference target. The plugin should clone all its references as well. Also, the plug-in's implementation of this method must call BaseClone(). In order for classes derived from this class to clone cleanly, the Clone method should just create the new instance, and then call an implementation of BaseClone that clones the references and copies any other necessary data. For example:
            class MyDerivedPlugin
                : public MyBasePlugin
            {
                const int MY_REFERENCE = 1;

                ReferenceTarget* Clone(RemapDir& remap)
                {
                    ReferenceTarget* result = new MyDerivedPlugin();
                    BaseClone(this, result, remap);
                    return result;
                }

                void BaseClone(ReferenceTarget* from, ReferenceTarget* to, RemapDir& remap)
                {
                    if (!to || !from || from == to)
                        return;    
                    MyBasePlugin::BaseClone(from, to, remap);
                    to->ReplaceReference(MY_REFERENCE, remap->CloneRef(from->GetReference(MY_REFERENCE)));
                }
            };

This method should not be directly called by plug-ins. Instead, either RemapDir::CloneRef() or CloneRefHierachy() should be used to perform cloning. These methods ensure that the mapping from the original object to the clone is added to the RemapDir used for cloning, which may be used during backpatch operations

Note:
See the remarks in method BaseClone() below.
Parameters:
remap - A RemapDir instance used for remapping references during a Clone.
Returns:
A pointer to the cloned item.

Reimplemented from ReferenceTarget.

CoreExport ObjectState Eval ( TimeValue  t ) [virtual]

This method is called to evaluate the object and return the result as an ObjectState.

When the system has a pointer to an object it doesn't know if it's a procedural object or a derived object. So it calls Eval() on it and gets back an ObjectState. A derived object managed by the system may have to call Eval() on its input for example. A plug-in (like a procedural object) typically just returns itself. A plug-in that does not just return itself is the Morph Object (/MAXSDK/SAMPLES/OBJECTS/MORPHOBJ.CPP). This object uses a morph controller to compute a new object and fill in an ObjectState which it returns.

Parameters:
t Specifies the time to evaluate the object.
Returns:
The result of evaluating the object as an ObjectState.
Sample Code:
Typically this method is implemented as follows:
    { return ObjectState(this); }

Implements Object.

CoreExport Interval ObjectValidity ( TimeValue  t ) [virtual]

This method returns the validity interval of the object as a whole at the specified time.

Parameters:
t The time to compute the validity interval.
Default Implementation:
{ return FOREVER; }
Returns:
The validity interval of the object.

Reimplemented from Object.

CoreExport Interval ConvertValidity ( TimeValue  t )
CoreExport Interval ChannelValidity ( TimeValue  t,
int  nchan 
) [virtual]

Retrieve the current validity interval for the nchan channel of the object.

Note:
Most procedural objects won't implement this method since they don't have individual channels. Developers wanting to get the validity interval for a procedural object should use Object::ObjectValidity() instead.
Parameters:
t The time to retrieve the validity interval of the channel.
nchan Specifies the channel to return the validity interval of. See Object Channel Indices.
Returns:
The validity interval of the specified channel.

Reimplemented from Object.

CoreExport void SetChannelValidity ( int  nchan,
Interval  v 
) [virtual]

Sets the validity interval of the specified channel.

Parameters:
nchan Specifies the channel. See Object Channel Indices
v The validity interval for the channel.

Reimplemented from Object.

CoreExport void InvalidateChannels ( ChannelMask  channels ) [virtual]

This method invalidates the intervals for the given channel mask.

This just sets the validity intervals to empty (calling SetEmpty() on the interval).

Parameters:
channels Specifies the channels to invalidate.

Reimplemented from Object.

int IsDeformable ( ) [inline, virtual]

Indicates whether this object is deformable.

A deformable object is simply an object with points that can be modified. Deformable objects must implement the generic deformable object methods (NumPoints(), GetPoint(i), SetPoint(i), Deform()). A deformable object is simply an object with points that can be modified. These points can be stored in any form the object wants. They are accessed through a virtual array interface with methods to get and set the 'i-th' point. If an object has tangents for instance, it would convert them to and from points as necessary. For example, a simple Bezier spline object that stored its control handles relative to the knot would convert them to be absolute when GetPoint() was called with 'i' specifying one of the control points. When the control point is later set, the object can convert it back to be relative to its knot. At this point it could also apply any constraints that it may have, such as maintaining a degree of continuity. The idea is that the entity calling GetPoint(i) and SetPoint(i) doesn't care what the point represents. It will simply apply some function to the point.

Note:
The Deformable object methods only need to be implemented if the object returns TRUE from this method.
Returns:
Return nonzero if the object is deformable and implements the generic deformable object methods; otherwise 0.

Reimplemented from Object.

{ return 1; }  
CoreExport int NumPoints ( ) [virtual]

The points of a deformable object are accessed through a virtual array interface.

This method specifies the number of points in the object. The meaning of 'points' is defined by the object. A TriObject uses the vertices as the points for example. b>

Returns:
The number of points in the object.

Reimplemented from Object.

CoreExport Point3 GetPoint ( int  i ) [virtual]

The points of a deformable object are accessed through a virtual array interface.

This method returns the 'i-th' point of the object.

Note:
If your plug-in is a modifier and you want to operate on the selected points of the object you are modifying, you can't tell which points are selected unless you know the type of object. If it is a generic deformable object there is no way of knowing since the way the object handles selection is up to it. Therefore, if you want to operate on selected points of a generic deformable object, use a Deformer.
Parameters:
i Specifies which point should be returned.
Returns:
The 'i-th' point of the object.

Reimplemented from Object.

CoreExport void SetPoint ( int  i,
const Point3 p 
) [virtual]

The points of a deformable object are accessed through a virtual array interface.

This method stores the 'i-th' point of the object.

Parameters:
i The index of the point to store.
p The point to store.

Reimplemented from Object.

CoreExport BOOL IsPointSelected ( int  i ) [virtual]

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

Parameters:
i The zero based index of the point to check.

Reimplemented from Object.

CoreExport void PointsWereChanged ( ) [virtual]

Informs the object that its points have been deformed, so it can invalidate its cache.

A developer who uses the GetPoint() / SetPoint() approach to modifying an object will call PointsWereChanged() to invalidate the object's cache. For example, if a modifier calls SetPoint(), when it is finished it should call this method so the object can invalidate and/or update its bounding box and any other data it might cache.

Reimplemented from Object.

CoreExport void GetDeformBBox ( TimeValue  t,
Box3 box,
Matrix3 tm = NULL,
BOOL  useSel = FALSE 
) [virtual]

This method computes the bounding box in the objects local coordinates or the optional space defined by tm.

Note: If you are looking for a precise bounding box, use this method and pass in the node's object TM (INode::GetObjectTM()) as the matrix.

Parameters:
t The time to compute the box.
box A reference to a box the result is stored in.
tm This is an alternate coordinate system used to compute the box. If the tm is not NULL this matrix should be used in the computation of the result.
useSel If TRUE, the bounding box of selected sub-elements should be computed; otherwise the entire object should be used.

Reimplemented from Object.

CoreExport void Deform ( Deformer defProc,
int  useSel 
) [virtual]

This is the method used to deform the object with a deformer.

The developer should loop through the object's points calling the defProc for each point (or each selected point if useSel is nonzero). The Deform() method is mostly a convenience. Modifiers can implement a 'Deformer' callback object which is passed to the Deform() method. The object then iterates through its points calling their deformer's callback for each point. The only difference between using the Deform() method as opposed to iterating through the points is that the Deform() method should respect sub-object selection. For example, the TriObject's implementation of Deform() iterates through its vertices, if the TriObject's selection level is set to vertex then it only calls the Deformer's callback for vertices that are selected. This way modifiers can be written that can be applied only to selection sets without any specific code to check selected points. The default implementation of this method just iterates through all points using GetPoint(i) and SetPoint(i). If an object supports sub-object selection sets then it should override this method.

Parameters:
defProc A pointer to an instance of the Deformer class. This is the callback object that actually performs the deformation.
useSel A flag to indicate if the object should use the selected points only. If nonzero the selected points are used; otherwise all the points of the object are used.
Default Implementation:
    void Object::Deform(Deformer *defProc,int useSel)
    {
        int nv = NumPoints();
        for (int i=0; i<nv; i++)
            SetPoint(i,defProc->Map(i,GetPoint(i)));
        PointsWereChanged();
    }
Sample Code:
This code shows the TriObject implementation of this method. Note how it looks at the useSel parameter to only call the selected points if required.
    void TriObject::Deform(Deformer *defProc,int useSel)
    {
        int nv = NumPoints();
        int i;
        if ( useSel ) {
            BitArray sel = mesh.VertexTempSel();
            float *vssel = mesh.getVSelectionWeights ();
            if (vssel) {
                for (i=0; i<nv; i++) {
                    if(sel[i]) {
                        SetPoint(i,defProc->Map(i,GetPoint(i)));
                        continue;
                    }
                    if (vssel[i]==0) continue;
                    Point3 & A = GetPoint(i);
                    Point3 dir = defProc->Map(i,A) - A;
                    SetPoint(i,A+vssel[i]*dir);
                }
            }
            else {
                for (i=0; i<nv; i++) if (sel[i])
                    SetPoint(i,defProc->Map(i,GetPoint(i)));
            }
        }
        else {
            for (i=0; i<nv; i++)
                SetPoint(i,defProc->Map(i,GetPoint(i)));
        }
        PointsWereChanged();
    }

Reimplemented from Object.

CoreExport int CanConvertToType ( Class_ID  obtype ) [virtual]

Indicates whether the object can be converted to the specified type.

If the object returns nonzero to indicate it can be converted to the specified type, it must handle converting to and returning an object of that type from ConvertToType().

See also:
Class ObjectConverter for additional details on converting objects between types.
Parameters:
obtype The Class_ID of the type of object to convert to. See Class Class_ID, List of Class_IDs.
Returns:
Nonzero if the object can be converted to the specified type; otherwise 0.
Default Implementation:
{ return 0; }

Reimplemented from Object.

CoreExport Object* ConvertToType ( TimeValue  t,
Class_ID  obtype 
) [virtual]

This method converts this object to the type specified and returns a pointer it.

Note that if ConvertToType() returns a new object it should be a completely different object with no ties (pointers or references) to the original.

See also:
class ObjectConverter for additional details on converting objects between types.
The following is an issue that developers of world space modifiers need to
be aware of if the world space modifier specifies anything but generic deformable objects as its input type. In other words, if a world space modifier, in its implementation of Modifier::InputType(), doesn't specifically return defObjectClassID then the following issue regarding the 3ds Max pipeline needs to be considered. Developers of other plug-ins that don't meet this condition don't need to be concerned with this issue.
World space modifiers that work on anything other than generic deformable
objects are responsible for transforming the points of the object they modify into world space using the ObjectState TM. To understand why this is necessary, consider how 3ds Max applies the node transformation to the object flowing down the pipeline.
In the geometry pipeline architecture, the node in the scene has its
transformation applied to the object in the pipeline at the transition between the last object space modifier and the first world space modifier. The node transformation is what places the object in the scene -- thus this is what puts the object in world space. The system does this by transforming the points of the object in the pipeline by the node transformation. This is only possible however for deformable objects. Deformable objects are those that support the Object::IsDeformable(), NumPoints(), GetPoint() and SetPoint() methods. These deformable objects can be deformed by the system using these methods, and thus the system can modify the points to put them in world space itself.
If a world space modifier does not specify that it works on deformable
objects, the system is unable to transform the points of the object into world space. What it does instead is apply the transformation to the ObjectState TM. In this case, a world space modifier is responsible for transforming the points of the object into world space itself, and then setting the ObjectState TM to the identity. There is an example of this in the sample code for the Bomb space warp. The Bomb operates on TriObjects and implements InputType() as { return Class_ID(TRIOBJ_CLASS_ID,0); }. Since it doesn't specifically return defObjectClassID, it is thus responsible for transforming the points of the object into world space itself. It does this in its implementation of ModifyObject() as follows:
    if (os->GetTM())
    {
        Matrix3 tm = *(os->GetTM());
        for (int i=0; i<triOb->mesh.getNumVerts(); i++) {
            triOb->mesh.verts[i] = triOb->mesh.verts[i] *tm;
        }
        os->obj->UpdateValidity(GEOM_CHAN_NUM,os->tmValid());
        os->SetTM(NULL,FOREVER);
    }
As the code above shows, the Bomb checks if the ObjectState TM is non-NULL. If it is, the points of the object are still not in world space and thus must be transformed. It does this by looping through the points of the TriObject and multiplying each point by the ObjectState TM. When it is done, it sets the ObjectState TM to NULL to indicate the points are now in world space. This ensure that any later WSMs will not transform the points with this matrix again.
For the Bomb world space modifier this is not a problem since it specifies
in its implementation of ChannelsChanged() that it will operate on the geometry channel (PART_GEOM). Certain world space modifiers may not normally specify PART_GEOM in their implementation of ChannelsChanged(). Consider the camera mapping world space modifier. Its function is to apply mapping coordinates to the object it is applied to. Thus it would normally only specify PART_TEXMAP for ChannelsChanged(). However, since it operates directly on TriObjects, just like the Bomb, the system cannot transform the points into world space, and therefore the camera mapping modifier must do so in its implementation of ModifyObject(). But since it is actually altering the points of the object by putting them into world space it is altering the geometry channel. Therefore, it should really specify PART_GEOM | PART_TEXMAP in its implementation of ChannelsChanged(). If it didn't do this, but went ahead and modified the points of the object anyway, it would be transforming not copies of the points, but the original points stored back in an earlier cache or even the base object.
This is the issue developers need to be aware of. To state this in simple
terms then: Any world space modifier that needs to put the points of the object into world space (since it doesn't implement InputType() as defObjectClassID) needs to specify PART_GEOM in its implementation of ChannelsChanged().
Parameters:
t The time at which to convert.
obtype The Class_ID of the type of object to convert to. See Class Class_ID, List of Class_IDs.
Returns:
A pointer to an object of type obtype.
Default Implementation:
{ return NULL; }
Sample Code:
The following code shows how a TriObject can be retrieved from a node. Note on the code that if you call ConvertToType() on an object and it returns a pointer other than itself, you are responsible for deleting that object.
    // Retrieve the TriObject from the node
    int deleteIt;
    TriObject *triObject = GetTriObjectFromNode(ip->GetSelNode(0),deleteIt);
    // Use the TriObject if available
    if (!triObject) return;
    // ...
    // Delete it when done...
    if (deleteIt) triObject->DeleteMe();
    
    // Return a pointer to a TriObject given an INode or return NULL
    // if the node cannot be converted to a TriObject
    TriObject *Utility::GetTriObjectFromNode(INode *node, int &deleteIt)
    {
        deleteIt = FALSE;
        Object *obj = node->EvalWorldState(0).obj;
        if (obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0))) {
            TriObject *tri = (TriObject *) obj->ConvertToType(0,Class_ID(TRIOBJ_CLASS_ID, 0));
    // Note that the TriObject should only be deleted
    // if the pointer to it is not equal to the object
    // pointer that called ConvertToType()
            if (obj != tri) 
                deleteIt = TRUE;
            return tri;
        }
        else {
            return NULL;
        }
    }

Reimplemented from Object.

CoreExport void FreeChannels ( ChannelMask  channels ) [virtual]

This method deletes the memory associated with the specified channels and set the intervals associated with the channels to invalid (empty).

Parameters:
channels Specifies the channels to free.

Reimplemented from Object.

CoreExport Object* MakeShallowCopy ( ChannelMask  channels ) [virtual]

This method must make a copy of its "shell" and then shallow copy (see below) only the specified channels.

It must also copy the validity intervals of the copied channels, and invalidate the other intervals.

Parameters:
channels The channels to copy.
Returns:
A pointer to the shallow copy of the object.

Reimplemented from Object.

CoreExport void ShallowCopy ( Object fromOb,
ChannelMask  channels 
) [virtual]

This method copies the specified channels from the fromOb to this and copies the validity intervals.

A plug-in needs to copy the specified channels from the specified object fromOb to itself by just copying pointers (not actually copying the data). No new memory is typically allocated, this method is just copying the pointers.

Parameters:
fromOb Object to copy the channels from.
channels Channels to copy.

Reimplemented from Object.

CoreExport void NewAndCopyChannels ( ChannelMask  channels ) [virtual]

This method replaces the locked channels with newly allocated copies.

It will only be called if the channel is locked.

Parameters:
channels The channels to be allocate and copy.

Reimplemented from Object.

CoreExport DWORD GetSubselState ( ) [virtual]

For objects that have sub selection levels, this method returns the current selection level of the object.

For example, a TriObject has the following selection levels: object, vertex, face, edge. Other object types may have different selection levels. The only standard is that a value of 0 indicates object level. b>

Returns:
The current selection level of the object.

Reimplemented from Object.

CoreExport ObjectHandle CreateTriObjRep ( TimeValue  t )
CoreExport void GetWorldBoundBox ( TimeValue  t,
INode inode,
ViewExp vp,
Box3 box 
) [virtual]

This method returns the world space bounding box for Objects (see below for the Sub-object gizmo or Modifiers gizmo version).

The bounding box returned by this method does not need to be precise. It should however be calculated rapidly. The object can handle this by transforming the 8 points of its local bounding box into world space and take the minimums and maximums of the result. Although this isn't necessarily the tightest bounding box of the objects points in world space, it is close enough.

Parameters:
t The time to compute the bounding box.
inode The node to calculate the bounding box for.
vp An interface pointer that can be used to call methods associated with the viewports.
box Contains the returned bounding box.

Reimplemented from BaseObject.

CoreExport void GetLocalBoundBox ( TimeValue  t,
INode inode,
ViewExp vp,
Box3 box 
) [virtual]

This is the object space bounding box, the box in the object's local coordinates.

The system expects that requesting the object space bounding box will be fast.

Parameters:
t The time to retrieve the bounding box.
inode The node to calculate the bounding box for.
vp An interface pointer that may be used to call methods associated with the viewports.
box Contains the returned bounding box.

Reimplemented from BaseObject.

CoreExport int NumberOfVertices ( TimeValue  t,
int  curve 
) [virtual]

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:
t The time at which the number of vertices is to be computed.
curve The curve index. See note above.

Reimplemented from ShapeObject.

CoreExport int NumberOfCurves ( ) [virtual]

Returns the number of polygons in the shape.

Implements ShapeObject.

CoreExport BOOL CurveClosed ( TimeValue  t,
int  curve 
) [virtual]

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

Parameters:
t The time to check.
curve The index of the curve to check.
Returns:
TRUE if the curve is closed; otherwise FALSE.

Implements ShapeObject.

CoreExport Point3 InterpCurve3D ( TimeValue  t,
int  curve,
float  param,
int  ptype = PARAM_SIMPLE 
) [virtual]

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:
t The time to evaluate.
curve The index of the curve to evaluate.
param The 'distance' along the curve where 0 is the start and 1 is the end.
ptype The parameter type for spline interpolation. See List of Parameter Types for Shape Interpolation.
Returns:
The interpolated point on the curve.

Implements ShapeObject.

CoreExport Point3 TangentCurve3D ( TimeValue  t,
int  curve,
float  param,
int  ptype = PARAM_SIMPLE 
) [virtual]

This method returns a tangent vector interpolated on the entire curve.

Also see method TangentPiece3D().

Parameters:
t The time at which to evaluate the curve.
curve The index of the curve to evaluate.
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.
Returns:
The tangent vector

Implements ShapeObject.

CoreExport float LengthOfCurve ( TimeValue  t,
int  curve 
) [virtual]

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:
t The time at which to compute the length.
curve The index of the curve.

Implements ShapeObject.

CoreExport int NumberOfPieces ( TimeValue  t,
int  curve 
) [virtual]

Returns the number of sub-curves in a curve.

Parameters:
t The time at which to check.
curve The index of the curve.

Implements ShapeObject.

CoreExport Point3 InterpPiece3D ( TimeValue  t,
int  curve,
int  piece,
float  param,
int  ptype = PARAM_SIMPLE 
) [virtual]

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:
t The time to evaluate the sub-curve.
curve The curve to evaluate.
piece The segment to evaluate.
param The position along the curve to return where 0.0 is the start and 1.0 is the end.
ptype The parameter type for spline interpolation. See List of Parameter Types for Shape Interpolation.
Returns:
The point in world space.

Implements ShapeObject.

CoreExport Point3 TangentPiece3D ( TimeValue  t,
int  curve,
int  piece,
float  param,
int  ptype = PARAM_SIMPLE 
) [virtual]

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

Parameters:
t The time to evaluate the sub-curve.
curve The curve to evaluate.
piece The sub-curve (segment) to evaluate.
param The position along the curve to return where 0 is the start and 1 is the end.
ptype The parameter type for spline interpolation. See List of Parameter Types for Shape Interpolation.
Returns:
The tangent vector.

Implements ShapeObject.

CoreExport MtlID GetMatID ( TimeValue  t,
int  curve,
int  piece 
) [virtual]
Remarks:
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.

Reimplemented from ShapeObject.

BOOL CanMakeBezier ( ) [inline, virtual]

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

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

Reimplemented from ShapeObject.

{ return TRUE; }
CoreExport void MakeBezier ( TimeValue  t,
BezierShape shape 
) [virtual]

Creates the bezier representation of the shape.

Parameters:
t The time to convert.
shape The bezier representation is stored here.

Reimplemented from ShapeObject.

CoreExport ShapeHierarchy& OrganizeCurves ( TimeValue  t,
ShapeHierarchy hier = NULL 
) [virtual]

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:
t The time to organize the curves.
hier This class provides information about the hierarchy. See Class ShapeHierarchy.

Implements ShapeObject.

CoreExport void MakePolyShape ( TimeValue  t,
PolyShape shape,
int  steps = PSHAPE_BUILTIN_STEPS,
BOOL  optimize = FALSE 
) [virtual]

Create a PolyShape representation with optional fixed steps.

Parameters:
t The time to make the PolyShape.
shape The PolyShape representation is stored here.
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.
optimize If TRUE intermediate steps are removed from linear segments.

Implements ShapeObject.

CoreExport int MakeCap ( TimeValue  t,
MeshCapInfo capInfo,
int  capType 
) [virtual]

This method generates a mesh capping info for the shape.

Parameters:
t The time to create the cap info.
capInfo The cap info to update.
capType See Shape Capping Types.
Returns:
Nonzero if the cap info was generated; otherwise zero.

Implements ShapeObject.

CoreExport int MakeCap ( TimeValue  t,
PatchCapInfo capInfo 
) [virtual]

This method creates a patch cap info out of the shape.

Only implement this method if CanMakeBezier() returns TRUE.

Parameters:
t The time to create the cap info.
capInfo The cap info to update.
Returns:
Nonzero if the cap info was generated; otherwise zero.

Reimplemented from ShapeObject.

PolyShape& GetShape ( ) [inline]
Remarks:
Returns the shape data member.
{ return shape; }
CoreExport void SetPointFlags ( )
Remarks:
This method does the job of setting all points in the PolyShape to POLYPT_KNOT types, and removing the POLYPT_INTERPOLATED flag. This is because the LinearShape knows nothing about its origin.
CoreExport void DeleteThis ( ) [virtual]

Deletes an instance of this class.

3ds Max calls this method when it needs to delete a plugin object (an instance of a class derived from Animatable). Similarly, plugins that need to delete instances of an Animatable or a class directly derived from it via an Animatable pointer, should call this method instead of calling directly operator delete. Following these rules will ensure that the same memory manager is used to allocate and deallocate the object. The default implementation of this method deletes the object. Plugin instances that never need to be deleted from the heap can overwrite this method to do nothing.

Note:
See the method ClassDesc::Create() for details on how Max allocates plugin objects.
See ReferenceMaker::DeleteMe() and ReferenceTarget::MaybeAutoDelete() for information on how plugin instances are deleted by the system.
Remarks:
See Memory Allocation.

See also:
Plugin DLL Functions, Class ClassDesc.

Reimplemented from Animatable.

void FreeCaches ( ) [inline, virtual]
Remarks:
This is called to delete any item that can be rebuilt. For example, the procedural sphere object has a mesh that it caches. It could call Mesh::FreeAll() on the mesh from this method. This will free the vertex/face/uv arrays. If the sphere is ever evaluated again it can just rebuild the mesh. If an object (like a sphere) has modifiers applied to it, and those modifiers are not animated, then the result of the pipeline is cached in the node. So there is no reason for the sphere to also have a cache of its representation. Therefore when this method is called, the sphere can free the data of the mesh.
Default Implementation:
{}

Reimplemented from Animatable.

Class_ID ClassID ( ) [inline, virtual]

Retrieves a constant that uniquely identifies the plugin class.

This method must return the unique ID for the plugin class. If two ClassIDs conflict, the system will only load the first conflicting one it finds. A program (gencid.exe) is provided to generate unique class id values.

Returns:
A class id that uniquely identifies a plugin class
See also:
Class ClassID, List of Class IDs.

Reimplemented from Animatable.

{ return linearShapeClassID; }
CoreExport void GetClassName ( MSTR s ) [virtual]

Retrieves the name of the plugin class.

This name is usually used internally for debugging purposes. For Material plug-ins this method is used to put up the material "type" name in the Material Editor.

Parameters:
s Reference to a string filled in with the name of the plugin class

Reimplemented from ReferenceTarget.

void NotifyMe ( Animatable subAnim,
int  message 
) [inline]
{ UNUSED_PARAM(subAnim); UNUSED_PARAM(message);}
int IsKeyable ( ) [inline]
int Update ( TimeValue  t ) [inline]
{ UNUSED_PARAM(t); return 0; }
BOOL BypassTreeView ( ) [inline, virtual]
Remarks:
This method indicates to the system that this anim should not appear in the Track View. Note: Track View was formally referred to as Tree View. This is what parameter blocks do for example. They don't show up in track view, just their sub-anims do. This prevents the extra level of the parameter block from appearing.
Returns:
Return TRUE to not appear in the Track View. Note that if you return TRUE your children will appear in the track view regardless.
Default Implementation:
{ return FALSE; }

Reimplemented from Animatable.

{ return TRUE; }
CoreExport MCHAR* GetObjectName ( ) [virtual]
Returns:
the name that will appear in the history browser (modifier stack).

Reimplemented from BaseObject.

CoreExport IOResult Save ( ISave isave ) [virtual]

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 An interface for saving data. See Class ISave.

Reimplemented from ShapeObject.

CoreExport IOResult Load ( ILoad iload ) [virtual]

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 An interface for loading data. See Class ILoad.

Reimplemented from ShapeObject.

CoreExport void RescaleWorldUnits ( float  f ) [virtual]

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:
f The parameter to scale.

Reimplemented from ShapeObject.

CoreExport void InvalidateGeomCache ( ) [virtual]

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.

Reimplemented from ShapeObject.


Member Data Documentation


LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape
LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape LinearShape