Public Member Functions

MSShapeXtnd Class Reference

Search for all occurrences

#include <mxsPlugin.h>

Inheritance diagram for MSShapeXtnd:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  MSShapeXtnd (MSPluginClass *pc, BOOL loading)
  ~MSShapeXtnd ()
RefTargetHandle  Clone (RemapDir &remap)
  This method is used by 3ds Max to clone an object.
int  IsRenderable ()
  Indicates whether the object may be rendered.
Mesh GetRenderMesh (TimeValue t, INode *inode, View &view, BOOL &needDelete)
  This method should be implemented by all renderable GeomObjects.
void  InitNodeName (MSTR &s)
  This is the default name of the node when it is created.
SClass_ID  SuperClassID ()
  Retrieves a constant representing the type of the plugin.
int  IntersectRay (TimeValue t, Ray &ray, float &at, Point3 &norm)
  Computes the intersection point of the ray passed and the shape.
int  NumberOfVertices (TimeValue t, int curve=-1)
  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.
int  NumberOfCurves ()
  Returns the number of polygons in the shape.
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.
Point3  InterpCurve3D (TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE)
  This method returns a point interpolated on the entire curve.
Point3  TangentCurve3D (TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE)
  This method returns a tangent vector interpolated on the entire curve.
float  LengthOfCurve (TimeValue t, int curve)
  Returns the length of the specified curve.
int  NumberOfPieces (TimeValue t, int curve)
  Returns the number of sub-curves in a curve.
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).
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.
BOOL  CanMakeBezier ()
  This method is called to determine if the shape can be converted to a bezier representation.
void  MakeBezier (TimeValue t, BezierShape &shape)
  Creates the bezier representation of the shape.
ShapeHierarchy OrganizeCurves (TimeValue t, ShapeHierarchy *hier=NULL)
  This method is called to prepare the shape for lofting, extrusion, etc.
void  MakePolyShape (TimeValue t, PolyShape &shape, int steps=PSHAPE_BUILTIN_STEPS, BOOL optimize=FALSE)
  Create a PolyShape representation with optional fixed steps.
int  MakeCap (TimeValue t, MeshCapInfo &capInfo, int capType)
  This method generates a mesh capping info for the shape.
int  MakeCap (TimeValue t, PatchCapInfo &capInfo)
  This method creates a patch cap info out of the shape.
MtlID  GetMatID (TimeValue t, int curve, int piece)
  This method provides access to the material IDs of the shape.
BOOL  AttachShape (TimeValue t, INode *thisNode, INode *attachNode)
BOOL  HasUVW ()
  It is called to find out if the object is has UVW coordinates.
void  SetGenUVW (BOOL sw)
  This method is called to change the state of its Generate UVW boolean.
IOResult  Save (ISave *isave)
  Implemented by the System.
IOResult  Load (ILoad *iload)
  Implemented by the System.
Class_ID  PreferredCollapseType ()
  Implemented by the System.
BOOL  GetExtendedProperties (TimeValue t, MSTR &prop1Label, MSTR &prop1Data, MSTR &prop2Label, MSTR &prop2Data)
  Implemented by the System.
void  RescaleWorldUnits (float f)
  Implemented by the System.
Object MakeShallowCopy (ChannelMask channels)
  This method must make a copy of its "shell" and then shallow copy (see below) only the specified channels.
void  ShallowCopy (Object *fromOb, ChannelMask channels)
  This method copies the specified channels from the fromOb to this and copies the validity intervals.
ObjectState  Eval (TimeValue time)
  This method is called to evaluate the object and return the result as an ObjectState.

Constructor & Destructor Documentation

MSShapeXtnd ( MSPluginClass *  pc,
BOOL  loading 
)
~MSShapeXtnd ( ) [inline]

Member Function Documentation

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 MSPluginShape.

int IsRenderable ( ) [inline, virtual]

Indicates whether the object may be rendered.

Some objects such as construction grids and helpers should not be rendered and can return zero.

Returns:
Nonzero if the object may be rendered; otherwise 0.

Reimplemented from MSPluginShape.

{ return delegate->IsRenderable(); }        
Mesh* GetRenderMesh ( TimeValue  t,
INode inode,
View view,
BOOL &  needDelete 
) [inline, virtual]

This method should be implemented by all renderable GeomObjects.

It provides a mesh representation of the object for use by the renderer. Primitives that already have a mesh cached can just return a pointer to it (and set needDelete to FALSE). Implementations of this method which take a long time should periodically call View::CheckForRenderAbort() to see if the user has canceled the render. If canceled, the function can either return NULL, or return a non null pointer with the appropriate value for needDelete. (If needDelete is TRUE a non-null mesh will be deleted.)

Parameters:
t The time to get the mesh.
inode The node in the scene.
view If the renderer calls this method it will pass the view information here. See Class View.
needDelete Set to TRUE if the renderer should delete the mesh, FALSE otherwise.
Returns:
A pointer to the mesh object.

Reimplemented from MSPluginShape.

{ return delegate->GetRenderMesh(t, inode, view, needDelete); }
void InitNodeName ( MSTR s ) [inline, virtual]

This is the default name of the node when it is created.

Parameters:
s The default name of the node is stored here.

Reimplemented from MSObjectXtnd< ShapeObject, MSPluginShape >.

SClass_ID SuperClassID ( ) [inline, virtual]

Retrieves a constant representing the type of the plugin.

Returns:
A super class id that uniquely identifies the type (category) of the plugin. Note that several plugin classes can be of the same type, thus return the same super class id. Plugins are uniquely identified by their class ids. List of Super Class IDs.
See also:
SClass_ID

Reimplemented from MSPluginShape.

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

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

Note:
This method has a default implementation and it is not necessary to define this method in classes derived from ShapeObject.
Parameters:
t The time to compute the intersection.
ray Ray to intersect.
at The point of intersection.
norm The surface normal at the point of intersection.
Returns:
Nonzero if a point of intersection was found; otherwise 0.

Reimplemented from MSObjectXtnd< ShapeObject, MSPluginShape >.

{ return delegate->IntersectRay(t, ray, at, norm); }
int NumberOfVertices ( TimeValue  t,
int  curve = -1 
) [inline, 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 MSPluginShape.

{ return delegate->NumberOfVertices(t, curve); }    
int NumberOfCurves ( ) [inline, virtual]

Returns the number of polygons in the shape.

Reimplemented from MSPluginShape.

{ return delegate->NumberOfCurves(); }                 
BOOL CurveClosed ( TimeValue  t,
int  curve 
) [inline, 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.

Reimplemented from MSPluginShape.

{ return delegate->CurveClosed(t, curve); }     
Point3 InterpCurve3D ( TimeValue  t,
int  curve,
float  param,
int  ptype = PARAM_SIMPLE 
) [inline, 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.

Reimplemented from MSPluginShape.

{ return delegate->InterpCurve3D(t, curve, param, ptype); }    
Point3 TangentCurve3D ( TimeValue  t,
int  curve,
float  param,
int  ptype = PARAM_SIMPLE 
) [inline, 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

Reimplemented from MSPluginShape.

{ return delegate->TangentCurve3D(t, curve, param, ptype); }    
float LengthOfCurve ( TimeValue  t,
int  curve 
) [inline, 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.

Reimplemented from MSPluginShape.

{ return delegate->LengthOfCurve(t, curve); }  
int NumberOfPieces ( TimeValue  t,
int  curve 
) [inline, virtual]

Returns the number of sub-curves in a curve.

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

Reimplemented from MSPluginShape.

{ return delegate->NumberOfPieces(t, curve); }   
Point3 InterpPiece3D ( TimeValue  t,
int  curve,
int  piece,
float  param,
int  ptype = PARAM_SIMPLE 
) [inline, 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.

Reimplemented from MSPluginShape.

{ return delegate->InterpPiece3D(t, curve, piece, param, ptype); }  
Point3 TangentPiece3D ( TimeValue  t,
int  curve,
int  piece,
float  param,
int  ptype = PARAM_SIMPLE 
) [inline, 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.

Reimplemented from MSPluginShape.

{ return delegate->TangentPiece3D(t, curve, piece, param, ptype); }         
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 MSPluginShape.

{ return delegate->CanMakeBezier(); }                  
void MakeBezier ( TimeValue  t,
BezierShape shape 
) [inline, virtual]

Creates the bezier representation of the shape.

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

Reimplemented from MSPluginShape.

{ delegate->MakeBezier(t, shape); }     
ShapeHierarchy& OrganizeCurves ( TimeValue  t,
ShapeHierarchy hier = NULL 
) [inline, 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.

Reimplemented from MSPluginShape.

{ return delegate->OrganizeCurves(t, hier); }       
void MakePolyShape ( TimeValue  t,
PolyShape shape,
int  steps = PSHAPE_BUILTIN_STEPS,
BOOL  optimize = FALSE 
) [inline, 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.

Reimplemented from MSPluginShape.

{ delegate->MakePolyShape(t, shape, steps, optimize); } 
int MakeCap ( TimeValue  t,
MeshCapInfo capInfo,
int  capType 
) [inline, 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.

Reimplemented from MSPluginShape.

{ return delegate->MakeCap(t, capInfo, capType); }  
int MakeCap ( TimeValue  t,
PatchCapInfo capInfo 
) [inline, 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 MSPluginShape.

{ return delegate->MakeCap(t, capInfo); }   
MtlID GetMatID ( TimeValue  t,
int  curve,
int  piece 
) [inline, virtual]

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:
t The time to evaluate the sub-curve.
curve The zero based index of the curve to evaluate.
piece The sub-curve (segment) to evaluate.

Reimplemented from MSPluginShape.

{ return delegate->GetMatID(t, curve, piece); }
BOOL AttachShape ( TimeValue  t,
INode thisNode,
INode attachNode 
) [inline]

Reimplemented from MSPluginShape.

{ return delegate->AttachShape(t, thisNode, attachNode); }  // Return TRUE if attached
BOOL HasUVW ( ) [inline, virtual]

It is called to find out if the object is has UVW coordinates.

This method returns TRUE if the object has UVW coordinates; otherwise FALSE. In 3ds Max 2.0 and later there is code in the renderer that will automatically turn on the UVW coordinates of the base object if UV's are missing (and needed). The base object has to implement two simple methods to make this work: HasUVW() and SetGenUVW(). Developers are encouraged to put these methods in their objects: it makes using the program easier for the user. If they are not implemented, it doesn't cause any real harm: it will just operate as before and put up the missing UVW's message. Here is how the procedural sphere implements these methods:

    BOOL SphereObject::GetGenUVW()
    {
        BOOL genUVs;
        Interval v;
        pblock->GetValue(PB_GENUVS, 0, genUVs, v);
        return genUVs;
    }
    
    void SphereObject::SetGenUVW(BOOL sw)
    {
        if (sw==GetGenUVW()) return;
        pblock->SetValue(PB_GENUVS,0, sw);
    }

Important Note: The pblock->SetValue() will cause a call to NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_CHANGE), which will invalidate the UVW cache. It is essential that this call be made, so if the 'generate UVW' boolean is not handled by a parameter block, then NotifyDependents() needs to be called explicitly. Also Note: For "modifiable objects" that pass up the pipeline getting modified, such as TriObject, EditTriObject, etc., which cannot generate their own UVWs, but can carry them in their data structures, only this HasUVW() method needs to be implemented. For example, here is the implementation for TriObject: BOOL TriObject::HasUVW() { return mesh.tvFace?1:0; }

Reimplemented from MSObjectXtnd< ShapeObject, MSPluginShape >.

{ return delegate->HasUVW(); }
void SetGenUVW ( BOOL  sw ) [inline, virtual]

This method is called to change the state of its Generate UVW boolean.

If the state changes, the object must send a REFMSG_CHANGE up the pipeline by calling NotifyDependents(). This applies to map channel 1.

Parameters:
sw The new state for the generate UVW flag.

Reimplemented from MSObjectXtnd< ShapeObject, MSPluginShape >.

{ delegate->SetGenUVW(sw); }
IOResult Save ( ISave isave ) [inline, 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 MSPluginShape.

{ MSPlugin::Save(isave); return ShapeObject::Save(isave); }
IOResult Load ( ILoad iload ) [inline, 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 MSPluginShape.

{  MSPlugin::Load(iload); return ShapeObject::Load(iload); }
Class_ID PreferredCollapseType ( ) [inline, virtual]

Implemented by the System.

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

Reimplemented from MSPluginShape.

BOOL GetExtendedProperties ( TimeValue  t,
MSTR prop1Label,
MSTR prop1Data,
MSTR prop2Label,
MSTR prop2Data 
) [inline, virtual]

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.

Reimplemented from MSPluginShape.

                        { return delegate->GetExtendedProperties(t, prop1Label, prop1Data, prop2Label, prop2Data); }
void RescaleWorldUnits ( float  f ) [inline, 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 MSPluginShape.

Object* MakeShallowCopy ( ChannelMask  channels ) [inline, 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.

{ return delegate->MakeShallowCopy(channels); }
void ShallowCopy ( Object fromOb,
ChannelMask  channels 
) [inline, 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.

{ delegate->ShallowCopy(fromOb, channels); }
ObjectState Eval ( TimeValue  t ) [inline, 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); }

Reimplemented from MSObjectXtnd< ShapeObject, MSPluginShape >.

{ delegate->Eval(time); return ObjectState(this); }

MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd
MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd MSShapeXtnd