1 | #pragma once
|
---|
2 | #include <list>
|
---|
3 | #include <boost/shared_ptr.hpp>
|
---|
4 | #include <boost/weak_ptr.hpp>
|
---|
5 | #include ".\Vector.h"
|
---|
6 | #include <string>
|
---|
7 | #include "NxPhysics.h"
|
---|
8 | #include <vector>
|
---|
9 |
|
---|
10 | class Renderer;
|
---|
11 | class Scene;
|
---|
12 | class GameManager;
|
---|
13 | class Quad;
|
---|
14 |
|
---|
15 | #define SPTR boost::shared_ptr
|
---|
16 | #define WPTR boost::weak_ptr
|
---|
17 |
|
---|
18 | class Node
|
---|
19 | {
|
---|
20 | public:
|
---|
21 | friend class Scene;
|
---|
22 |
|
---|
23 | Node(void);
|
---|
24 | ~Node(void);
|
---|
25 |
|
---|
26 | void setBehaveAs(int _behaveAs);
|
---|
27 | virtual void setRenderer(SPTR<Renderer> &_myRenderer);
|
---|
28 | virtual void removeRenderer();
|
---|
29 | virtual SPTR<Renderer> getRenderer();
|
---|
30 | bool hasRenderer();
|
---|
31 |
|
---|
32 | virtual void translate(float dx, float dy, float dz);
|
---|
33 | virtual void translate(Vector &tv);
|
---|
34 | virtual void rotate(float dalpha, float dbeta, float dgamma);
|
---|
35 | virtual void setPosition(float x, float y, float z);
|
---|
36 | virtual void setPosition(Vector &p);
|
---|
37 | virtual void setRotation(float alpha, float beta, float gamma);
|
---|
38 | virtual void setRotation(Vector &r);
|
---|
39 | Vector getPosition();
|
---|
40 | float getRotationX();
|
---|
41 | float getRotationY();
|
---|
42 | float getRotationZ();
|
---|
43 |
|
---|
44 | std::list<SPTR<Node> >::iterator addChild(SPTR<Node> _child);
|
---|
45 | virtual void removeChild(std::list<SPTR<Node> >::iterator _it);
|
---|
46 | virtual void removeChild(SPTR<Node> _child);
|
---|
47 | virtual void removeAllChildren();
|
---|
48 | virtual void killMe();
|
---|
49 |
|
---|
50 |
|
---|
51 | virtual void update(float dt);
|
---|
52 | virtual void calcWorldMatrix(D3DXMATRIX &pMatWorld);
|
---|
53 | void setWorldMatrix(D3DXMATRIXA16 &worldMatrix);
|
---|
54 | D3DXMATRIXA16* getWorldMatrix();
|
---|
55 | virtual void getAbsoluteVector(Vector &pOut, Vector &pin);
|
---|
56 | virtual void getAbsoluteDirectionVector(Vector &dirOut, Vector &dirIn);
|
---|
57 | Vector getAbsolutePosition();
|
---|
58 |
|
---|
59 | Vector* getAbsMinBBox();
|
---|
60 | Vector* getAbsMaxBBox();
|
---|
61 | Vector getAbsBoxCenter();
|
---|
62 | virtual void updateBBox();
|
---|
63 | virtual void setDetail(Vector ObjectCenter);
|
---|
64 |
|
---|
65 | void setScene(Scene &scene);
|
---|
66 | void setVisible(bool _visible);
|
---|
67 | bool isVisible();
|
---|
68 | void setStandBy(bool _standBy);
|
---|
69 | bool onStandBy();
|
---|
70 |
|
---|
71 | Scene *myScene;
|
---|
72 | Vector myPosition;
|
---|
73 | Vector myRotation;
|
---|
74 |
|
---|
75 | Node* getFather();
|
---|
76 | std::list<SPTR<Node> > * getChildren();
|
---|
77 |
|
---|
78 | //Physic Stuff
|
---|
79 | static const int NORMAL = 0;
|
---|
80 | static const int STATIC = 1;
|
---|
81 | static const int KINEMATIC = 2;
|
---|
82 | static const int RIGIDBODY = 3;
|
---|
83 | static const int PARTICLE = 4;
|
---|
84 | NxActorDesc* getActorDescriptor();
|
---|
85 | NxBodyDesc* getBodyDescriptor();
|
---|
86 | NxActor* getActor();
|
---|
87 | void setPMaterial(int id);
|
---|
88 | void setColDetGroup(int group);
|
---|
89 |
|
---|
90 | //Particle Stuff
|
---|
91 | virtual void setParticleGroup(int _group);
|
---|
92 | int getParticleGroup();
|
---|
93 | virtual Node* clone();
|
---|
94 | virtual void setTimeToLive(float _timeToLive);
|
---|
95 | float getTimeToLive();
|
---|
96 |
|
---|
97 | virtual void cloneChildren(Node *clonedNode);
|
---|
98 |
|
---|
99 | void orientAndMove(Vector direction, Vector upVec, Vector moveVec, bool moveRelative = true);
|
---|
100 |
|
---|
101 | Vector minAABBox;
|
---|
102 | Vector maxAABBox;
|
---|
103 | Vector absMinAABBox;
|
---|
104 | Vector absMaxAABBox;
|
---|
105 | Vector absBoxCenter;
|
---|
106 |
|
---|
107 | virtual void OnLostDevice( void* pUserContext );
|
---|
108 | virtual void OnDestroyDevice( void* pUserContext );
|
---|
109 | virtual HRESULT OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
|
---|
110 |
|
---|
111 | bool testAgainstFrustum;
|
---|
112 |
|
---|
113 | bool isA(int _nodeType);
|
---|
114 | void* userData;
|
---|
115 |
|
---|
116 | void clonePhysicStuff(Node* obj);
|
---|
117 |
|
---|
118 | bool doingSoftKill;
|
---|
119 | float softKillAlpha;
|
---|
120 | virtual void setSoftKill(bool _softKill, float _duration = 1.0f);
|
---|
121 | bool getSoftKill();
|
---|
122 | float camDistance;
|
---|
123 |
|
---|
124 | friend class Quad;
|
---|
125 | friend class ResourceManager;
|
---|
126 | protected:
|
---|
127 | int nodeType;
|
---|
128 | //Jede Node die auf StandBy=true ist, wird überhaupt nicht beachtet. Aktivierung durch explizites setzen oder Trigger(siehe goodie)
|
---|
129 | bool standBy;
|
---|
130 | //Soll updateMethode aufgerufen werden?
|
---|
131 | bool updateMe;
|
---|
132 | //Soll Node gezeichnet werden?
|
---|
133 | bool visible;
|
---|
134 | //Ist die vorhandene Node ein clon?
|
---|
135 | bool aClone;
|
---|
136 | //Calc Boundingbox of this Node
|
---|
137 | bool calcBoundingBox;
|
---|
138 |
|
---|
139 | bool softKill;
|
---|
140 | float softKillDuration;
|
---|
141 |
|
---|
142 |
|
---|
143 | Node *father;
|
---|
144 | int behaveAs;
|
---|
145 | std::list<SPTR<Node> > children;
|
---|
146 |
|
---|
147 | bool rendererAdded;
|
---|
148 | SPTR<Renderer> myRenderer;
|
---|
149 |
|
---|
150 | D3DXMATRIXA16 myWorldMatrix;
|
---|
151 | bool bOverrideWorldMatrix;
|
---|
152 | void calcStaticPhysicWorldMatrix();
|
---|
153 | void calcNormalWorldMatrix(D3DXMATRIX &pMatWorld);
|
---|
154 | void calcKinematicWorldMatrix(D3DXMATRIX &pMatWorld);
|
---|
155 | virtual void calcPhysicWorldMatrix(D3DXMATRIX &pMatWorld);
|
---|
156 |
|
---|
157 | //Phyisc Stuff
|
---|
158 | NxActorDesc pActorDesc;
|
---|
159 | NxBodyDesc pBodyDesc;
|
---|
160 | NxActor* pActor;
|
---|
161 | int pMaterialId;
|
---|
162 | int pColDetGroup;
|
---|
163 |
|
---|
164 | //Particle Stuff
|
---|
165 | int particleGroup;
|
---|
166 | float timeToLive;
|
---|
167 | float maxAge;
|
---|
168 |
|
---|
169 | Vector myAbsPos;
|
---|
170 | Vector corner[8]; //Fuer BoundingBox
|
---|
171 | };
|
---|