#include <mxsPlugin.h>
Public Member Functions |
|
MSSimpleObjectXtnd (MSPluginClass *pc, BOOL loading) | |
~MSSimpleObjectXtnd () | |
void | DeleteThis () |
ReferenceTarget * | get_delegate () |
void | GetClassName (MSTR &s) |
Retrieves the name of the plugin class.
|
|
Class_ID | ClassID () |
Retrieves a constant that uniquely
identifies the plugin class. |
|
void | FreeCaches () |
int | NumSubs () |
Animatable * | SubAnim (int i) |
MSTR | SubAnimName (int i) |
int | NumParamBlocks () |
IParamBlock2 * | GetParamBlock (int i) |
IParamBlock2 * | GetParamBlockByID (BlockID id) |
void * | GetInterface (ULONG id) |
Inherited from Animatable. |
|
int | NumRefs () |
Returns the total number of references this
ReferenceMaker can hold. |
|
RefTargetHandle | GetReference (int i) |
Returns the 'i-th' reference. |
|
RefTargetHandle | Clone (RemapDir &remap) |
This method is used by 3ds Max to clone an
object. |
|
MCHAR * | GetObjectName () |
void | BeginEditParams (IObjParam *ip, ULONG flags, Animatable *prev) |
void | EndEditParams (IObjParam *ip, ULONG flags, Animatable *next) |
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. |
|
int | Display (TimeValue t, INode *inode, ViewExp *vpt, int flags) |
This is called by the system to have the
item display itself (perform a quick render in viewport, using the
current TM). |
|
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). |
|
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. |
|
void | Snap (TimeValue t, INode *inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) |
Checks the point passed for a snap and
updates the SnapInfo
structure. |
|
CreateMouseCallBack * | GetCreateMouseCallBack () |
This method allows the system to retrieve a
callback object used in creating an object in the 3D viewports.
|
|
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. |
|
ObjectState | Eval (TimeValue time) |
This method is called to evaluate the object
and return the result as an
ObjectState. |
|
void | InitNodeName (MSTR &s) |
This is the default name of the node when it
is created. |
|
Interval | ObjectValidity (TimeValue t) |
This method returns the validity interval of
the object as a whole at the specified time. |
|
int | CanConvertToType (Class_ID obtype) |
Indicates whether the object can be
converted to the specified type. |
|
Object * | ConvertToType (TimeValue t, Class_ID obtype) |
This method converts this object to the type
specified and returns a pointer it. |
|
void | GetCollapseTypes (Tab< Class_ID > &clist, Tab< MSTR * > &nlist) |
When the user clicks on the Edit Stack button in the modify
branch a list of 'Convert To:' types is presented. |
|
void | GetDeformBBox (TimeValue t, Box3 &box, Matrix3 *tm, BOOL useSel) |
This method computes the bounding box in the
objects local coordinates or the optional space defined by tm.
|
|
int | IntersectRay (TimeValue t, Ray &r, float &at, Point3 &norm) |
This method is called to compute the
intersection point and surface normal at this intersection point of
the ray passed and the object. |
|
void | BuildMesh (TimeValue t) |
BOOL | OKtoDisplay (TimeValue t) |
void | InvalidateUI () |
ParamDimension * | GetParameterDim (int pbIndex) |
MSTR | GetParameterName (int pbIndex) |
Public Attributes |
|
SimpleObject * | delegate |
Protected Member Functions |
|
virtual void | SetReference (int i, RefTargetHandle rtarg) |
Stores a
ReferenceTarget as its 'i-th' reference`. |
MSSimpleObjectXtnd | ( | MSPluginClass * | pc, |
BOOL | loading | ||
) |
~MSSimpleObjectXtnd | ( | ) | [inline] |
{ DeleteAllRefsFromMe(); }
void DeleteThis | ( | ) |
Reimplemented from MSPluginSimpleObject.
ReferenceTarget* get_delegate | ( | ) | [inline, virtual] |
void GetClassName | ( | MSTR & | s | ) | [inline, 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.
s | Reference to a string filled in with the name of the plugin class |
Reimplemented from MSPluginSimpleObject.
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.
Reimplemented from MSPluginSimpleObject.
{ return pc->class_id; }
void FreeCaches | ( | ) | [inline, virtual] |
Reimplemented from SimpleObject.
{ delegate->FreeCaches(); }
int NumSubs | ( | ) | [inline, virtual] |
Reimplemented from MSPluginSimpleObject.
Animatable* SubAnim | ( | int | i | ) | [inline, virtual] |
i | This is the index of the sub-anim to return. |
Reimplemented from MSPluginSimpleObject.
MSTR SubAnimName | ( | int | i | ) | [inline, virtual] |
i | The index of the parameter name to return |
Reimplemented from MSPluginSimpleObject.
{ if (i == 0) return delegate->GetObjectName(); else return pblocks[i-1]->GetLocalName(); }
int NumParamBlocks | ( | ) | [inline, virtual] |
Reimplemented from MSPluginSimpleObject.
IParamBlock2* GetParamBlock | ( | int | i | ) | [inline, virtual] |
i | The zero based index of the ParamBlock2 to return. |
Reimplemented from MSPluginSimpleObject.
{ return pblocks[i]; }
IParamBlock2* GetParamBlockByID | ( | BlockID | id | ) | [inline] |
Reimplemented from MSPluginSimpleObject.
{ return MSPlugin::GetParamBlockByID(id); }
void* GetInterface | ( | ULONG | id | ) | [inline, virtual] |
Inherited from Animatable.
Returns a pointer to the interface.
id | - The id of the interface. |
Reimplemented from MSPluginSimpleObject.
{ if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return MSPluginSimpleObject::GetInterface(id); }
int NumRefs | ( | ) | [virtual] |
Returns the total number of references this ReferenceMaker can hold.
The plugin implements this method to indicate the total number of of references it can make. This includes all references whether they are NULL (inactive) or non-NULL (active) at the time when this method is called. A plugin can hold a variable number of references, thus the return value of this method is not to be cached and reused by client code.
Reimplemented from MSPluginSimpleObject.
RefTargetHandle GetReference | ( | int | i | ) | [virtual] |
Returns the 'i-th' reference.
The plugin implements this method to return its 'i-th' reference. The plug-in simply keeps track of its references using an integer index for each one. This method is normally called by the system.
i | - The index of the reference to retrieve. Valid values are from 0 to NumRefs()-1. |
Reimplemented from MSPluginSimpleObject.
virtual void SetReference | ( | int | i, |
RefTargetHandle | rtarg | ||
) | [protected, virtual] |
Stores a ReferenceTarget as its 'i-th' reference`.
The plugin implements this method to store the reference handle passed to it as its 'i-th' reference. In its implementation of this method, the plugin should simply assign the reference handle passed in as a parameter to the member variable that holds the 'i-th' reference. Other reference handling methods such as ReferenceMaker::DeleteReference(), or ReferenceMaker::ReplaceReference() should not be called from within this method. The plugin itself or other plugins should not call this method directly. The system will call this method when a new reference is created or an existing one is replaced by calling ReferenceMaker::ReplaceReference().
i | - The index of the reference to store. Valid values are from 0 to NumRefs()-1. |
rtarg | - The reference handle to store. |
Reimplemented from MSPluginSimpleObject.
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 MSPluginSimpleObject.
MCHAR* GetObjectName | ( | ) | [inline, virtual] |
Reimplemented from MSPluginSimpleObject.
{ return pc->class_name->to_string(); }
void BeginEditParams | ( | IObjParam * | ip, |
ULONG | flags, | ||
Animatable * | prev | ||
) | [virtual] |
ip | Interface pointer. The developer can use it to call methods such as AddRollupPage(). Note that this pointer is only valid between BeginEditParams() and EndEditParams(). It should not be used outside this interval. |
flags | Describe which branch of the command panel or dialog the item
is being edited in. The following are possible values: BEGIN_EDIT_CREATE Indicates an item is being edited in the create branch. BEGIN_EDIT_MOTION Indicates a controller is being edited in the motion branch. BEGIN_EDIT_HIERARCHY Indicates a controller is being edited in the Pivot subtask of the hierarchy branch. BEGIN_EDIT_IK Indicates a controller is being edited in the IK subtask of the hierarchy branch. BEGIN_EDIT_LINKINFO Indicates a controller is being edited in the Link Info subtask of the hierarchy branch. |
prev | Pointer to an Animatable object. This parameter may be used in the motion and hierarchy branches of the command panel. This pointer allows a plug-in to look at the ClassID of the previous item that was being edited, and if it is the same as this item, to not replace the entire UI in the command panel, but simply update the values displayed in the UI fields. This prevents the UI from 'flickering' when the current item begins its edit. For example, if you are in the motion branch and are looking at an item's PRS controller values, and then select another item that is displayed with a PRS controller, the UI will not change - only the values displayed in the fields will change. If however you selected a target camera that has a lookat controller (not a PRS controller) the UI will change because a different set of parameters need to be displayed. Note that for items that are edited in the modifier branch this field can be ignored. |
Reimplemented from MSPluginSimpleObject.
void EndEditParams | ( | IObjParam * | ip, |
ULONG | flags, | ||
Animatable * | next | ||
) | [virtual] |
ip | An interface pointer. The developer may use the interface
pointer to call methods such as
DeleteRollupPage(). |
flags | The following flag may be set: END_EDIT_REMOVEUI If TRUE, the item's user interface should be removed. |
next | Animatable pointer. Can be used in the motion and hierarchy branches of the command panel. It allows a plug-in to look at the ClassID of the next item that was being edited, and if it is the same as this item, to not replace the entire UI in the command panel. Note that for items that are edited in the modifier branch this field can be ignored. |
Reimplemented from MSPluginSimpleObject.
int HitTest | ( | TimeValue | t, |
INode * | inode, | ||
int | type, | ||
int | crossing, | ||
int | flags, | ||
IPoint2 * | p, | ||
ViewExp * | vpt | ||
) | [inline, 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.
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. |
Reimplemented from SimpleObject.
This is called by the system to have the item display itself (perform a quick render in viewport, using the current TM).
Note: For this method to be called the object's validity interval must be invalid at the specified time t. If the interval is valid, the system may not call this method since it thinks the display is already valid.
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. |
Reimplemented from SimpleObject.
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.
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 SimpleObject.
{ delegate->GetWorldBoundBox(t, inode, vpt, box); }
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.
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 SimpleObject.
{ delegate->GetLocalBoundBox(t, inode, vpt, box ); }
void Snap | ( | TimeValue | t, |
INode * | inode, | ||
SnapInfo * | snap, | ||
IPoint2 * | p, | ||
ViewExp * | vpt | ||
) | [inline, virtual] |
Checks the point passed for a snap and updates the SnapInfo structure.
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 SimpleObject.
CreateMouseCallBack* GetCreateMouseCallBack | ( | ) | [inline, 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.
Reimplemented from MSPluginSimpleObject.
{ return delegate->GetCreateMouseCallBack(); }
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 MSPluginSimpleObject.
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 MSPluginSimpleObject.
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.
t | Specifies the time to evaluate the object. |
{ return ObjectState(this); }
Reimplemented from SimpleObject.
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 SimpleObject.
{s = GetObjectName();}
Interval ObjectValidity | ( | TimeValue | t | ) | [virtual] |
This method returns the validity interval of the object as a whole at the specified time.
t | The time to compute the validity interval. |
Reimplemented from SimpleObject.
int CanConvertToType | ( | Class_ID | obtype | ) | [inline, 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().
obtype | The Class_ID of the type of object to convert to. See Class Class_ID, List of Class_IDs. |
Reimplemented from SimpleObject.
{ return delegate->CanConvertToType(obtype); }
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.
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); }
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. |
// 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 SimpleObject.
{ // CAL-10/1/2002: Don't return the delegate, because it might be deleted. // Return a copy of the delegate instead. (422964) Object* obj = delegate->ConvertToType(t, obtype); if (obj == delegate) obj = delegate->MakeShallowCopy(OBJ_CHANNELS); return obj; }
When the user clicks on the Edit Stack button in the modify branch a list of 'Convert To:' types is presented.
The use may click on one of these choices to collapse the object into one of these types (for instance, an Editable Mesh or an Editable NURBS object). This method returns a list of Class_IDs and descriptive strings that specify the allowable types of objects that this object may be collapsed into. Note: Most plug-ins call the base class method in Object in their implementation of this method. The base class implementation provided by Object checks if the object can convert to both an editable mesh and an editable spline. If it can, these are added to the allowable types.
clist | The table of allowable Class_IDs. |
nlist | The table of pointers to strings that correspond to the table of Class_IDs above. |
void SphereObject::GetCollapseTypes(Tab<Class_ID> &clist,Tab<MSTR*>&nlist) { Object::GetCollapseTypes(clist, nlist); Class_ID id = EDITABLE_SURF_CLASS_ID; MSTR *name = new MSTR(GetString(IDS_SM_NURBS_SURFACE)); clist.Append(1,&id); nlist.Append(1,&name); }
Reimplemented from Object.
{ delegate->GetCollapseTypes(clist, nlist); }
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.
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 SimpleObject.
{ delegate->GetDeformBBox(t, box, tm, useSel); }
This method is called to compute the intersection point and surface normal at this intersection point of the ray passed and the object.
t | The time to compute the intersection. |
r | Ray to intersect. See Class Ray. |
at | The point of intersection. |
norm | Surface normal at the point of intersection. |
Reimplemented from SimpleObject.
{ return delegate->IntersectRay(t, r, at, norm); }
void BuildMesh | ( | TimeValue | t | ) | [inline, virtual] |
Reimplemented from MSPluginSimpleObject.
BOOL OKtoDisplay | ( | TimeValue | t | ) | [inline, virtual] |
Reimplemented from MSPluginSimpleObject.
{ return delegate->OKtoDisplay(t); }
void InvalidateUI | ( | ) | [inline, virtual] |
pmapParam->Invalidate();
void foo(IObjParam* ip, IParamBlock* pblock) { float newval; Interval valid = FOREVER; TimeValue t = ip->GetTime(); // Get the value from the parameter block at the current time. pblock->GetValue( PB_ANGLE, t, newval, valid ); // Set the value. Note that the notify argument is passed as FALSE. // This ensures no messages are sent when the value changes. angleSpin->SetValue( newval, FALSE ); }
Reimplemented from MSPluginSimpleObject.
{ delegate->InvalidateUI(); }
ParamDimension* GetParameterDim | ( | int | pbIndex | ) | [inline, virtual] |
Reimplemented from SimpleObject.
{ return delegate->GetParameterDim(pbIndex); }
MSTR GetParameterName | ( | int | pbIndex | ) | [inline, virtual] |
Reimplemented from SimpleObject.
{ return delegate->GetParameterName(pbIndex); }