📄 object.h
字号:
// same order as cb->TM()
// NOTE: The SubObjAxisCallback class is defined in animatable and used in both the
// controller version and this version of GetSubObjectCenters() and GetSubObjectTMs()
virtual void GetSubObjectCenters(SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc) {}
virtual void GetSubObjectTMs(SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc) {}
// Find out if the Object or Modifer is is generating UVW's
// on map channel 1.
virtual BOOL HasUVW () { return 0; }
// or on any map channel:
virtual BOOL HasUVW (int mapChannel) { return (mapChannel==1) ? HasUVW() : FALSE; }
// Change the state of the object's Generate UVW boolean.
// IFF the state changes, the object should send a REFMSG_CHANGED down the pipe.
virtual void SetGenUVW(BOOL sw) { } // applies to mapChannel 1
virtual void SetGenUVW (int mapChannel, BOOL sw) { if (mapChannel==1) SetGenUVW (sw); }
// Notify the BaseObject that the end result display has been switched.
// (Sometimes this is needed for display changes.)
virtual void ShowEndResultChanged (BOOL showEndResult) { }
//
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
private:
};
//-------------------------------------------------------------
// Callback object used by Modifiers to deform "Deformable" objects
class Deformer {
public:
virtual Point3 Map(int i, Point3 p) = 0;
void ApplyToTM(Matrix3* tm);
};
// Mapping types passed to ApplyUVWMap()
#define MAP_PLANAR 0
#define MAP_CYLINDRICAL 1
#define MAP_SPHERICAL 2
#define MAP_BALL 3
#define MAP_BOX 4
/*-------------------------------------------------------------------
Object is the class of all objects that can be pointed to by a node:
It INcludes Lights,Cameras, Geometric objects, derived objects,
and deformation Objects (e.g. FFD lattices)
It EXcludes Modifiers
---------------------------------------------------------------------*/
#define OBJECT_LOCKED 0x8000000
class ShapeObject;
class Object: public BaseObject {
ulong locked; // lock flags for each channel + object locked flag
Interval noEvalInterval; // used in ReducingCaches
public:
Object() { locked = OBJECT_LOCKED; noEvalInterval = FOREVER; }
virtual int IsRenderable()=0; // is this a renderable object?
virtual void InitNodeName(TSTR& s)=0;
virtual int UsesWireColor() { return TRUE; } // TRUE if the object color is used for display
virtual int DoOwnSelectHilite() { return 0; }
// validity interval of Object as a whole at current time
virtual Interval ObjectValidity(TimeValue t) { return FOREVER; }
// This used to be in GeomObject but I realized that other types of objects may
// want this (mainly to participate in normal align) such as grid helper objects.
virtual int IntersectRay(TimeValue t, Ray& r, float& at, Point3& norm) {return FALSE;}
// Objects that don't support IntersectRay() (like helpers) can implement this
// method to provide a default vector for normal align.
virtual BOOL NormalAlignVector(TimeValue t,Point3 &pt, Point3 &norm) {return FALSE;}
// locking of object as whole. defaults to NOT modifiable.
void LockObject() { locked |= OBJECT_LOCKED; }
void UnlockObject() { locked &= ~OBJECT_LOCKED; }
int IsObjectLocked() { return locked&OBJECT_LOCKED; }
// the validity intervals are now in the object.
virtual ObjectState Eval(TimeValue t)=0;
// Access the lock flags for th specified channels
void LockChannels(ChannelMask channels) { locked |= channels; }
void UnlockChannels(ChannelMask channels) { locked &= ~channels; }
ChannelMask GetChannelLocks() { return locked; }
void SetChannelLocks(ChannelMask channels) { locked = channels; }
ChannelMask GetChannelLocks(ChannelMask m) { return locked; }
// Can this object have channels cached?
// Particle objects flow up the pipline without making shallow copies of themselves and therefore cannot be cached
virtual BOOL CanCacheObject() {return TRUE;}
// This is called by a node when the node's world space state has
// become invalid. Normally an object does not (and should not) be
// concerned with this, but in certain cases (particle systems) an
// object is effectively a world space object an needs to be notified.
virtual void WSStateInvalidate() {}
// Identifies the object as a world space object. World space
// objects (particles for example) can not be instanced because
// they exist in world space not object space.
virtual BOOL IsWorldSpaceObject() {return FALSE;}
// This is only valid for world-space objects (they must return TRUE for
// the IsWorldSpaceObject method). It locates the node which contains the
// object. Non-world-space objects will return NULL for this!
CoreExport INode *GetWorldSpaceObjectNode();
// Is the derived class derived from ParticleObject?
virtual BOOL IsParticleSystem() {return FALSE;}
// copy specified flags from obj
CoreExport void CopyChannelLocks(Object *obj, ChannelMask needChannels);
// access the current validity interval for the nth channel
CoreExport virtual Interval ChannelValidity(TimeValue t, int nchan);
virtual void SetChannelValidity(int nchan, Interval v) { }
CoreExport void UpdateValidity(int nchan, Interval v); // AND in interval v to channel validity
// invalidate the specified channels
virtual void InvalidateChannels(ChannelMask channels) { }
// topology has been changed by a modifier -- update mesh strip/edge lists
virtual void TopologyChanged() { }
//
// does this object implement the generic Deformable Object procs?
//
virtual int IsDeformable() { return 0; }
// DeformableObject procs: only need be implemented
// IsDeformable() returns TRUE.
virtual int NumPoints(){ return 0;}
virtual Point3 GetPoint(int i) { return Point3(0,0,0); }
virtual void SetPoint(int i, const Point3& p) {}
// Completes the deformable object access with two methods to
// query point selection.
// IsPointSelected returns a TRUE/FALSE value
// PointSelection returns the weighted point selection, if supported.
// Harry D, 11/98
virtual BOOL IsPointSelected (int i) { return FALSE; }
virtual float PointSelection (int i) {
return IsPointSelected(i) ? 1.0f : 0.0f;
}
// These allow the NURBS Relational weights to be modified
virtual BOOL HasWeights() { return FALSE; }
virtual double GetWeight(int i) { return 1.0; }
virtual void SetWeight(int i, const double w) {}
// Get the count of faces and vertices for the polyginal mesh
// of an object. If it return FALSE, then this function
// isn't supported. Plug-ins should use GetPolygonCount(Object*, int&, int&)
// to count the polys in an arbitrary object
virtual BOOL PolygonCount(TimeValue t, int& numFaces, int& numVerts) { return FALSE; }
// informs the object that its points have been deformed,
// so it can invalidate its cache.
virtual void PointsWereChanged(){}
// deform the object with a deformer.
CoreExport virtual void Deform(Deformer *defProc, int useSel=0);
// box in objects local coords or optional space defined by tm
// If useSel is true, the bounding box of selected sub-elements will be taken.
CoreExport virtual void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm=NULL, BOOL useSel=FALSE );
//
// does this object implement the generic Mappable Object procs?
//
virtual int IsMappable() { return 0; }
virtual int NumMapChannels () { return IsMappable(); } // returns number possible.
virtual int NumMapsUsed () { return NumMapChannels(); } // at least 1+(highest channel in use).
// This does the texture map application -- Only need to implement if
// IsMappable returns TRUE
virtual void ApplyUVWMap(int type,
float utile, float vtile, float wtile,
int uflip, int vflip, int wflip, int cap,
const Matrix3 &tm,int channel=1) {}
// Objects need to be able convert themselves
// to TriObjects. Most modifiers will ask for
// Deformable Objects, and triobjects will suffice.
CoreExport virtual int CanConvertToType(Class_ID obtype);
CoreExport virtual Object* ConvertToType(TimeValue t, Class_ID obtype);
// Indicate the types this object can collapse to
virtual Class_ID PreferredCollapseType() {return Class_ID(0,0);}
CoreExport virtual void GetCollapseTypes(Tab<Class_ID> &clist,Tab<TSTR*> &nlist);
// return the current sub-selection state
virtual DWORD GetSubselState() {return 0;}
virtual void SetSubSelState(DWORD s) {}
// If the requested channels are locked, replace their data
// with a copy/ and unlock them, otherwise leave them alone
CoreExport void ReadyChannelsForMod(ChannelMask channels);
// Virtual methods to be implemented by plug-in object:-----
// Makes a copy of its "shell" and shallow copies only the
// specified channels. Also copies the validity intervals of
// the copied channels, and sets Invalidates the other intervals.
virtual Object *MakeShallowCopy(ChannelMask channels) { return NULL; }
// Shallow-copies the specified channels from the fromOb to this.
// Also copies the validity intervals.
virtual void ShallowCopy(Object* fromOb, ChannelMask channels) {}
// This replaces locked channels with newly allocated copies.
// It will only be called if the channel is locked.
virtual void NewAndCopyChannels(ChannelMask channels) {}
// Free the specified channels
virtual void FreeChannels(ChannelMask channels) {}
Interval GetNoEvalInterval() { return noEvalInterval; }
void SetNoEvalInterval(Interval iv) {noEvalInterval = iv; }
// Give the object chance to reduce its caches,
// depending on the noEvalInterval.
CoreExport virtual void ReduceCaches(TimeValue t);
// Is this object a construction object:
virtual int IsConstObject() { return 0; }
// Retreives sub-object branches from an object that supports branching.
// Certain objects combine a series of input objects (pipelines) into
// a single object. These objects act as a multiplexor allowing the
// user to decide which branch(s) they want to see the history for.
//
// It is up to the object how they want to let the user choose. The object
// may use sub object selection to allow the user to pick a set of
// objects for which the common history will be displayed.
//
// When the history changes for any reason, the object should send
// a notification (REFMSG_BRANCHED_HISTORY_CHANGED) via NotifyDependents.
//
virtual int NumPipeBranches() {return 0;}
virtual Object *GetPipeBranch(int i) {return NULL;}
// When an object has sub-object branches, it is likely that the
// sub-objects are transformed relative to the object. This method
// gives the object a chance to modify the node's transformation so
// that operations (like edit modifiers) will work correctly when
// editing the history of the sub object branch.
virtual INode *GetBranchINode(TimeValue t,INode *node,int i) {return node;}
// Shape viewports can reference shapes contained within objects, so we
// need to be able to access shapes within an object. The following methods
// provide this access
virtual int NumberOfContainedShapes() { return -1; } // NOT a container!
virtual ShapeObject *GetContainedShape(TimeValue t, int index) { return NULL; }
virtual void GetContainedShapeMatrix(TimeValue t, int index, Matrix3 &mat) {}
virtual BitArray ContainedShapeSelectionArray() { return BitArray(); }
// Return TRUE for ShapeObject class or GeomObjects that are Shapes too
virtual BOOL IsShapeObject() { return FALSE; }
// For debugging only. TriObject inplements this method by making sure
// its face's vert indices are all valid.
virtual BOOL CheckObjectIntegrity() {return TRUE;}
// Find out if the Object is generating UVW's
virtual BOOL HasUVW() { return 0; }
// or on any map channel:
virtual BOOL HasUVW (int mapChannel) { return (mapChannel==1) ? HasUVW() : FALSE; }
// This is overridden by DerivedObjects to search up the pipe for the base object
virtual Object *FindBaseObject() { return this; }
// Access a parametric position on the surface of the object
virtual BOOL IsParamSurface() {return FALSE;}
virtual int NumSurfaces(TimeValue t) {return 1;}
// Single-surface version (surface 0)
virtual Point3 GetSurfacePoint(TimeValue t, float u, float v,Interval &iv) {return Point3(0,0,0);}
// Multiple-surface version (Implement if you override NumSurfaces)
virtual Point3 GetSurfacePoint(TimeValue t, int surface, float u, float v,Interval &iv) {return Point3(0,0,0);}
// Get information on whether a surface is closed (default is closed both ways)
virtual void SurfaceClosed(TimeValue t, int surface, BOOL &uClosed, BOOL &vClosed) {uClosed = vClosed = TRUE;}
// Allow an object to return extended Properties fields
// Return TRUE if you take advantage of these, and fill in all strings
virtual BOOL GetExtendedProperties(TimeValue t, TSTR &prop1Label, TSTR &prop1Data, TSTR &prop2Label, TSTR &prop2Data) {return FALSE;}
// Allow the object to enlarge its viewport rectangle, if it wants to.
virtual void MaybeEnlargeViewportRect(GraphicsWindow *gw, Rect &rect) {}
// Animatable Overides...
CoreExport SvGraphNodeReference SvTraverseAnimGraph(IGraphObjectManager *gom, Animatable *owner, int id, DWORD flags);
CoreExport bool SvHandleDoubleClick(IGraphObjectManager *gom, IGraphNode *gNode);
CoreExport TSTR SvGetName(IGraphObjectManager *gom, IGraphNode *gNode, bool isBeingEdited);
CoreExport COLORREF SvHighlightColor(IGraphObjectManager *gom, IGraphNode *gNode);
CoreExport bool SvIsSelected(IGraphObjectManager *gom, IGraphNode *gNode);
CoreExport MultiSelectCallback* SvGetMultiSelectCallback(IGraphObjectManager *gom, IGraphNode *gNode);
CoreExport bool SvCanSelect(IGraphObjectManager *gom, IGraphNode *gNode);
};
// This function should be used to count polygons in an object.
// It uses Object::PolygonCount() if it is supported, and converts to
// a TriObject and counts faces and vertices otherwise.
CoreExport void GetPolygonCount(TimeValue t, Object* pObj, int& numFaces, int& numVerts);
/*-------------------------------------------------------------------
CameraObject:
---------------------------------------------------------------------*/
#define CAM_HITHER_CLIP 1
#define CAM_YON_CLIP 2
#define ENV_NEAR_RANGE 0
#define ENV_FAR_RANGE 1
struct CameraState {
BOOL isOrtho; // true if cam is ortho, false for persp
float fov; // field-of-view for persp cams, width for ortho cams
float tdist; // target distance for free cameras
BOOL horzLine; // horizon line display state
int manualClip;
float hither;
float yon;
float nearRange;
float farRange;
};
class CameraObject: public Object {
public:
SClass_ID SuperClassID() { return CAMERA_CLASS_ID; }
int IsRenderable() { return(0);}
virtual void InitNodeName(TSTR& s) { s = _T("Camera"); }
virtual int UsesWireColor() { return FALSE; } // TRUE if the object color is used for display
// Method specific to cameras:
virtual RefResult EvalCameraState(TimeValue time, Interval& valid, CameraState* cs)=0;
virtual void SetOrtho(BOOL b)=0;
virtual BOOL IsOrtho()=0;
virtual void SetFOV(TimeValue time, float f)=0;
virtual float GetFOV(TimeValue t, Interval& valid = Interval(0,0))=0;
virtual void SetTDist(TimeValue time, float f)=0;
virtual float GetTDist(TimeValue t, Interval& valid = Interval(0,0))=0;
virtual int GetManualClip()=0;
virtual void SetManualClip(int onOff)=0;
virtual float GetClipDist(TimeValue t, int which, Interval &valid=Interval(0,0))=0;
virtual void SetClipDist(TimeValue t, int which, float val)=0;
virtual void SetEnvRange(TimeValue time, int which, float f)=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -