📄 object.h
字号:
/**********************************************************************
*<
FILE: object.h
DESCRIPTION: Defines Object Classes
CREATED BY: Dan Silva
HISTORY: created 9 September 1994
*> Copyright (c) 1994, All Rights Reserved.
**********************************************************************/
#ifndef _OBJECT_
#define _OBJECT_
#include "inode.h"
#include "maxapi.h"
#include "plugapi.h"
#include "snap.h"
#include "genshape.h"
#include <hitdata.h>
#include "imtl.h"
typedef short MtlIndex;
typedef short TextMapIndex;
CoreExport void setHitType(int t);
CoreExport int getHitType(void);
CoreExport BOOL doingXORDraw(void);
// Hit test types:
#define HITTYPE_POINT 1
#define HITTYPE_BOX 2
#define HITTYPE_CIRCLE 3
#define HITTYPE_SOLID 4
#define HITTYPE_FENCE 5
// Flags for hit test.
#define HIT_SELONLY (1<<0)
#define HIT_UNSELONLY (1<<2)
#define HIT_ABORTONHIT (1<<3)
#define HIT_SELSOLID (1<<4)
#define HIT_ANYSOLID (1<<5)
#define HIT_TRANSFORMGIZMO (1<<6) // CCJ - 06/29/98 - Hittest transform gizmo
#define HIT_SWITCH_GIZMO (1<<7) // CCJ - 06/29/98 - Switch axis when hit
// These are filters for hit testing. They also
// are combined into the flags parameter.
#define HITFLTR_ALL (1<<10)
#define HITFLTR_OBJECTS (1<<11)
#define HITFLTR_CAMERAS (1<<12)
#define HITFLTR_LIGHTS (1<<13)
#define HITFLTR_HELPERS (1<<14)
#define HITFLTR_WSMOBJECTS (1<<15)
#define HITFLTR_SPLINES (1<<16)
// Starting at this bit through the 31st bit can be used
// by plug-ins for sub-object hit testing
#define HITFLAG_STARTUSERBIT 24
#define VALID(x) (x)
class Modifier;
class Object;
class NameTab;
class Texmap;
typedef Object* ObjectHandle;
MakeTab(TextMapIndex)
typedef TextMapIndexTab TextTab;
//---------------------------------------------------------------
class IdentityTM: public Matrix3 {
public:
IdentityTM() { IdentityMatrix(); }
};
CoreExport extern IdentityTM idTM;
//-------------------------------------------------------------
// This is passed in to GetRenderMesh to allow objects to do
// view dependent rendering.
//
// flag defines for View::flags
#define RENDER_MESH_DISPLACEMENT_MAP 1 // enable displacement mapping
class View {
public:
float screenW, screenH; // screen dimensions
Matrix3 worldToView;
virtual Point2 ViewToScreen(Point3 p)=0;
// the following added for GAP
int projType;
float fov, pixelSize;
Matrix3 affineTM; // worldToCam
DWORD flags;
// Call during render to check if user has cancelled render.
// Returns TRUE iff user has cancelled.
virtual BOOL CheckForRenderAbort() { return FALSE; }
// Generic expansion function
virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) { return 0; }
View() { projType = -1; flags = RENDER_MESH_DISPLACEMENT_MAP; } // projType not set, this is to deal with older renderers.
};
//-------------------------------------------------------------
// Class ID of general deformable object.
extern CoreExport Class_ID defObjectClassID;
//-------------------------------------------------------------
// Class ID of general texture-mappable object.
extern CoreExport Class_ID mapObjectClassID;
//-------------------------------------------------------------
// ChannelMask: bits specific channels in the OSM dataflow.
typedef unsigned long ChannelMask;
// an array of channel masks for all the channels *within*
// the Object.
CoreExport extern ChannelMask chMask[];
class Object;
//-- ObjectState ------------------------------------------------------------
// This is what is passed down the pipeline, and ultimately used by the Node
// to Display, Hittest, render:
// flags bits
class ObjectState {
ulong flags;
Matrix3 *tm;
Interval tmvi;
int mtl;
Interval mtlvi;
void AllocTM();
public:
Object *obj; // object: provides interval with obj->ObjectValidity()
CoreExport ObjectState();
CoreExport ObjectState(Object *ob);
CoreExport ObjectState(const ObjectState& os);
CoreExport ~ObjectState();
void OSSetFlag(ulong f) { flags |= f; }
void OSClearFlag(ulong f) { flags &= ~f; }
ulong OSTestFlag(ulong f) const { return flags&f; }
CoreExport void OSCopyFlag(ulong f, const ObjectState& fromos);
CoreExport ObjectState& operator=(const ObjectState& os);
Interval tmValid() const { return tmvi; }
Interval mtlValid() const { return mtlvi; }
CoreExport Interval Validity(TimeValue t) const;
CoreExport int TMIsIdentity() const;
CoreExport void SetTM(Matrix3* mat, Interval iv);
CoreExport Matrix3* GetTM() const;
CoreExport void SetIdentityTM();
CoreExport void ApplyTM(Matrix3* mat, Interval iv);
CoreExport void CopyTM(const ObjectState &fromos);
CoreExport void CopyMtl(const ObjectState &fromos);
CoreExport void Invalidate(ChannelMask channels, BOOL checkLock=FALSE);
CoreExport void DeleteObj(BOOL checkLock=FALSE);
};
class INodeTab : public Tab<INode*> {
public:
void DisposeTemporary() {
for (int i=0; i<Count(); i++) (*this)[i]->DisposeTemporary();
}
};
//---------------------------------------------------------------
// A reference to a pointer to an instance of this class is passed in
// to ModifyObject(). The value of the pointer starts out as NULL, but
// the modifier can set it to point at an actual instance of a derived
// class. When the mod app is deleted, if the pointer is not NULL, the
// LocalModData will be deleted - the virtual destructor alows this to work.
class LocalModData {
public:
virtual ~LocalModData() {}
virtual LocalModData *Clone()=0;
virtual void* GetInterface(ULONG id) { return NULL; } // to access sub-obj selection interfaces, JBW 2/5/99
};
class ModContext {
public:
Matrix3 *tm;
Box3 *box;
LocalModData *localData;
CoreExport ~ModContext();
CoreExport ModContext();
CoreExport ModContext(const ModContext& mc);
CoreExport ModContext(Matrix3 *tm, Box3 *box, LocalModData *localData);
};
class ModContextList : public Tab<ModContext*> {};
class HitRecord;
// Values passed to NewSetByOperator()
#define NEWSET_MERGE 1
#define NEWSET_INTERSECTION 2
#define NEWSET_SUBTRACT 3
// Flags passed to Display()
#define USE_DAMAGE_RECT (1<<0)
#define DISP_SHOWSUBOBJECT (1<<1)
// The base class of Geometric objects, Lights, Cameras, Modifiers,
// Deformation objects--
// --anything with a 3D representation in the UI scene.
class IParamArray;
class BaseObject: public ReferenceTarget {
public:
CoreExport void* GetInterface(ULONG id);
virtual int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt){return 0;};
virtual void SetExtendedDisplay(int flags) {} // for setting mode-dependent display attributes
virtual int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) { return 0; }; // quick render in viewport, using current TM.
virtual void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) {} // Check for snap, updating SnapInfo
virtual void GetWorldBoundBox(TimeValue t, INode * inode, ViewExp* vp, Box3& box ){}; // Box in world coords.
virtual void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vp, Box3& box ){}; // box in objects local coords
virtual CreateMouseCallBack* GetCreateMouseCallBack()=0;
// This is the name that will appear in the history browser.
virtual TCHAR *GetObjectName() { return _T("Object"); }
// Sends the REFMSG_IS_OK_TO_CHANGE_TOPOLOGY off to see if any
// modifiers or objects down the pipeline depend on topology.
// modName will be set to the dependent modifier's name if there is one.
CoreExport virtual BOOL OKToChangeTopology(TSTR &modName);
// Return true if this object(or modifier) is cabable of changing
//topology when it's parameters are being edited.
virtual BOOL ChangeTopology() {return TRUE;}
virtual void ForceNotify(Interval& i)
{NotifyDependents(i, PART_ALL,REFMSG_CHANGE);}
// If an object or modifier wishes it can make its parameter block
// available for other plug-ins to access. The system itself doesn't
// actually call this method -- this method is optional.
virtual IParamArray *GetParamBlock() {return NULL;}
// If a plug-in make its parameter block available then it will
// need to provide #defines for indices into the parameter block.
// These defines should probably 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.
// -1 indicates an invalid parameter id
virtual int GetParamBlockIndex(int id) {return -1;}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
// The following methods are for sub-object selection. If the
// derived class is NOT a modifier, the modContext pointer passed
// to some of the methods will be NULL.
//
// Affine transform methods
virtual void Move( TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin=FALSE ){}
virtual void Rotate( TimeValue t, Matrix3& partm, Matrix3& tmAxis, Quat& val, BOOL localOrigin=FALSE ){}
virtual void Scale( TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin=FALSE ){}
// The following is called before the first Move(), Rotate() or Scale() call and
// before a hold is in effect
virtual void TransformStart(TimeValue t) {}
// The following is called before the first Move(), Rotate() or Scale() call and
// after a hold is in effect
virtual void TransformHoldingStart(TimeValue t) {}
// The following is called after the user has completed the Move, Rotate or Scale operation and
// before the undo object has been accepted.
virtual void TransformHoldingFinish(TimeValue t) {}
// The following is called after the user has completed the Move, Rotate or Scale operation and
// after the undo object has been accepted.
virtual void TransformFinish(TimeValue t) {}
// The following is called when the transform operation is cancelled by a right-click and
// the undo has been cancelled.
virtual void TransformCancel(TimeValue t) {}
virtual int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc) { return 0; }
virtual int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags, ModContext* mc) { return 0; }; // quick render in viewport, using current TM.
virtual void GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box, ModContext *mc) {}
virtual void CloneSelSubComponents(TimeValue t) {}
virtual void AcceptCloneSelSubComponents(TimeValue t) {}
// Changes the selection state of the component identified by the
// hit record.
virtual void SelectSubComponent(
HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert=FALSE) {}
// Clears the selection for the given sub-object type.
virtual void ClearSelection(int selLevel) {}
virtual void SelectAll(int selLevel) {}
virtual void InvertSelection(int selLevel) {}
// Returns the index of the subobject entity identified by hitRec.
virtual int SubObjectIndex(HitRecord *hitRec) {return 0;}
// This notifies an object being edited that the current sub object
// selection level has changed. level==0 indicates object level selection.
// level==1 or greater refer to the types registered by the object in the
// order they appeared in the list when registered.
// If level >= 1, the object should specify sub-object xform modes in the
// modes structure (defined in cmdmode.h).
virtual void ActivateSubobjSel(int level, XFormModes& modes ) {}
// An object that supports sub-object selection can choose to
// support named sub object selection sets. Methods in the the
// interface passed to objects allow them to add items to the
// sub-object selection set drop down.
// The following methods are called when the user picks items
// from the list.
virtual BOOL SupportsNamedSubSels() {return FALSE;}
virtual void ActivateSubSelSet(TSTR &setName) {}
virtual void NewSetFromCurSel(TSTR &setName) {}
virtual void RemoveSubSelSet(TSTR &setName) {}
// New for version 2. To support the new edit named selections dialog,
// plug-ins must implemented the following methods:
virtual void SetupNamedSelDropDown() {}
virtual int NumNamedSelSets() {return 0;}
virtual TSTR GetNamedSelSetName(int i) {return _T("");}
virtual void SetNamedSelSetName(int i,TSTR &newName) {}
virtual void NewSetByOperator(TSTR &newName,Tab<int> &sets,int op) {}
// New way of dealing with sub object coordinate systems.
// Plug-in enumerates its centers or TMs and calls the callback once for each.
// NOTE:cb->Center() should be called the same number of times and in the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -