diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8.1/source/Irrlicht/CSceneManager.h | 659 |
1 files changed, 659 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/source/Irrlicht/CSceneManager.h b/libraries/irrlicht-1.8.1/source/Irrlicht/CSceneManager.h new file mode 100644 index 0000000..3957f85 --- /dev/null +++ b/libraries/irrlicht-1.8.1/source/Irrlicht/CSceneManager.h | |||
@@ -0,0 +1,659 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | ||
2 | // This file is part of the "Irrlicht Engine". | ||
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | ||
4 | |||
5 | #ifndef __C_SCENE_MANAGER_H_INCLUDED__ | ||
6 | #define __C_SCENE_MANAGER_H_INCLUDED__ | ||
7 | |||
8 | #include "ISceneManager.h" | ||
9 | #include "ISceneNode.h" | ||
10 | #include "ICursorControl.h" | ||
11 | #include "irrString.h" | ||
12 | #include "irrArray.h" | ||
13 | #include "IMeshLoader.h" | ||
14 | #include "CAttributes.h" | ||
15 | #include "ILightManager.h" | ||
16 | |||
17 | namespace irr | ||
18 | { | ||
19 | namespace io | ||
20 | { | ||
21 | class IXMLWriter; | ||
22 | class IFileSystem; | ||
23 | } | ||
24 | namespace scene | ||
25 | { | ||
26 | class IMeshCache; | ||
27 | class IGeometryCreator; | ||
28 | |||
29 | /*! | ||
30 | The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. | ||
31 | */ | ||
32 | class CSceneManager : public ISceneManager, public ISceneNode | ||
33 | { | ||
34 | public: | ||
35 | |||
36 | //! constructor | ||
37 | CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, | ||
38 | gui::ICursorControl* cursorControl, IMeshCache* cache = 0, | ||
39 | gui::IGUIEnvironment *guiEnvironment = 0); | ||
40 | |||
41 | //! destructor | ||
42 | virtual ~CSceneManager(); | ||
43 | |||
44 | //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. | ||
45 | virtual IAnimatedMesh* getMesh(const io::path& filename); | ||
46 | |||
47 | //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. | ||
48 | virtual IAnimatedMesh* getMesh(io::IReadFile* file); | ||
49 | |||
50 | //! Returns an interface to the mesh cache which is shared beween all existing scene managers. | ||
51 | virtual IMeshCache* getMeshCache(); | ||
52 | |||
53 | //! returns the video driver | ||
54 | virtual video::IVideoDriver* getVideoDriver(); | ||
55 | |||
56 | //! return the gui environment | ||
57 | virtual gui::IGUIEnvironment* getGUIEnvironment(); | ||
58 | |||
59 | //! return the filesystem | ||
60 | virtual io::IFileSystem* getFileSystem(); | ||
61 | |||
62 | //! adds Volume Lighting Scene Node. | ||
63 | //! the returned pointer must not be dropped. | ||
64 | virtual IVolumeLightSceneNode* addVolumeLightSceneNode(ISceneNode* parent=0, s32 id=-1, | ||
65 | const u32 subdivU = 32, const u32 subdivV = 32, | ||
66 | const video::SColor foot = video::SColor(51, 0, 230, 180), | ||
67 | const video::SColor tail = video::SColor(0, 0, 0, 0), | ||
68 | const core::vector3df& position = core::vector3df(0,0,0), | ||
69 | const core::vector3df& rotation = core::vector3df(0,0,0), | ||
70 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); | ||
71 | |||
72 | //! adds a cube scene node to the scene. It is a simple cube of (1,1,1) size. | ||
73 | //! the returned pointer must not be dropped. | ||
74 | virtual IMeshSceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, | ||
75 | const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); | ||
76 | |||
77 | //! Adds a sphere scene node to the scene. | ||
78 | virtual IMeshSceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16, ISceneNode* parent=0, s32 id=-1, | ||
79 | const core::vector3df& position = core::vector3df(0,0,0), | ||
80 | const core::vector3df& rotation = core::vector3df(0,0,0), | ||
81 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); | ||
82 | |||
83 | //! adds a scene node for rendering an animated mesh model | ||
84 | virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1, | ||
85 | const core::vector3df& position = core::vector3df(0,0,0), | ||
86 | const core::vector3df& rotation = core::vector3df(0,0,0), | ||
87 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), | ||
88 | bool alsoAddIfMeshPointerZero=false); | ||
89 | |||
90 | //! adds a scene node for rendering a static mesh | ||
91 | //! the returned pointer must not be dropped. | ||
92 | virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, | ||
93 | const core::vector3df& position = core::vector3df(0,0,0), | ||
94 | const core::vector3df& rotation = core::vector3df(0,0,0), | ||
95 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), | ||
96 | bool alsoAddIfMeshPointerZero=false); | ||
97 | |||
98 | //! Adds a scene node for rendering a animated water surface mesh. | ||
99 | virtual ISceneNode* addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, f32 waveSpeed, f32 wlenght, ISceneNode* parent=0, s32 id=-1, | ||
100 | const core::vector3df& position = core::vector3df(0,0,0), | ||
101 | const core::vector3df& rotation = core::vector3df(0,0,0), | ||
102 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); | ||
103 | |||
104 | //! renders the node. | ||
105 | virtual void render(); | ||
106 | |||
107 | //! returns the axis aligned bounding box of this node | ||
108 | virtual const core::aabbox3d<f32>& getBoundingBox() const; | ||
109 | |||
110 | //! registers a node for rendering it at a specific time. | ||
111 | virtual u32 registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC); | ||
112 | |||
113 | //! draws all scene nodes | ||
114 | virtual void drawAll(); | ||
115 | |||
116 | //! Adds a scene node for rendering using a octree to the scene graph. This a good method for rendering | ||
117 | //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much | ||
118 | //! faster then a bsp tree. | ||
119 | virtual IMeshSceneNode* addOctreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, | ||
120 | s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false); | ||
121 | |||
122 | //! Adss a scene node for rendering using a octree. This a good method for rendering | ||
123 | //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much | ||
124 | //! faster then a bsp tree. | ||
125 | virtual IMeshSceneNode* addOctreeSceneNode(IMesh* mesh, ISceneNode* parent=0, | ||
126 | s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); | ||
127 | |||
128 | //! Adds a camera scene node to the tree and sets it as active camera. | ||
129 | //! \param position: Position of the space relative to its parent where the camera will be placed. | ||
130 | //! \param lookat: Position where the camera will look at. Also known as target. | ||
131 | //! \param parent: Parent scene node of the camera. Can be null. If the parent moves, | ||
132 | //! the camera will move too. | ||
133 | //! \return Pointer to interface to camera | ||
134 | virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, | ||
135 | const core::vector3df& position = core::vector3df(0,0,0), | ||
136 | const core::vector3df& lookat = core::vector3df(0,0,100), | ||
137 | s32 id=-1, bool makeActive=true); | ||
138 | |||
139 | //! Adds a camera scene node which is able to be controlle with the mouse similar | ||
140 | //! like in the 3D Software Maya by Alias Wavefront. | ||
141 | //! The returned pointer must not be dropped. | ||
142 | virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent=0, | ||
143 | f32 rotateSpeed=-1500.f, f32 zoomSpeed=200.f, | ||
144 | f32 translationSpeed=1500.f, s32 id=-1, f32 distance=70.f, | ||
145 | bool makeActive=true); | ||
146 | |||
147 | //! Adds a camera scene node which is able to be controled with the mouse and keys | ||
148 | //! like in most first person shooters (FPS): | ||
149 | virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, | ||
150 | f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1, | ||
151 | SKeyMap* keyMapArray=0, s32 keyMapSize=0, | ||
152 | bool noVerticalMovement=false, f32 jumpSpeed = 0.f, | ||
153 | bool invertMouseY=false, bool makeActive=true); | ||
154 | |||
155 | //! Adds a dynamic light scene node. The light will cast dynamic light on all | ||
156 | //! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING | ||
157 | //! turned on. (This is the default setting in most scene nodes). | ||
158 | virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0, | ||
159 | const core::vector3df& position = core::vector3df(0,0,0), | ||
160 | video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f), | ||
161 | f32 range=100.0f, s32 id=-1); | ||
162 | |||
163 | //! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, | ||
164 | //! which always looks to the camera. It is usually used for things like explosions, fire, | ||
165 | //! lensflares and things like that. | ||
166 | virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0, | ||
167 | const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f), | ||
168 | const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, | ||
169 | video::SColor shadeTop = 0xFFFFFFFF, video::SColor shadeBottom = 0xFFFFFFFF); | ||
170 | |||
171 | //! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and | ||
172 | //! is drawn around the camera position. | ||
173 | virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, | ||
174 | video::ITexture* left, video::ITexture* right, video::ITexture* front, | ||
175 | video::ITexture* back, ISceneNode* parent = 0, s32 id=-1); | ||
176 | |||
177 | //! Adds a skydome scene node. A skydome is a large (half-) sphere with a | ||
178 | //! panoramic texture on it and is drawn around the camera position. | ||
179 | virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture, | ||
180 | u32 horiRes=16, u32 vertRes=8, | ||
181 | f32 texturePercentage=0.9, f32 spherePercentage=2.0,f32 radius = 1000.f, | ||
182 | ISceneNode* parent=0, s32 id=-1); | ||
183 | |||
184 | //! Adds a text scene node, which is able to display | ||
185 | //! 2d text at a position in three dimensional space | ||
186 | virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, | ||
187 | video::SColor color=video::SColor(100,255,255,255), | ||
188 | ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), | ||
189 | s32 id=-1); | ||
190 | |||
191 | //! Adds a text scene node, which uses billboards | ||
192 | virtual IBillboardTextSceneNode* addBillboardTextSceneNode(gui::IGUIFont* font, const wchar_t* text, | ||
193 | ISceneNode* parent = 0, | ||
194 | const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f), | ||
195 | const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, | ||
196 | video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF); | ||
197 | |||
198 | //! Adds a scene node, which can render a quake3 shader | ||
199 | virtual IMeshSceneNode* addQuake3SceneNode(const IMeshBuffer* meshBuffer, const quake3::IShader * shader, | ||
200 | ISceneNode* parent=0, s32 id=-1 | ||
201 | ); | ||
202 | |||
203 | |||
204 | //! Adds a Hill Plane mesh to the mesh pool. The mesh is | ||
205 | //! generated on the fly and looks like a plane with some hills | ||
206 | //! on it. You can specify how many hills should be on the plane | ||
207 | //! and how high they should be. Also you must specify a name | ||
208 | //! for the mesh because the mesh is added to the mesh pool and | ||
209 | //! can be retrieved back using ISceneManager::getMesh with the | ||
210 | //! name as parameter. | ||
211 | virtual IAnimatedMesh* addHillPlaneMesh(const io::path& name, | ||
212 | const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount, | ||
213 | video::SMaterial* material = 0, f32 hillHeight = 0.0f, | ||
214 | const core::dimension2d<f32>& countHills = core::dimension2d<f32>(1.0f, 1.0f), | ||
215 | const core::dimension2d<f32>& textureRepeatCount = core::dimension2d<f32>(1.0f, 1.0f)); | ||
216 | |||
217 | //! Adds a terrain mesh to the mesh pool. | ||
218 | virtual IAnimatedMesh* addTerrainMesh(const io::path& meshname, video::IImage* texture, video::IImage* heightmap, | ||
219 | const core::dimension2d<f32>& stretchSize = core::dimension2d<f32>(10.0f,10.0f), | ||
220 | f32 maxHeight=200.0f, | ||
221 | const core::dimension2d<u32>& defaultVertexBlockSize = core::dimension2d<u32>(64,64)); | ||
222 | |||
223 | //! Add a arrow mesh to the mesh pool | ||
224 | virtual IAnimatedMesh* addArrowMesh(const io::path& name, | ||
225 | video::SColor vtxColor0, video::SColor vtxColor1, | ||
226 | u32 tesselationCylinder, u32 tesselationCone, | ||
227 | f32 height, f32 cylinderHeight, f32 width0, | ||
228 | f32 width1); | ||
229 | |||
230 | //! Adds a static sphere mesh to the mesh pool. | ||
231 | IAnimatedMesh* addSphereMesh(const io::path& name, | ||
232 | f32 radius=5.f, u32 polyCountX=16, u32 polyCountY=16); | ||
233 | |||
234 | //! Adds a static volume light mesh to the mesh pool. | ||
235 | IAnimatedMesh* addVolumeLightMesh(const io::path& name, | ||
236 | const u32 SubdivideU = 32, const u32 SubdivideV = 32, | ||
237 | const video::SColor FootColor = video::SColor(51, 0, 230, 180), | ||
238 | const video::SColor TailColor = video::SColor(0, 0, 0, 0)); | ||
239 | |||
240 | //! Adds a particle system scene node. | ||
241 | virtual IParticleSystemSceneNode* addParticleSystemSceneNode( | ||
242 | bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, | ||
243 | const core::vector3df& position = core::vector3df(0,0,0), | ||
244 | const core::vector3df& rotation = core::vector3df(0,0,0), | ||
245 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); | ||
246 | |||
247 | //! Adds a terrain scene node to the scene graph. | ||
248 | virtual ITerrainSceneNode* addTerrainSceneNode( | ||
249 | const io::path& heightMapFileName, | ||
250 | ISceneNode* parent=0, s32 id=-1, | ||
251 | const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), | ||
252 | const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), | ||
253 | const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), | ||
254 | video::SColor vertexColor = video::SColor(255,255,255,255), | ||
255 | s32 maxLOD=4, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17,s32 smoothFactor=0, | ||
256 | bool addAlsoIfHeightmapEmpty = false); | ||
257 | |||
258 | //! Adds a terrain scene node to the scene graph. | ||
259 | virtual ITerrainSceneNode* addTerrainSceneNode( | ||
260 | io::IReadFile* heightMap, | ||
261 | ISceneNode* parent=0, s32 id=-1, | ||
262 | const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), | ||
263 | const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), | ||
264 | const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), | ||
265 | video::SColor vertexColor = video::SColor(255,255,255,255), | ||
266 | s32 maxLOD=4, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17,s32 smoothFactor=0, | ||
267 | bool addAlsoIfHeightmapEmpty=false); | ||
268 | |||
269 | //! Adds a dummy transformation scene node to the scene graph. | ||
270 | virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode( | ||
271 | ISceneNode* parent=0, s32 id=-1); | ||
272 | |||
273 | //! Adds an empty scene node. | ||
274 | virtual ISceneNode* addEmptySceneNode(ISceneNode* parent, s32 id=-1); | ||
275 | |||
276 | //! Returns the root scene node. This is the scene node wich is parent | ||
277 | //! of all scene nodes. The root scene node is a special scene node which | ||
278 | //! only exists to manage all scene nodes. It is not rendered and cannot | ||
279 | //! be removed from the scene. | ||
280 | //! \return Pointer to the root scene node. | ||
281 | virtual ISceneNode* getRootSceneNode(); | ||
282 | |||
283 | //! Returns the current active camera. | ||
284 | //! \return The active camera is returned. Note that this can be NULL, if there | ||
285 | //! was no camera created yet. | ||
286 | virtual ICameraSceneNode* getActiveCamera() const; | ||
287 | |||
288 | //! Sets the active camera. The previous active camera will be deactivated. | ||
289 | //! \param camera: The new camera which should be active. | ||
290 | virtual void setActiveCamera(ICameraSceneNode* camera); | ||
291 | |||
292 | //! creates a rotation animator, which rotates the attached scene node around itself. | ||
293 | //! \param rotationPerSecond: Specifies the speed of the animation | ||
294 | //! \return The animator. Attach it to a scene node with ISceneNode::addAnimator() | ||
295 | //! and the animator will animate it. | ||
296 | virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond); | ||
297 | |||
298 | //! creates a fly circle animator | ||
299 | /** Lets the attached scene node fly around a center. | ||
300 | \param center Center relative to node origin | ||
301 | \param speed: The orbital speed, in radians per millisecond. | ||
302 | \param direction: Specifies the upvector used for alignment of the mesh. | ||
303 | \param startPosition: The position on the circle where the animator will | ||
304 | begin. Value is in multiples of a circle, i.e. 0.5 is half way around. | ||
305 | \return The animator. Attach it to a scene node with ISceneNode::addAnimator() | ||
306 | */ | ||
307 | virtual ISceneNodeAnimator* createFlyCircleAnimator( | ||
308 | const core::vector3df& center=core::vector3df(0.f, 0.f, 0.f), | ||
309 | f32 radius=100.f, f32 speed=0.001f, | ||
310 | const core::vector3df& direction=core::vector3df(0.f, 1.f, 0.f), | ||
311 | f32 startPosition = 0.f, | ||
312 | f32 radiusEllipsoid = 0.f); | ||
313 | |||
314 | //! Creates a fly straight animator, which lets the attached scene node | ||
315 | //! fly or move along a line between two points. | ||
316 | virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint, | ||
317 | const core::vector3df& endPoint, u32 timeForWay, bool loop=false,bool pingpong = false); | ||
318 | |||
319 | //! Creates a texture animator, which switches the textures of the target scene | ||
320 | //! node based on a list of textures. | ||
321 | virtual ISceneNodeAnimator* createTextureAnimator(const core::array<video::ITexture*>& textures, | ||
322 | s32 timePerFrame, bool loop); | ||
323 | |||
324 | //! Creates a scene node animator, which deletes the scene node after | ||
325 | //! some time automaticly. | ||
326 | virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMS); | ||
327 | |||
328 | |||
329 | //! Creates a special scene node animator for doing automatic collision detection | ||
330 | //! and response. | ||
331 | virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( | ||
332 | ITriangleSelector* world, ISceneNode* sceneNode, | ||
333 | const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), | ||
334 | const core::vector3df& gravityPerSecond = core::vector3df(0,-1.0f,0), | ||
335 | const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), | ||
336 | f32 slidingValue = 0.0005f); | ||
337 | |||
338 | //! Creates a follow spline animator. | ||
339 | virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime, | ||
340 | const core::array< core::vector3df >& points, | ||
341 | f32 speed, f32 tightness, bool loop, bool pingpong); | ||
342 | |||
343 | |||
344 | //! Creates a simple ITriangleSelector, based on a mesh. | ||
345 | virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node); | ||
346 | |||
347 | //! Creates a simple ITriangleSelector, based on an animated mesh scene node. | ||
348 | //! Details of the mesh associated with the node will be extracted internally. | ||
349 | //! Call ITriangleSelector::update() to have the triangle selector updated based | ||
350 | //! on the current frame of the animated mesh scene node. | ||
351 | //! \param: The animated mesh scene node from which to build the selector | ||
352 | virtual ITriangleSelector* createTriangleSelector(IAnimatedMeshSceneNode* node); | ||
353 | |||
354 | //! Creates a simple ITriangleSelector, based on a mesh. | ||
355 | virtual ITriangleSelector* createOctreeTriangleSelector(IMesh* mesh, | ||
356 | ISceneNode* node, s32 minimalPolysPerNode); | ||
357 | |||
358 | //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. | ||
359 | virtual ITriangleSelector* createTriangleSelectorFromBoundingBox( | ||
360 | ISceneNode* node); | ||
361 | |||
362 | //! Creates a meta triangle selector. | ||
363 | virtual IMetaTriangleSelector* createMetaTriangleSelector(); | ||
364 | |||
365 | //! Creates a triangle selector which can select triangles from a terrain scene node | ||
366 | //! \param: Pointer to the created terrain scene node | ||
367 | //! \param: Level of detail, 0 for highest detail. | ||
368 | virtual ITriangleSelector* createTerrainTriangleSelector( | ||
369 | ITerrainSceneNode* node, s32 LOD=0); | ||
370 | |||
371 | //! Adds an external mesh loader. | ||
372 | virtual void addExternalMeshLoader(IMeshLoader* externalLoader); | ||
373 | |||
374 | //! Returns the number of mesh loaders supported by Irrlicht at this time | ||
375 | virtual u32 getMeshLoaderCount() const; | ||
376 | |||
377 | //! Retrieve the given mesh loader | ||
378 | virtual IMeshLoader* getMeshLoader(u32 index) const; | ||
379 | |||
380 | //! Adds an external scene loader. | ||
381 | virtual void addExternalSceneLoader(ISceneLoader* externalLoader); | ||
382 | |||
383 | //! Returns the number of scene loaders supported by Irrlicht at this time | ||
384 | virtual u32 getSceneLoaderCount() const; | ||
385 | |||
386 | //! Retrieve the given scene loader | ||
387 | virtual ISceneLoader* getSceneLoader(u32 index) const; | ||
388 | |||
389 | //! Returns a pointer to the scene collision manager. | ||
390 | virtual ISceneCollisionManager* getSceneCollisionManager(); | ||
391 | |||
392 | //! Returns a pointer to the mesh manipulator. | ||
393 | virtual IMeshManipulator* getMeshManipulator(); | ||
394 | |||
395 | //! Sets the color of stencil buffers shadows drawn by the scene manager. | ||
396 | virtual void setShadowColor(video::SColor color); | ||
397 | |||
398 | //! Returns the current color of shadows. | ||
399 | virtual video::SColor getShadowColor() const; | ||
400 | |||
401 | //! Adds a scene node to the deletion queue. | ||
402 | virtual void addToDeletionQueue(ISceneNode* node); | ||
403 | |||
404 | //! Returns the first scene node with the specified id. | ||
405 | virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0); | ||
406 | |||
407 | //! Returns the first scene node with the specified name. | ||
408 | virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0); | ||
409 | |||
410 | //! Returns the first scene node with the specified type. | ||
411 | virtual ISceneNode* getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode* start=0); | ||
412 | |||
413 | //! returns scene nodes by type. | ||
414 | virtual void getSceneNodesFromType(ESCENE_NODE_TYPE type, core::array<scene::ISceneNode*>& outNodes, ISceneNode* start=0); | ||
415 | |||
416 | //! Posts an input event to the environment. Usually you do not have to | ||
417 | //! use this method, it is used by the internal engine. | ||
418 | virtual bool postEventFromUser(const SEvent& event); | ||
419 | |||
420 | //! Clears the whole scene. All scene nodes are removed. | ||
421 | virtual void clear(); | ||
422 | |||
423 | //! Removes all children of this scene node | ||
424 | virtual void removeAll(); | ||
425 | |||
426 | //! Returns interface to the parameters set in this scene. | ||
427 | virtual io::IAttributes* getParameters(); | ||
428 | |||
429 | //! Returns current render pass. | ||
430 | virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const; | ||
431 | |||
432 | //! Creates a new scene manager. | ||
433 | virtual ISceneManager* createNewSceneManager(bool cloneContent); | ||
434 | |||
435 | //! Returns type of the scene node | ||
436 | virtual ESCENE_NODE_TYPE getType() const { return ESNT_SCENE_MANAGER; } | ||
437 | |||
438 | //! Returns the default scene node factory which can create all built in scene nodes | ||
439 | virtual ISceneNodeFactory* getDefaultSceneNodeFactory(); | ||
440 | |||
441 | //! Adds a scene node factory to the scene manager. | ||
442 | /** Use this to extend the scene manager with new scene node types which it should be | ||
443 | able to create automaticly, for example when loading data from xml files. */ | ||
444 | virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd); | ||
445 | |||
446 | //! Returns amount of registered scene node factories. | ||
447 | virtual u32 getRegisteredSceneNodeFactoryCount() const; | ||
448 | |||
449 | //! Returns a scene node factory by index | ||
450 | virtual ISceneNodeFactory* getSceneNodeFactory(u32 index); | ||
451 | |||
452 | //! Returns a typename from a scene node type or null if not found | ||
453 | virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type); | ||
454 | |||
455 | //! Returns a typename from a scene node animator type or null if not found | ||
456 | virtual const c8* getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); | ||
457 | |||
458 | //! Adds a scene node to the scene by name | ||
459 | virtual ISceneNode* addSceneNode(const char* sceneNodeTypeName, ISceneNode* parent=0); | ||
460 | |||
461 | //! creates a scene node animator based on its type name | ||
462 | virtual ISceneNodeAnimator* createSceneNodeAnimator(const char* typeName, ISceneNode* target=0); | ||
463 | |||
464 | //! Returns the default scene node animator factory which can create all built-in scene node animators | ||
465 | virtual ISceneNodeAnimatorFactory* getDefaultSceneNodeAnimatorFactory(); | ||
466 | |||
467 | //! Adds a scene node animator factory to the scene manager. | ||
468 | virtual void registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd); | ||
469 | |||
470 | //! Returns amount of registered scene node animator factories. | ||
471 | virtual u32 getRegisteredSceneNodeAnimatorFactoryCount() const; | ||
472 | |||
473 | //! Returns a scene node animator factory by index | ||
474 | virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(u32 index); | ||
475 | |||
476 | //! Saves the current scene into a file. | ||
477 | virtual bool saveScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0); | ||
478 | |||
479 | //! Saves the current scene into a file. | ||
480 | virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0); | ||
481 | |||
482 | //! Saves the current scene into a file. | ||
483 | virtual bool saveScene(io::IXMLWriter* writer, const io::path& currentPath, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0); | ||
484 | |||
485 | //! Loads a scene. Note that the current scene is not cleared before. | ||
486 | virtual bool loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0); | ||
487 | |||
488 | //! Loads a scene. Note that the current scene is not cleared before. | ||
489 | virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0); | ||
490 | |||
491 | //! Writes attributes of the scene node. | ||
492 | virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; | ||
493 | |||
494 | //! Reads attributes of the scene node. | ||
495 | virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); | ||
496 | |||
497 | //! Returns a mesh writer implementation if available | ||
498 | virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type); | ||
499 | |||
500 | //! Get a skinned mesh, which is not available as header-only code | ||
501 | virtual ISkinnedMesh* createSkinnedMesh(); | ||
502 | |||
503 | //! Sets ambient color of the scene | ||
504 | virtual void setAmbientLight(const video::SColorf &ambientColor); | ||
505 | |||
506 | //! Returns ambient color of the scene | ||
507 | virtual const video::SColorf& getAmbientLight() const; | ||
508 | |||
509 | //! Register a custom callbacks manager which gets callbacks during scene rendering. | ||
510 | virtual void setLightManager(ILightManager* lightManager); | ||
511 | |||
512 | //! Get current render time. | ||
513 | virtual E_SCENE_NODE_RENDER_PASS getCurrentRendertime() const { return CurrentRendertime; } | ||
514 | |||
515 | //! Set current render time. | ||
516 | virtual void setCurrentRendertime(E_SCENE_NODE_RENDER_PASS currentRendertime) { CurrentRendertime = currentRendertime; } | ||
517 | |||
518 | //! Get an instance of a geometry creator. | ||
519 | virtual const IGeometryCreator* getGeometryCreator(void) const { return GeometryCreator; } | ||
520 | |||
521 | //! returns if node is culled | ||
522 | virtual bool isCulled(const ISceneNode* node) const; | ||
523 | |||
524 | private: | ||
525 | |||
526 | //! clears the deletion list | ||
527 | void clearDeletionList(); | ||
528 | |||
529 | //! writes a scene node | ||
530 | void writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer, const fschar_t* currentPath=0, bool init=false); | ||
531 | |||
532 | struct DefaultNodeEntry | ||
533 | { | ||
534 | DefaultNodeEntry(ISceneNode* n) : | ||
535 | Node(n), TextureValue(0) | ||
536 | { | ||
537 | if (n->getMaterialCount()) | ||
538 | TextureValue = (n->getMaterial(0).getTexture(0)); | ||
539 | } | ||
540 | |||
541 | bool operator < (const DefaultNodeEntry& other) const | ||
542 | { | ||
543 | return (TextureValue < other.TextureValue); | ||
544 | } | ||
545 | |||
546 | ISceneNode* Node; | ||
547 | private: | ||
548 | void* TextureValue; | ||
549 | }; | ||
550 | |||
551 | //! sort on distance (center) to camera | ||
552 | struct TransparentNodeEntry | ||
553 | { | ||
554 | TransparentNodeEntry(ISceneNode* n, const core::vector3df& camera) | ||
555 | : Node(n) | ||
556 | { | ||
557 | Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(camera); | ||
558 | } | ||
559 | |||
560 | bool operator < (const TransparentNodeEntry& other) const | ||
561 | { | ||
562 | return Distance > other.Distance; | ||
563 | } | ||
564 | |||
565 | ISceneNode* Node; | ||
566 | private: | ||
567 | f64 Distance; | ||
568 | }; | ||
569 | |||
570 | //! sort on distance (sphere) to camera | ||
571 | struct DistanceNodeEntry | ||
572 | { | ||
573 | DistanceNodeEntry(ISceneNode* n, const core::vector3df& cameraPos) | ||
574 | : Node(n) | ||
575 | { | ||
576 | setNodeAndDistanceFromPosition(n, cameraPos); | ||
577 | } | ||
578 | |||
579 | bool operator < (const DistanceNodeEntry& other) const | ||
580 | { | ||
581 | return Distance < other.Distance; | ||
582 | } | ||
583 | |||
584 | void setNodeAndDistanceFromPosition(ISceneNode* n, const core::vector3df & fromPosition) | ||
585 | { | ||
586 | Node = n; | ||
587 | Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(fromPosition); | ||
588 | Distance -= Node->getBoundingBox().getExtent().getLengthSQ() * 0.5; | ||
589 | } | ||
590 | |||
591 | ISceneNode* Node; | ||
592 | private: | ||
593 | f64 Distance; | ||
594 | }; | ||
595 | |||
596 | //! video driver | ||
597 | video::IVideoDriver* Driver; | ||
598 | |||
599 | //! file system | ||
600 | io::IFileSystem* FileSystem; | ||
601 | |||
602 | //! GUI Enviroment ( Debug Purpose ) | ||
603 | gui::IGUIEnvironment* GUIEnvironment; | ||
604 | |||
605 | //! cursor control | ||
606 | gui::ICursorControl* CursorControl; | ||
607 | |||
608 | //! collision manager | ||
609 | ISceneCollisionManager* CollisionManager; | ||
610 | |||
611 | //! render pass lists | ||
612 | core::array<ISceneNode*> CameraList; | ||
613 | core::array<ISceneNode*> LightList; | ||
614 | core::array<ISceneNode*> ShadowNodeList; | ||
615 | core::array<ISceneNode*> SkyBoxList; | ||
616 | core::array<DefaultNodeEntry> SolidNodeList; | ||
617 | core::array<TransparentNodeEntry> TransparentNodeList; | ||
618 | core::array<TransparentNodeEntry> TransparentEffectNodeList; | ||
619 | |||
620 | core::array<IMeshLoader*> MeshLoaderList; | ||
621 | core::array<ISceneLoader*> SceneLoaderList; | ||
622 | core::array<ISceneNode*> DeletionList; | ||
623 | core::array<ISceneNodeFactory*> SceneNodeFactoryList; | ||
624 | core::array<ISceneNodeAnimatorFactory*> SceneNodeAnimatorFactoryList; | ||
625 | |||
626 | //! current active camera | ||
627 | ICameraSceneNode* ActiveCamera; | ||
628 | core::vector3df camWorldPos; // Position of camera for transparent nodes. | ||
629 | |||
630 | video::SColor ShadowColor; | ||
631 | video::SColorf AmbientLight; | ||
632 | |||
633 | //! String parameters | ||
634 | // NODE: Attributes are slow and should only be used for debug-info and not in release | ||
635 | io::CAttributes Parameters; | ||
636 | |||
637 | //! Mesh cache | ||
638 | IMeshCache* MeshCache; | ||
639 | |||
640 | E_SCENE_NODE_RENDER_PASS CurrentRendertime; | ||
641 | |||
642 | //! An optional callbacks manager to allow the user app finer control | ||
643 | //! over the scene lighting and rendering. | ||
644 | ILightManager* LightManager; | ||
645 | |||
646 | //! constants for reading and writing XML. | ||
647 | //! Not made static due to portability problems. | ||
648 | const core::stringw IRR_XML_FORMAT_SCENE; | ||
649 | const core::stringw IRR_XML_FORMAT_NODE; | ||
650 | const core::stringw IRR_XML_FORMAT_NODE_ATTR_TYPE; | ||
651 | |||
652 | IGeometryCreator* GeometryCreator; | ||
653 | }; | ||
654 | |||
655 | } // end namespace video | ||
656 | } // end namespace scene | ||
657 | |||
658 | #endif | ||
659 | |||