inode.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. /**********************************************************************
  2. *<
  3. FILE: inode.h
  4. DESCRIPTION:
  5. CREATED BY: Dan Silva
  6. HISTORY:
  7. *> Copyright (c) 1994, All Rights Reserved.
  8. **********************************************************************/
  9. #ifndef __INODE__H
  10. #define __INODE__H
  11. class ObjectState;
  12. class Object;
  13. class Control;
  14. class ScaleValue;
  15. class Mtl;
  16. class RenderData;
  17. // Transform modes -- passed to Move/Rotate/Scale
  18. #define PIV_NONE 0
  19. #define PIV_PIVOT_ONLY 1
  20. #define PIV_OBJECT_ONLY 2
  21. // Node interface
  22. class INode: public ReferenceTarget {
  23. public:
  24. // If this was a temporary INode (like an INodeTransformed) this will delete it.
  25. virtual void DisposeTemporary() {}
  26. // In the case of INodeTransformed, this gets a pointer to the real node.
  27. virtual INode *GetActualINode() {return this;}
  28. virtual TCHAR* GetName()=0;
  29. virtual void SetName(TCHAR *s)=0;
  30. // Get/Set node's transform ( without object-offset or WSM affect)
  31. virtual Matrix3 GetNodeTM(TimeValue t, Interval* valid=NULL)=0;
  32. virtual void SetNodeTM(TimeValue t, Matrix3& tm)=0;
  33. // Invalidate node's caches
  34. virtual void InvalidateTreeTM()=0;
  35. virtual void InvalidateTM()=0;
  36. virtual void InvalidateWS()=0;
  37. // Get object's transform (including object-offset)
  38. // and also the WSM affect when appropriate )
  39. // This is used inside object Display and HitTest routines
  40. virtual Matrix3 GetObjectTM(TimeValue time, Interval* valid=NULL)=0;
  41. // Get object's transform including object-offset but not WSM affect
  42. virtual Matrix3 GetObjTMBeforeWSM(TimeValue time, Interval* valid=NULL)=0;
  43. // Get object's transform including object-offset and WSM affect
  44. virtual Matrix3 GetObjTMAfterWSM(TimeValue time, Interval* valid=NULL)=0;
  45. // evaluate the State the object after offset and WSM's applied
  46. // if evalHidden is FALSE and the node is hidden the pipeline will not
  47. // actually be evaluated (however the TM will).
  48. virtual const ObjectState& EvalWorldState(TimeValue time,BOOL evalHidden=TRUE)=0;
  49. // Hierarchy manipulation
  50. virtual INode* GetParentNode()=0;
  51. virtual void AttachChild(INode* node, int keepPos=1)=0; // make node a child of this one
  52. virtual void Detach(TimeValue t, int keepPos=1)=0; // detach node
  53. virtual int NumberOfChildren()=0;
  54. virtual INode* GetChildNode(int i)=0;
  55. // display attributes
  56. virtual void Hide(BOOL onOff)=0; // set node's hide bit
  57. virtual int IsHidden(DWORD hflags=0)=0;
  58. virtual int IsNodeHidden()=0; // is node hidden in *any* way.
  59. virtual void Freeze(BOOL onOff)= 0; // stop node from being pickable
  60. virtual int IsFrozen()=0;
  61. virtual void BoxMode(BOOL onOff)=0; // display node with a bounding box
  62. virtual int GetBoxMode()=0;
  63. virtual void AllEdges(BOOL onOff)=0; // display all edges, including "hidden" ones
  64. virtual int GetAllEdges()=0;
  65. virtual void BackCull(BOOL onOff)=0; // backcull display toggle
  66. virtual int GetBackCull()=0;
  67. virtual void SetCastShadows(BOOL onOff)=0;
  68. virtual int CastShadows()=0;
  69. virtual void SetRcvShadows(BOOL onOff)=0;
  70. virtual int RcvShadows()=0;
  71. virtual void SetMotBlur(BOOL onOff)=0;
  72. virtual int MotBlur()=0;
  73. // bone display attributes.
  74. virtual void ShowBone(int boneVis)=0; // 0: off, 1: show bone, 2: show bone only
  75. virtual void BoneAsLine(int onOff)=0; // display bone as simple line
  76. virtual BOOL IsBoneShowing()=0;
  77. // Access node's wire-frame color
  78. virtual DWORD GetWireColor()=0;
  79. virtual void SetWireColor(DWORD newcol)=0;
  80. // Test various flags
  81. virtual int IsRootNode()=0;
  82. virtual int Selected()=0;
  83. virtual int Dependent()=0;
  84. virtual int IsTarget()=0;
  85. // Node transform locks
  86. virtual BOOL GetTransformLock(int type, int axis)=0;
  87. virtual void SetTransformLock(int type, int axis, BOOL onOff)=0;
  88. // Get target node if any.
  89. virtual INode* GetTarget()=0; // returns NULL if node has no target.
  90. virtual INode* GetLookatNode()=0; // if this is a target, this finds the node that looks at it.
  91. // This is just GetParent+GetNodeTM
  92. virtual Matrix3 GetParentTM(TimeValue t)=0;
  93. // This is just GetTarget+GetNodeTM
  94. virtual int GetTargetTM(TimeValue t, Matrix3& m)=0;
  95. // Object reference
  96. virtual Object* GetObjectRef()=0;
  97. virtual void SetObjectRef(Object *)=0;
  98. // TM Controller
  99. virtual Control* GetTMController()=0;
  100. virtual void SetTMController(Control *m3cont)=0;
  101. // Visibility controller
  102. virtual Control *GetVisController()=0;
  103. virtual void SetVisController(Control *cont)=0;
  104. virtual float GetVisibility(TimeValue t,Interval *valid=NULL)=0;
  105. virtual void SetVisibility(TimeValue t,float vis)=0;
  106. // Renderer Materials
  107. virtual Mtl *GetMtl()=0;
  108. virtual void SetMtl(Mtl* matl)=0;
  109. // GraphicsWindow Materials
  110. virtual Material* Mtls()=0; // Array of GraphicsWindow Materials
  111. virtual int NumMtls()=0; // number of entries in Mtls
  112. // Object offset from node:
  113. virtual void SetObjOffsetPos(Point3 p)=0;
  114. virtual Point3 GetObjOffsetPos()=0;
  115. virtual void SetObjOffsetRot(Quat q)=0;
  116. virtual Quat GetObjOffsetRot()=0;
  117. virtual void SetObjOffsetScale(ScaleValue sv)=0;
  118. virtual ScaleValue GetObjOffsetScale()=0;
  119. // Misc.
  120. virtual void FlagForeground(TimeValue t,BOOL notify=TRUE)=0;
  121. virtual int IsActiveGrid()=0;
  122. // A place to hang temp data. Don't expect the data to stay around after you return control
  123. virtual void SetNodeLong(LONG l)=0;
  124. virtual LONG GetNodeLong()=0;
  125. // virtual void GetMaterial(Material &mtl)=0; // Why do we need this?
  126. // Access render data
  127. virtual RenderData *GetRenderData()=0;
  128. virtual void SetRenderData(RenderData *rd)=0;
  129. //
  130. // Access user defined property text
  131. //
  132. // The first two functions access the entire buffer
  133. virtual void GetUserPropBuffer(TSTR &buf)=0;
  134. virtual void SetUserPropBuffer(const TSTR &buf)=0;
  135. // These get individual properties - return FALSE if the key is not found
  136. virtual BOOL GetUserPropString(const TSTR &key,TSTR &string)=0;
  137. virtual BOOL GetUserPropInt(const TSTR &key,int &val)=0;
  138. virtual BOOL GetUserPropFloat(const TSTR &key,float &val)=0;
  139. virtual BOOL GetUserPropBool(const TSTR &key,BOOL &b)=0;
  140. // These set individual properties - create the key if it doesn't exist
  141. virtual void SetUserPropString(const TSTR &key,const TSTR &string)=0;
  142. virtual void SetUserPropInt(const TSTR &key,int val)=0;
  143. virtual void SetUserPropFloat(const TSTR &key,float val)=0;
  144. virtual void SetUserPropBool(const TSTR &key,BOOL b)=0;
  145. // Just checks to see if a key exists
  146. virtual BOOL UserPropExists(const TSTR &key)=0;
  147. // G-Buffer ID's
  148. virtual ULONG GetGBufID()=0;
  149. virtual void SetGBufID(ULONG id)=0;
  150. // Transform the node about a specified axis system.
  151. // Either the pivot point or the object or both can be transformed.
  152. // Also, the children can be counter transformed so they don't move.
  153. virtual void Move(TimeValue t, const Matrix3& tmAxis, const Point3& val, BOOL localOrigin=FALSE, BOOL affectKids=TRUE, int pivMode=PIV_NONE, BOOL ignoreLocks=FALSE)=0;
  154. virtual void Rotate(TimeValue t, const Matrix3& tmAxis, const AngAxis& val, BOOL localOrigin=FALSE, BOOL affectKids=TRUE, int pivMode=PIV_NONE, BOOL ignoreLocks=FALSE)=0;
  155. virtual void Rotate(TimeValue t, const Matrix3& tmAxis, const Quat& val, BOOL localOrigin=FALSE, BOOL affectKids=TRUE, int pivMode=PIV_NONE, BOOL ignoreLocks=FALSE)=0;
  156. virtual void Scale(TimeValue t, const Matrix3& tmAxis, const Point3& val, BOOL localOrigin=FALSE, BOOL affectKids=TRUE, int pivMode=PIV_NONE, BOOL ignoreLocks=FALSE)=0;
  157. virtual BOOL IsGroupMember()=0;
  158. virtual BOOL IsGroupHead()=0;
  159. };
  160. // Transform lock types
  161. #define INODE_LOCKPOS 0
  162. #define INODE_LOCKROT 1
  163. #define INODE_LOCKSCL 2
  164. // Transform lock axis
  165. #define INODE_LOCK_X 0
  166. #define INODE_LOCK_Y 1
  167. #define INODE_LOCK_Z 2
  168. // Derive a class from this class, implementing the callback.
  169. class ITreeEnumProc {
  170. public:
  171. virtual int callback( INode *node )=0;
  172. };
  173. // Return values for the TreeEnum callback:
  174. #define TREE_CONTINUE 0 // Continue enumerating
  175. #define TREE_IGNORECHILDREN 1 // Don't enumerate children, but continue
  176. #define TREE_ABORT 2 // Stop enumerating
  177. // Node properties:
  178. #define PROPID_PINNODE PROPID_USER+1 // Returns a pointer to the node this node is pinned to
  179. #define PROPID_PRECEDENCE PROPID_USER+2 // Returns an integer representing this node's precedence
  180. #define PROPID_RELPOS PROPID_USER+3 // Returns a pointer to the relative vector between the node and its pin
  181. #define PROPID_RELROT PROPID_USER+4 // Returns a pointer to the relative quaternion between the node and its pin
  182. class INodeTransformed;
  183. // INodeTransformed can be allocated on the stack, but if you need
  184. // to create one dynamically, use these methods.
  185. CoreExport void DeleteINodeTransformed(INodeTransformed *n);
  186. CoreExport INodeTransformed *CreateINodeTransformed(INode *n,Matrix3 tm,BOOL dm=TRUE);
  187. // This class provides a layer that will add in a transformation to the
  188. // node's objectTM.
  189. //
  190. // Most methods pass through to the inode, except for the objectTM methods
  191. // which pre-multiply in the given matrix.
  192. //
  193. class INodeTransformed : public INode {
  194. public:
  195. INode *node;
  196. Matrix3 tm;
  197. BOOL deleteMe;
  198. INodeTransformed(INode *n,Matrix3 tm,BOOL dm=TRUE) {node = n;this->tm = tm;deleteMe = dm;}
  199. void DisposeTemporary() {node->DisposeTemporary(); if (deleteMe) DeleteINodeTransformed(this);}
  200. INode *GetActualINode() {return node->GetActualINode();}
  201. TCHAR* GetName() {return node->GetName();}
  202. void SetName(TCHAR *s) {node->SetName(s);}
  203. Matrix3 GetNodeTM(TimeValue t, Interval* valid=NULL) {return node->GetNodeTM(t,valid);}
  204. void SetNodeTM(TimeValue t, Matrix3& tm) {node->SetNodeTM(t,tm);}
  205. void InvalidateTreeTM() {node->InvalidateTreeTM();}
  206. void InvalidateTM() {node->InvalidateTM();}
  207. void InvalidateWS() {node->InvalidateWS();}
  208. Matrix3 GetObjectTM(TimeValue time, Interval* valid=NULL) {return tm*node->GetObjectTM(time,valid);}
  209. Matrix3 GetObjTMBeforeWSM(TimeValue time, Interval* valid=NULL) {return tm*node->GetObjTMBeforeWSM(time,valid);}
  210. Matrix3 GetObjTMAfterWSM(TimeValue time, Interval* valid=NULL) {return tm*node->GetObjTMAfterWSM(time,valid);}
  211. const ObjectState& EvalWorldState(TimeValue time,BOOL evalHidden=TRUE) {return node->EvalWorldState(time,evalHidden);}
  212. INode* GetParentNode() {return node->GetParentNode();}
  213. void AttachChild(INode* node, int keepPos=1) {node->AttachChild(node,keepPos);}
  214. void Detach(TimeValue t, int keepPos=1) {node->Detach(t,keepPos);}
  215. int NumberOfChildren() {return node->NumberOfChildren();}
  216. INode* GetChildNode(int i) {return node->GetChildNode(i);}
  217. void Hide(BOOL onOff) {node->Hide(onOff);}
  218. int IsHidden(DWORD hflags=0) {return node->IsHidden(hflags);}
  219. int IsNodeHidden() { return node->IsNodeHidden(); }
  220. void Freeze(BOOL onOff) {node->Freeze(onOff);}
  221. int IsFrozen() {return node->IsFrozen();}
  222. void BoxMode(BOOL onOff) {node->BoxMode(onOff);}
  223. int GetBoxMode() {return node->GetBoxMode();}
  224. void AllEdges(BOOL onOff) {node->AllEdges(onOff);}
  225. int GetAllEdges() {return node->GetAllEdges();}
  226. void BackCull(BOOL onOff) {node->BackCull(onOff);}
  227. int GetBackCull() {return node->GetBackCull();}
  228. void SetCastShadows(BOOL onOff) { node->SetCastShadows(onOff); }
  229. int CastShadows() { return node->CastShadows(); }
  230. void SetRcvShadows(BOOL onOff) { node->SetRcvShadows(onOff); }
  231. int RcvShadows() { return node->RcvShadows(); }
  232. void SetMotBlur(BOOL onOff) { node->SetMotBlur(onOff); }
  233. int MotBlur() { return node->MotBlur(); }
  234. void ShowBone(int boneVis) {node->ShowBone(boneVis);}
  235. void BoneAsLine(int onOff) {node->BoneAsLine(onOff);}
  236. BOOL IsBoneShowing() {return node->IsBoneShowing();}
  237. DWORD GetWireColor() {return node->GetWireColor();}
  238. void SetWireColor(DWORD newcol) {node->SetWireColor(newcol);}
  239. int IsRootNode() {return node->IsRootNode();}
  240. int Selected() {return node->Selected();}
  241. int Dependent() {return node->Dependent();}
  242. int IsTarget() {return node->IsTarget();}
  243. BOOL GetTransformLock(int type, int axis) {return node->GetTransformLock(type,axis);}
  244. void SetTransformLock(int type, int axis, BOOL onOff) {node->SetTransformLock(type,axis,onOff);}
  245. INode* GetTarget() {return node->GetTarget();}
  246. INode* GetLookatNode() {return node->GetLookatNode();}
  247. Matrix3 GetParentTM(TimeValue t) {return node->GetParentTM(t);}
  248. int GetTargetTM(TimeValue t, Matrix3& m) {return node->GetTargetTM(t,m);}
  249. Object* GetObjectRef() {return node->GetObjectRef();}
  250. void SetObjectRef(Object *o) {node->SetObjectRef(o);}
  251. Control* GetTMController() {return node->GetTMController();}
  252. void SetTMController(Control *m3cont) {node->SetTMController(m3cont);}
  253. Control *GetVisController() {return node->GetVisController();}
  254. void SetVisController(Control *cont) {node->SetVisController(cont);}
  255. float GetVisibility(TimeValue t,Interval *valid=NULL) {return node->GetVisibility(t,valid);}
  256. void SetVisibility(TimeValue t,float vis) {node->SetVisibility(t,vis);}
  257. Mtl *GetMtl() { return node->GetMtl(); }
  258. void SetMtl(Mtl* matl) { node->SetMtl(matl); }
  259. Material* Mtls() { return node->Mtls(); }
  260. int NumMtls() { return node->NumMtls(); }
  261. RenderData *GetRenderData() {return node->GetRenderData();}
  262. void SetRenderData(RenderData *rd) {node->SetRenderData(rd);}
  263. void SetObjOffsetPos(Point3 p) {node->SetObjOffsetPos(p);}
  264. Point3 GetObjOffsetPos() {return node->GetObjOffsetPos();}
  265. void SetObjOffsetRot(Quat q) {node->SetObjOffsetRot(q);}
  266. Quat GetObjOffsetRot() {return node->GetObjOffsetRot();}
  267. void FlagForeground(TimeValue t,BOOL notify=TRUE) {node->FlagForeground(t,notify);}
  268. int IsActiveGrid() {return node->IsActiveGrid();}
  269. void SetNodeLong(LONG l) {node->SetNodeLong(l);}
  270. LONG GetNodeLong() {return node->GetNodeLong();}
  271. void GetUserPropBuffer(TSTR &buf) {node->GetUserPropBuffer(buf);}
  272. void SetUserPropBuffer(const TSTR &buf) {node->SetUserPropBuffer(buf);}
  273. BOOL GetUserPropString(const TSTR &key,TSTR &string) {return node->GetUserPropString(key,string);}
  274. BOOL GetUserPropInt(const TSTR &key,int &val) {return node->GetUserPropInt(key,val);}
  275. BOOL GetUserPropFloat(const TSTR &key,float &val) {return node->GetUserPropFloat(key,val);}
  276. BOOL GetUserPropBool(const TSTR &key,BOOL &b) {return node->GetUserPropBool(key,b);}
  277. void SetUserPropString(const TSTR &key,const TSTR &string) {node->SetUserPropString(key,string);}
  278. void SetUserPropInt(const TSTR &key,int val) {node->SetUserPropInt(key,val);}
  279. void SetUserPropFloat(const TSTR &key,float val) {node->SetUserPropFloat(key,val);}
  280. void SetUserPropBool(const TSTR &key,BOOL b) {node->SetUserPropBool(key,b);}
  281. BOOL UserPropExists(const TSTR &key) {return node->UserPropExists(key);}
  282. ULONG GetGBufID() { return node->GetGBufID(); }
  283. void SetGBufID(ULONG id) { node->SetGBufID(id); }
  284. CoreExport void SetObjOffsetScale(ScaleValue sv);
  285. CoreExport ScaleValue GetObjOffsetScale();
  286. void Move(TimeValue t, const Matrix3& tmAxis, const Point3& val, BOOL localOrigin=FALSE, BOOL affectKids=TRUE, int pivMode=PIV_NONE, BOOL ignoreLocks=FALSE) {node->Move(t,tmAxis,val,localOrigin,pivMode,ignoreLocks);}
  287. void Rotate(TimeValue t, const Matrix3& tmAxis, const AngAxis& val, BOOL localOrigin=FALSE, BOOL affectKids=TRUE, int pivMode=PIV_NONE, BOOL ignoreLocks=FALSE) {node->Rotate(t,tmAxis,val,localOrigin,pivMode,ignoreLocks);}
  288. void Rotate(TimeValue t, const Matrix3& tmAxis, const Quat& val, BOOL localOrigin=FALSE, BOOL affectKids=TRUE, int pivMode=PIV_NONE, BOOL ignoreLocks=FALSE) {node->Rotate(t,tmAxis,val,localOrigin,pivMode,ignoreLocks);}
  289. void Scale(TimeValue t, const Matrix3& tmAxis, const Point3& val, BOOL localOrigin=FALSE, BOOL affectKids=TRUE, int pivMode=PIV_NONE, BOOL ignoreLocks=FALSE) {node->Scale(t,tmAxis,val,localOrigin,pivMode,ignoreLocks);}
  290. BOOL IsGroupMember() {return node->IsGroupMember();}
  291. BOOL IsGroupHead() {return node->IsGroupHead();}
  292. RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget,
  293. PartID& partID, RefMessage message) {return REF_SUCCEED;}
  294. };
  295. #endif //__INODE__H