~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CSceneManager.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 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.0f, f32 zoomSpeed = 200.0f,
 
144
                        f32 translationSpeed = 1500.0f, s32 id=-1,
 
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
                //! Loads a scene. Note that the current scene is not cleared before.
 
483
                virtual bool loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0);
 
484
 
 
485
                //! Loads a scene. Note that the current scene is not cleared before.
 
486
                virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0);
 
487
 
 
488
                //! Writes attributes of the scene node.
 
489
                virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
 
490
 
 
491
                //! Reads attributes of the scene node.
 
492
                virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
 
493
 
 
494
                //! Returns a mesh writer implementation if available
 
495
                virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type);
 
496
 
 
497
                //! Get a skinned mesh, which is not available as header-only code
 
498
                virtual ISkinnedMesh* createSkinnedMesh();
 
499
 
 
500
                //! Sets ambient color of the scene
 
501
                virtual void setAmbientLight(const video::SColorf &ambientColor);
 
502
 
 
503
                //! Returns ambient color of the scene
 
504
                virtual const video::SColorf& getAmbientLight() const;
 
505
 
 
506
                //! Register a custom callbacks manager which gets callbacks during scene rendering.
 
507
                virtual void setLightManager(ILightManager* lightManager);
 
508
 
 
509
                //! Get an instance of a geometry creator.
 
510
                virtual const IGeometryCreator* getGeometryCreator(void) const { return GeometryCreator; }
 
511
 
 
512
                //! returns if node is culled
 
513
                virtual bool isCulled(const ISceneNode* node) const;
 
514
 
 
515
        private:
 
516
 
 
517
                //! clears the deletion list
 
518
                void clearDeletionList();
 
519
 
 
520
                //! writes a scene node
 
521
                void writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer, const fschar_t* currentPath=0, bool init=false);
 
522
 
 
523
                struct DefaultNodeEntry
 
524
                {
 
525
                        DefaultNodeEntry(ISceneNode* n) :
 
526
                                Node(n), TextureValue(0)
 
527
                        {
 
528
                                if (n->getMaterialCount())
 
529
                                        TextureValue = (n->getMaterial(0).getTexture(0));
 
530
                        }
 
531
 
 
532
                        bool operator < (const DefaultNodeEntry& other) const
 
533
                        {
 
534
                                return (TextureValue < other.TextureValue);
 
535
                        }
 
536
 
 
537
                        ISceneNode* Node;
 
538
                        private:
 
539
                        void* TextureValue;
 
540
                };
 
541
 
 
542
                //! sort on distance (center) to camera
 
543
                struct TransparentNodeEntry
 
544
                {
 
545
                        TransparentNodeEntry(ISceneNode* n, const core::vector3df& camera)
 
546
                                : Node(n)
 
547
                        {
 
548
                                Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(camera);
 
549
                        }
 
550
 
 
551
                        bool operator < (const TransparentNodeEntry& other) const
 
552
                        {
 
553
                                return Distance > other.Distance;
 
554
                        }
 
555
 
 
556
                        ISceneNode* Node;
 
557
                        private:
 
558
                                f64 Distance;
 
559
                };
 
560
 
 
561
                //! sort on distance (sphere) to camera
 
562
                struct DistanceNodeEntry
 
563
                {
 
564
                        DistanceNodeEntry(ISceneNode* n, const core::vector3df& cameraPos)
 
565
                                : Node(n)
 
566
                        {
 
567
                                setNodeAndDistanceFromPosition(n, cameraPos);
 
568
                        }
 
569
 
 
570
                        bool operator < (const DistanceNodeEntry& other) const
 
571
                        {
 
572
                                return Distance < other.Distance;
 
573
                        }
 
574
 
 
575
                        void setNodeAndDistanceFromPosition(ISceneNode* n, const core::vector3df & fromPosition)
 
576
                        {
 
577
                                Node = n;
 
578
                                Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(fromPosition);
 
579
                                Distance -= Node->getBoundingBox().getExtent().getLengthSQ() * 0.5;
 
580
                        }
 
581
 
 
582
                        ISceneNode* Node;
 
583
                        private:
 
584
                        f64 Distance;
 
585
                };
 
586
 
 
587
                //! video driver
 
588
                video::IVideoDriver* Driver;
 
589
 
 
590
                //! file system
 
591
                io::IFileSystem* FileSystem;
 
592
 
 
593
                //! GUI Enviroment ( Debug Purpose )
 
594
                gui::IGUIEnvironment* GUIEnvironment;
 
595
 
 
596
                //! cursor control
 
597
                gui::ICursorControl* CursorControl;
 
598
 
 
599
                //! collision manager
 
600
                ISceneCollisionManager* CollisionManager;
 
601
 
 
602
                //! render pass lists
 
603
                core::array<ISceneNode*> CameraList;
 
604
                core::array<ISceneNode*> LightList;
 
605
                core::array<ISceneNode*> ShadowNodeList;
 
606
                core::array<ISceneNode*> SkyBoxList;
 
607
                core::array<DefaultNodeEntry> SolidNodeList;
 
608
                core::array<TransparentNodeEntry> TransparentNodeList;
 
609
                core::array<TransparentNodeEntry> TransparentEffectNodeList;
 
610
 
 
611
                core::array<IMeshLoader*> MeshLoaderList;
 
612
                core::array<ISceneLoader*> SceneLoaderList;
 
613
                core::array<ISceneNode*> DeletionList;
 
614
                core::array<ISceneNodeFactory*> SceneNodeFactoryList;
 
615
                core::array<ISceneNodeAnimatorFactory*> SceneNodeAnimatorFactoryList;
 
616
 
 
617
                //! current active camera
 
618
                ICameraSceneNode* ActiveCamera;
 
619
                core::vector3df camWorldPos; // Position of camera for transparent nodes.
 
620
 
 
621
                video::SColor ShadowColor;
 
622
                video::SColorf AmbientLight;
 
623
 
 
624
                //! String parameters
 
625
                io::CAttributes Parameters;
 
626
 
 
627
                //! Mesh cache
 
628
                IMeshCache* MeshCache;
 
629
 
 
630
                E_SCENE_NODE_RENDER_PASS CurrentRendertime;
 
631
 
 
632
                //! An optional callbacks manager to allow the user app finer control
 
633
                //! over the scene lighting and rendering.
 
634
                ILightManager* LightManager;
 
635
 
 
636
                //! constants for reading and writing XML.
 
637
                //! Not made static due to portability problems.
 
638
                const core::stringw IRR_XML_FORMAT_SCENE;
 
639
                const core::stringw IRR_XML_FORMAT_NODE;
 
640
                const core::stringw IRR_XML_FORMAT_NODE_ATTR_TYPE;
 
641
 
 
642
                IGeometryCreator* GeometryCreator;
 
643
        };
 
644
 
 
645
} // end namespace video
 
646
} // end namespace scene
 
647
 
 
648
#endif
 
649