- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
CSceneNode.h
资源名称:brm2.rar [点击查看]
上传用户:liujun12jf
上传日期:2022-07-12
资源大小:638k
文件大小:3k
源码类别:
OpenGL
开发平台:
Visual C++
- #ifndef _CSCENENODE_H_
- #define _CSCENENODE_H_
- #include "main.h"
- /*
- my hierarchy nodes need the following:
- vectorq<CSceneNode*> vKids; // children nodes vector (to which nodes is this node parent)
- CSceneNode *pParent; // parent node (whos child this is)
- CMatrix matrix; // matrix (position, rotation)
- and other: (not everything exist yet, this is just what will probably ever be in there)
- CModel *pModel; // pointer to model (this will be rendered)
- NewtonBody *pBody // pointer to newton body object, so we can set physic properties
- CVector colour; // colour of object (eg. somebody gets stoned, so his colour changes =])
- */
- enum SN_RTTI
- {
- SN_PHYSIC_BASE,
- SN_PARTICLES,
- SN_ROOT,
- SN_MAIN_ROOT,
- SN_BLENDING_ROOT
- };
- class CSceneNode;
- typedef vectorq<CSceneNode*> vqCSN;
- typedef vqCSN::iterator vqCSNi;
- class CSceneNode
- {
- void SetParent(CSceneNode *p)
- {
- pParent = p;
- }
- public:
- vqCSN vKids;
- CSceneNode *pParent;
- // warning!!
- // leaveXXX can NOT call another leaveXXX, because it would end as infinite loop
- // so every function does all the work itself, and can use only SetParent(..) and vectorq functions
- void AddChild(CSceneNode *ch)
- {
- if (!ch) return;
- vKids.add(ch);
- ch->SetParent(this);
- }
- void LeaveChild(CSceneNode *ch)
- {
- if (!ch) return;
- vKids.rm(ch);
- ch->SetParent(NULL);
- }
- void DeleteChild(CSceneNode *ch)
- {
- if (!ch) return;
- // child will be dettached, its in destructor
- vqCSNi i = vKids.Find(ch);
- if (!i) return;
- vKids.rm(i);
- delete ch;
- }
- void DeleteAllChildren()
- {
- // vectorq<CSceneNode*>::iterator i;
- vqCSNi i;
- for(i = vKids.begin() ; i != vKids.end() ; i++)
- {
- if (!*i) continue;
- delete *i;
- // this is in destructor, but just to be sure
- *i = 0;
- }
- vKids.clear();
- }
- void LeaveAllChildren()
- {
- // vectorq<CSceneNode*>::iterator i;
- vqCSNi i;
- for(i = vKids.begin() ; i != vKids.end() ; i++)
- {
- if (!*i) continue;
- (*i)->SetParent(0);
- }
- vKids.clear();
- }
- void LeaveParent()
- {
- if (!pParent) return;
- pParent->vKids.rm(this);
- SetParent(0);
- }
- CSceneNode *GetParent()
- { return pParent; }
- vqCSN *GetChildrenList()
- { return &vKids; }
- ~CSceneNode()
- {
- DeleteAllChildren();
- LeaveParent();
- }
- CMatrix mMatrix; // position and rotation
- CVector vColour; // colour of object
- // functions
- CSceneNode()
- {
- mMatrix.Reset();
- vColour.Set(0, 0, 0);
- }
- void SetMatrix(CMatrix m)
- { mMatrix = m; }
- CMatrix GetMatrix()
- { return mMatrix; }
- void SetPosition(CVector v)
- { mMatrix.m_posit = v; }
- CVector GetPosition()
- { return mMatrix.m_posit; }
- virtual void Update(float fTime) = 0;
- virtual void Render() = 0;
- virtual SN_RTTI GetType() = 0;
- /*
- void UpdateChildren(float fTime)
- {
- for (vqCSNi i = vKids.begin() ; i != vKids.end() ; i++)
- {
- if (!*i) continue;
- CSceneNode *pSN;
- pSN = *i;
- pSN->Update(fTime);
- }
- }
- void RenderChildren()
- {
- glPushMatrix();
- glMultMatrixf(&mMatrix[0][0]);
- for (vqCSNi i = vKids.begin() ; i != vKids.end() ; i++)
- {
- if (!*i) continue;
- CSceneNode *pSN;
- pSN = *i;
- pSN->Render();
- }
- glPopMatrix();
- }
- */
- };
- #endif