This reference page is linked to from the following overview topics: Lesson 5: Geometric Objects, Handling Requests for Interfaces, How Objects are Drawn in the Viewport, Animatables and Sub-Animatables, Hit Testing, Creating the Mesh, Converting Objects to Compatible Types, Displaying the Object in the Viewport.
#include <simpobj.h>
Public Member Functions |
|
CoreExport | SimpleObject () |
CoreExport | ~SimpleObject () |
CoreExport void | UpdateMesh (TimeValue t) |
CoreExport void | GetBBox (TimeValue t, Matrix3 &tm, Box3 &box) |
void | MeshInvalid () |
virtual CoreExport bool | RequiresSupportForLegacyDisplayMode () const |
virtual CoreExport bool | UpdateDisplay (unsigned long renderItemCategories, const MaxSDK::Graphics::MaterialRequiredStreams &materialRequiredStreams, TimeValue t) |
CoreExport void | BeginEditParams (IObjParam *ip, ULONG flags, Animatable *prev) |
CoreExport void | EndEditParams (IObjParam *ip, ULONG flags, Animatable *next) |
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 is called by the system to have the
item display itself (perform a quick render in viewport, using the
current TM). |
|
CoreExport IParamArray * | GetParamBlock () |
An object or modifier should implement this
method if it wishes to make its parameter block available for other
plug-ins to access it. |
|
CoreExport int | GetParamBlockIndex (int id) |
If a plug-in makes its parameter block
available (using
GetParamBlock()) then it will need to provide #defines for
indices into the parameter block. |
|
CoreExport 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. |
|
CoreExport Interval | ObjectValidity (TimeValue t) |
This method returns the validity interval of
the object as a whole at the specified time. |
|
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 BOOL | PolygonCount (TimeValue t, int &numFaces, int &numVerts) |
Retreives the number of faces and vertices
of the polyginal mesh representation of this object. |
|
CoreExport int | IntersectRay (TimeValue t, Ray &ray, 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. |
|
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 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.
|
|
CoreExport Mesh * | GetRenderMesh (TimeValue t, INode *inode, View &view, BOOL &needDelete) |
This method should be implemented by all
renderable GeomObjects. |
|
CoreExport void | FreeCaches () |
void | GetClassName (MSTR &s) |
Retrieves the name of the plugin class.
|
|
int | NumSubs () |
Animatable * | SubAnim (int i) |
CoreExport MSTR | SubAnimName (int i) |
virtual CoreExport BaseInterface * | GetInterface (Interface_ID iid) |
Inherited from Animatable. |
|
CoreExport 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. |
|
CoreExport RefResult | NotifyRefChanged (Interval changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message) |
Receives and responds to messages. |
|
virtual void | BuildMesh (TimeValue t)=0 |
virtual BOOL | OKtoDisplay (TimeValue t) |
virtual void | InvalidateUI () |
virtual ParamDimension * | GetParameterDim (int pbIndex) |
virtual MSTR | GetParameterName (int pbIndex) |
Public Attributes |
|
IParamBlock * | pblock |
Mesh | mesh |
Interval | ivalid |
BOOL | suspendSnap |
Static Public Attributes |
|
static SimpleObject * | editOb |
Protected Member Functions |
|
virtual void | SetReference (int i, RefTargetHandle rtarg) |
Stores a
ReferenceTarget as its 'i-th' reference`. |
CoreExport SimpleObject | ( | ) |
CoreExport ~SimpleObject | ( | ) |
CoreExport void UpdateMesh | ( | TimeValue | t | ) |
void MeshInvalid | ( | ) | [inline] |
virtual CoreExport bool RequiresSupportForLegacyDisplayMode | ( | ) | const [virtual] |
Reimplemented from BaseObject.
virtual CoreExport bool UpdateDisplay | ( | unsigned long | renderItemCategories, |
const MaxSDK::Graphics::MaterialRequiredStreams & | materialRequiredStreams, | ||
TimeValue | t | ||
) | [virtual] |
Reimplemented from BaseObject.
CoreExport 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 Animatable.
Reimplemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
CoreExport 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 Animatable.
Reimplemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
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.
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 BaseObject.
Reimplemented in MSSimpleObjectXtnd.
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.
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.
Reimplemented in MSSimpleObjectXtnd.
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 BaseObject.
Reimplemented in MSSimpleObjectXtnd.
CoreExport IParamArray* GetParamBlock | ( | ) | [virtual] |
An object or modifier should implement this method if it wishes to make its parameter block available for other plug-ins to access it.
The system itself doesn't actually call this method. This method is optional.
Reimplemented from BaseObject.
CoreExport int GetParamBlockIndex | ( | int | id | ) | [virtual] |
If a plug-in makes its parameter block available (using GetParamBlock()) then it will need to provide #defines for indices into the parameter block.
These defines should not be directly used with the parameter block but instead converted by this function that the plug-in implements. This way if a parameter moves around in a future version of the plug-in the #define can be remapped. A return value of -1 indicates an invalid parameter id.
id | The parameter block id. See Parameter Block IDs. |
Reimplemented from BaseObject.
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.
t | Specifies the time to evaluate the object. |
{ return ObjectState(this); }
Implements Object.
Reimplemented in MSSimpleObjectXtnd.
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 GeomObject.
Reimplemented in MSSimpleObjectXtnd.
{s = GetObjectName();}
CoreExport 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 Object.
Reimplemented in MSSimpleObjectXtnd.
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().
obtype | The Class_ID of the type of object to convert to. See Class Class_ID, List of Class_IDs. |
Reimplemented from Object.
Reimplemented in MSSimpleObjectXtnd.
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 Object.
Reimplemented in MSSimpleObjectXtnd.
CoreExport BOOL PolygonCount | ( | TimeValue | t, |
int & | numFaces, | ||
int & | numVerts | ||
) | [virtual] |
Retreives the number of faces and vertices of the polyginal mesh representation of this object.
If this method returns FALSE then this functionality is not supported. Note: Plug-In developers should use the global function GetPolygonCount(Object*, int&, int&) to retrieve the number f vertices and faces in an arbitrary object.
t | The time at which to compute the number of faces and vertices. |
numFaces | The number of faces is returned here. |
numVerts | The number of vertices is returned here. |
Reimplemented from Object.
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 Object.
Reimplemented in MSSimpleObjectXtnd.
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 BaseObject.
Reimplemented in MSSimpleObjectXtnd.
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 BaseObject.
Reimplemented in MSSimpleObjectXtnd.
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 Object.
Reimplemented in MSSimpleObjectXtnd.
CoreExport Mesh* GetRenderMesh | ( | TimeValue | t, |
INode * | inode, | ||
View & | view, | ||
BOOL & | needDelete | ||
) | [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 GeomObject.
CoreExport void FreeCaches | ( | ) | [virtual] |
Reimplemented from Animatable.
Reimplemented in MSSimpleObjectXtnd.
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 ReferenceTarget.
Reimplemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
{s = GetObjectName();}
int NumSubs | ( | ) | [inline, virtual] |
Reimplemented from Animatable.
Reimplemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
{ return 1; }
Animatable* SubAnim | ( | int | i | ) | [inline, virtual] |
i | This is the index of the sub-anim to return. |
Reimplemented from Animatable.
Reimplemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
{ return (Animatable*)pblock; }
CoreExport MSTR SubAnimName | ( | int | i | ) | [virtual] |
i | The index of the parameter name to return |
Reimplemented from Animatable.
Reimplemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
virtual CoreExport BaseInterface* GetInterface | ( | Interface_ID | id | ) | [virtual] |
Inherited from Animatable.
Returns a pointer to the Base Interface for the interface ID passed.
id | - The unique ID of the interface to get |
Reimplemented from Object.
CoreExport void* GetInterface | ( | ULONG | id | ) | [virtual] |
Inherited from Animatable.
Returns a pointer to the interface.
id | - The id of the interface. |
Reimplemented from Object.
Reimplemented in PodObj, MSPluginSimpleObject, and MSSimpleObjectXtnd.
int NumRefs | ( | ) | [inline, 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 ReferenceMaker.
Reimplemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
{return 1;}
RefTargetHandle GetReference | ( | int | i | ) | [inline, 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 ReferenceMaker.
Reimplemented in SimpleObject2, MSPluginSimpleObject, and MSSimpleObjectXtnd.
{return (RefTargetHandle)pblock;}
virtual void SetReference | ( | int | i, |
RefTargetHandle | rtarg | ||
) | [inline, 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 ReferenceMaker.
Reimplemented in SimpleObject2, MSPluginSimpleObject, and MSSimpleObjectXtnd.
{pblock=(IParamBlock*)rtarg;}
CoreExport RefResult NotifyRefChanged | ( | Interval | changeInt, |
RefTargetHandle | hTarget, | ||
PartID & | partID, | ||
RefMessage | message | ||
) | [virtual] |
Receives and responds to messages.
A plugin which makes references must implement a method to receive and respond to messages broadcast by its dependents. This is done by implementing NotifyRefChanged(). The plugin developer usually implements this method as a switch statement where each case is one of the messages the plugin needs to respond to. The Method StdNotifyRefChanged calls this, which can change the partID to new value. If it doesn't depend on the particular message& partID, it should return REF_DONTCARE.
changeInt | - This is the interval of time over which the message is active. Currently, all plug-ins will receive FOREVER for this interval. |
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 List of Reference Messages for more information about the meaning of the partID for some common messages. |
message | - The message parameters passed into this method is the specific message which needs to be handled. |
Implements ReferenceMaker.
Reimplemented in MSPluginSimpleObject.
virtual void BuildMesh | ( | TimeValue | t | ) | [pure virtual] |
Implemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
virtual BOOL OKtoDisplay | ( | TimeValue | t | ) | [inline, virtual] |
Reimplemented in MSPluginSimpleObject, and MSSimpleObjectXtnd.
{return TRUE;}
virtual 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 in MSPluginSimpleObject, and MSSimpleObjectXtnd.
{}
virtual ParamDimension* GetParameterDim | ( | int | pbIndex | ) | [inline, virtual] |
Reimplemented in MSSimpleObjectXtnd.
{return defaultDim;}
virtual MSTR GetParameterName | ( | int | pbIndex | ) | [inline, virtual] |
Reimplemented in MSSimpleObjectXtnd.
{return MSTR(_M("Parameter"));}
SimpleObject* editOb
[static] |