#include <mxsPlugin.h>
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. |
MSShapeXtnd | ( | MSPluginClass * | pc, |
BOOL | loading | ||
) |
~MSShapeXtnd | ( | ) | [inline] |
{ DeleteAllRefsFromMe(); }
RefTargetHandle Clone | ( | RemapDir & | remap | ) | [virtual] |
This method is used by 3ds Max to clone an object.
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
remap | - A RemapDir instance used for remapping references during a Clone. |
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.
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.)
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. |
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.
s | The default name of the node is stored here. |
Reimplemented from MSObjectXtnd< ShapeObject, MSPluginShape >.
{ delegate->InitNodeName(s); }
SClass_ID SuperClassID | ( | ) | [inline, virtual] |
Retrieves a constant representing the type of the plugin.
Reimplemented from MSPluginShape.
{ return delegate ? delegate->SuperClassID() : MSPluginShape::SuperClassID(); }
Computes the intersection point of the ray passed and the shape.
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. |
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.
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.
t | The time to check. |
curve | The index of the curve to check. |
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().
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. |
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().
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. |
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(); }
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.
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.
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. |
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.
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. |
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.
Reimplemented from MSPluginShape.
{ return delegate->CanMakeBezier(); }
void MakeBezier | ( | TimeValue | t, |
BezierShape & | shape | ||
) | [inline, virtual] |
Creates the bezier representation of the shape.
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.
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.
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.
t | The time to create the cap info. |
capInfo | The cap info to update. |
capType | See Shape Capping Types. |
Reimplemented from MSPluginShape.
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.
t | The time to create the cap info. |
capInfo | The cap info to update. |
Reimplemented from MSPluginShape.
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;
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.
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 >.
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.
sw | The new state for the generate UVW flag. |
Reimplemented from MSObjectXtnd< ShapeObject, MSPluginShape >.
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.
isave | An interface for saving data. See Class ISave. |
Reimplemented from MSPluginShape.
{ MSPlugin::Save(isave); return ShapeObject::Save(isave); }
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.
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.
{ return delegate->PreferredCollapseType(); }
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.
f | The parameter to scale. |
Reimplemented from MSPluginShape.
{ delegate->RescaleWorldUnits(f); }
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.
channels | The channels to copy. |
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.
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.
t | Specifies the time to evaluate the object. |
{ return ObjectState(this); }
Reimplemented from MSObjectXtnd< ShapeObject, MSPluginShape >.
{ delegate->Eval(time); return ObjectState(this); }