1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __I_SCENE_MANAGER_H_INCLUDED__
\r
6 #define __I_SCENE_MANAGER_H_INCLUDED__
\r
8 #include "IReferenceCounted.h"
\r
9 #include "irrArray.h"
\r
10 #include "irrString.h"
\r
12 #include "vector3d.h"
\r
13 #include "dimension2d.h"
\r
15 #include "ETerrainElements.h"
\r
16 #include "ESceneNodeTypes.h"
\r
17 #include "EMeshWriterEnums.h"
\r
18 #include "SceneParameters.h"
\r
19 #include "ISkinnedMesh.h"
\r
32 } // end namespace io
\r
37 class IGUIEnvironment;
\r
38 } // end namespace gui
\r
46 } // end namespace video
\r
50 //! Enumeration for render passes.
\r
51 /** A parameter passed to the registerNodeForRendering() method of the ISceneManager,
\r
52 specifying when the node wants to be drawn in relation to the other nodes.
\r
53 Note: Despite the numbering this is not used as bit-field.
\r
55 enum E_SCENE_NODE_RENDER_PASS
\r
57 //! No pass currently active
\r
60 //! Camera pass. The active view is set up here. The very first pass.
\r
63 //! In this pass, lights are transformed into camera space and added to the driver
\r
66 //! This is used for sky boxes.
\r
69 //! All normal objects can use this for registering themselves.
\r
70 /** This value will never be returned by
\r
71 ISceneManager::getSceneNodeRenderPass(). The scene manager
\r
72 will determine by itself if an object is transparent or solid
\r
73 and register the object as ESNRT_TRANSPARENT or ESNRP_SOLID
\r
74 automatically if you call registerNodeForRendering with this
\r
75 value (which is default). Note that it will register the node
\r
76 only as ONE type. If your scene node has both solid and
\r
77 transparent material types register it twice (one time as
\r
78 ESNRP_SOLID, the other time as ESNRT_TRANSPARENT) and in the
\r
79 render() method call getSceneNodeRenderPass() to find out the
\r
80 current render pass and render only the corresponding parts of
\r
82 ESNRP_AUTOMATIC =24,
\r
84 //! Solid scene nodes or special scene nodes without materials.
\r
87 //! Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in that order.
\r
88 ESNRP_TRANSPARENT =16,
\r
90 //! Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and drawn in that order.
\r
91 ESNRP_TRANSPARENT_EFFECT =32,
\r
93 //! Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes
\r
96 //! Drawn after transparent effect nodes. For custom gui's. Unsorted (in order nodes registered themselves).
\r
101 class IAnimatedMesh;
\r
102 class IAnimatedMeshSceneNode;
\r
103 class IBillboardSceneNode;
\r
104 class ICameraSceneNode;
\r
105 class IDummyTransformationSceneNode;
\r
109 class ISceneCollisionManager;
\r
111 class IMeshManipulator;
\r
112 class IMeshSceneNode;
\r
114 class ISceneLoader;
\r
116 class ISceneNodeFactory;
\r
117 class ISceneUserDataSerializer;
\r
119 //! The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff.
\r
120 /** All Scene nodes can be created only here.
\r
121 A scene node is a node in the hierarchical scene graph. Every scene node
\r
122 may have children, which are other scene nodes. Children move relative
\r
123 the their parents position. If the parent of a node is not visible, its
\r
124 children won't be visible, too. In this way, it is for example easily
\r
125 possible to attach a light to a moving car or to place a walking
\r
126 character on a moving platform on a moving ship.
\r
127 The SceneManager is also able to load 3d mesh files of different
\r
128 formats. Take a look at getMesh() to find out what formats are
\r
129 supported. If these formats are not enough, use
\r
130 addExternalMeshLoader() to add new formats to the engine.
\r
132 class ISceneManager : public virtual IReferenceCounted
\r
136 //! Get pointer to an animateable mesh. Loads the file if not loaded already.
\r
138 * If you want to remove a loaded mesh from the cache again, use removeMesh().
\r
139 * Currently there are the following mesh formats supported:
\r
140 * <TABLE border="1" cellpadding="2" cellspacing="0">
\r
143 * <TD>Description</TD>
\r
146 * <TD>3D Studio (.3ds)</TD>
\r
147 * <TD>Loader for 3D-Studio files which lots of 3D packages
\r
148 * are able to export. Only static meshes are currently
\r
149 * supported by this importer.</TD>
\r
152 * <TD>3D World Studio (.smf)</TD>
\r
153 * <TD>Loader for Leadwerks SMF mesh files, a simple mesh format
\r
154 * containing static geometry for games. The proprietary .STF texture format
\r
155 * is not supported yet. This loader was originally written by Joseph Ellis. </TD>
\r
158 * <TD>Bliz Basic B3D (.b3d)</TD>
\r
159 * <TD>Loader for blitz basic files, developed by Mark
\r
160 * Sibly. This is the ideal animated mesh format for game
\r
161 * characters as it is both rigidly defined and widely
\r
162 * supported by modeling and animation software.
\r
163 * As this format supports skeletal animations, an
\r
164 * ISkinnedMesh will be returned by this importer.</TD>
\r
167 * <TD>Cartography shop 4 (.csm)</TD>
\r
168 * <TD>Cartography Shop is a modeling program for creating
\r
169 * architecture and calculating lighting. Irrlicht can
\r
170 * directly import .csm files thanks to the IrrCSM library
\r
171 * created by Saurav Mohapatra which is now integrated
\r
172 * directly in Irrlicht.
\r
175 * <TD>Delgine DeleD (.dmf)</TD>
\r
176 * <TD>DeleD (delgine.com) is a 3D editor and level-editor
\r
177 * combined into one and is specifically designed for 3D
\r
178 * game-development. With this loader, it is possible to
\r
179 * directly load all geometry is as well as textures and
\r
180 * lightmaps from .dmf files. To set texture and
\r
181 * material paths, see scene::DMF_USE_MATERIALS_DIRS.
\r
182 * It is also possible to flip the alpha texture by setting
\r
183 * scene::DMF_FLIP_ALPHA_TEXTURES to true and to set the
\r
184 * material transparent reference value by setting
\r
185 * scene::DMF_ALPHA_CHANNEL_REF to a float between 0 and
\r
186 * 1. The loader is based on Salvatore Russo's .dmf
\r
187 * loader, I just changed some parts of it. Thanks to
\r
188 * Salvatore for his work and for allowing me to use his
\r
189 * code in Irrlicht and put it under Irrlicht's license.
\r
190 * For newer and more enhanced versions of the loader,
\r
191 * take a look at delgine.com.
\r
195 * <TD>DirectX (.x)</TD>
\r
196 * <TD>Platform independent importer (so not D3D-only) for
\r
197 * .x files. Most 3D packages can export these natively
\r
198 * and there are several tools for them available, e.g.
\r
199 * the Maya exporter included in the DX SDK.
\r
200 * .x files can include skeletal animations and Irrlicht
\r
201 * is able to play and display them, users can manipulate
\r
202 * the joints via the ISkinnedMesh interface. Currently,
\r
203 * Irrlicht only supports uncompressed .x files.</TD>
\r
206 * <TD>Half-Life model (.mdl)</TD>
\r
207 * <TD>This loader opens Half-life 1 models, it was contributed
\r
208 * by Fabio Concas and adapted by Thomas Alten.</TD>
\r
211 * <TD>LightWave (.lwo)</TD>
\r
212 * <TD>Native to NewTek's LightWave 3D, the LWO format is well
\r
213 * known and supported by many exporters. This loader will
\r
214 * import LWO2 models including lightmaps, bumpmaps and
\r
215 * reflection textures.</TD>
\r
218 * <TD>Maya (.obj)</TD>
\r
219 * <TD>Most 3D software can create .obj files which contain
\r
220 * static geometry without material data. The material
\r
221 * files .mtl are also supported. This importer for
\r
222 * Irrlicht can load them directly. </TD>
\r
225 * <TD>Milkshape (.ms3d)</TD>
\r
226 * <TD>.MS3D files contain models and sometimes skeletal
\r
227 * animations from the Milkshape 3D modeling and animation
\r
228 * software. Like the other skeletal mesh loaders, joints
\r
229 * are exposed via the ISkinnedMesh animated mesh type.</TD>
\r
232 * <TD>My3D (.my3d)</TD>
\r
233 * <TD>.my3D is a flexible 3D file format. The My3DTools
\r
234 * contains plug-ins to export .my3D files from several
\r
235 * 3D packages. With this built-in importer, Irrlicht
\r
236 * can read and display those files directly. This
\r
237 * loader was written by Zhuck Dimitry who also created
\r
238 * the whole My3DTools package.
\r
242 * <TD>OCT (.oct)</TD>
\r
243 * <TD>The oct file format contains 3D geometry and
\r
244 * lightmaps and can be loaded directly by Irrlicht. OCT
\r
245 * files<br> can be created by FSRad, Paul Nette's
\r
246 * radiosity processor or exported from Blender using
\r
247 * OCTTools which can be found in the exporters/OCTTools
\r
248 * directory of the SDK. Thanks to Murphy McCauley for
\r
249 * creating all this.</TD>
\r
252 * <TD>OGRE Meshes (.mesh)</TD>
\r
253 * <TD>Ogre .mesh files contain 3D data for the OGRE 3D
\r
254 * engine. Irrlicht can read and display them directly
\r
255 * with this importer. To define materials for the mesh,
\r
256 * copy a .material file named like the corresponding
\r
257 * .mesh file where the .mesh file is. (For example
\r
258 * ogrehead.material for ogrehead.mesh). Thanks to
\r
259 * Christian Stehno who wrote and contributed this
\r
263 * <TD>Pulsar LMTools (.lmts)</TD>
\r
264 * <TD>LMTools is a set of tools (Windows & Linux) for
\r
265 * creating lightmaps. Irrlicht can directly read .lmts
\r
266 * files thanks to<br> the importer created by Jonas
\r
268 * Notes for<br> this version of the loader:<br>
\r
269 * - It does not recognize/support user data in the
\r
270 * *.lmts files.<br>
\r
271 * - The TGAs generated by LMTools don't work in
\r
272 * Irrlicht for some reason (the textures are upside
\r
273 * down). Opening and resaving them in a graphics app
\r
274 * will solve the problem.</TD>
\r
277 * <TD>Quake 3 levels (.bsp)</TD>
\r
278 * <TD>Quake 3 is a popular game by IDSoftware, and .pk3
\r
279 * files contain .bsp files and textures/lightmaps
\r
280 * describing huge prelighted levels. Irrlicht can read
\r
281 * .pk3 and .bsp files directly and thus render Quake 3
\r
282 * levels directly. Written by Nikolaus Gebhardt
\r
283 * enhanced by Dean P. Macri with the curved surfaces
\r
287 * <TD>Quake 2 models (.md2)</TD>
\r
288 * <TD>Quake 2 models are characters with morph target
\r
289 * animation. Irrlicht can read, display and animate
\r
290 * them directly with this importer. </TD>
\r
293 * <TD>Quake 3 models (.md3)</TD>
\r
294 * <TD>Quake 3 models are characters with morph target
\r
295 * animation, they contain mount points for weapons and body
\r
296 * parts and are typically made of several sections which are
\r
297 * manually joined together.</TD>
\r
300 * <TD>Stanford Triangle (.ply)</TD>
\r
301 * <TD>Invented by Stanford University and known as the native
\r
302 * format of the infamous "Stanford Bunny" model, this is a
\r
303 * popular static mesh format used by 3D scanning hardware
\r
304 * and software. This loader supports extremely large models
\r
305 * in both ASCII and binary format, but only has rudimentary
\r
306 * material support in the form of vertex colors and texture
\r
307 * coordinates.</TD>
\r
310 * <TD>Stereolithography (.stl)</TD>
\r
311 * <TD>The STL format is used for rapid prototyping and
\r
312 * computer-aided manufacturing, thus has no support for
\r
317 * To load and display a mesh quickly, just do this:
\r
319 * SceneManager->addAnimatedMeshSceneNode(
\r
320 * SceneManager->getMesh("yourmesh.3ds"));
\r
322 * If you would like to implement and add your own file format loader to Irrlicht,
\r
323 * see addExternalMeshLoader().
\r
324 * \param filename: Filename of the mesh to load.
\r
325 * \param alternativeCacheName: In case you want to have the mesh under another name in the cache (to create real copies)
\r
326 * \return Null if failed, otherwise pointer to the mesh.
\r
327 * This pointer should not be dropped. See IReferenceCounted::drop() for more information.
\r
329 virtual IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName=io::path("")) = 0;
\r
331 //! Get pointer to an animateable mesh. Loads the file if not loaded already.
\r
332 /** Works just as getMesh(const char* filename). If you want to
\r
333 remove a loaded mesh from the cache again, use removeMesh().
\r
334 \param file File handle of the mesh to load.
\r
335 \return NULL if failed and pointer to the mesh if successful.
\r
336 This pointer should not be dropped. See
\r
337 IReferenceCounted::drop() for more information. */
\r
338 virtual IAnimatedMesh* getMesh(io::IReadFile* file) = 0;
\r
340 //! Get interface to the mesh cache which is shared between all existing scene managers.
\r
341 /** With this interface, it is possible to manually add new loaded
\r
342 meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate
\r
343 through already loaded meshes. */
\r
344 virtual IMeshCache* getMeshCache() = 0;
\r
346 //! Get the video driver.
\r
347 /** \return Pointer to the video Driver.
\r
348 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
349 virtual video::IVideoDriver* getVideoDriver() = 0;
\r
351 //! Get the active GUIEnvironment
\r
352 /** \return Pointer to the GUIEnvironment
\r
353 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
354 virtual gui::IGUIEnvironment* getGUIEnvironment() = 0;
\r
356 //! Get the active FileSystem
\r
357 /** \return Pointer to the FileSystem
\r
358 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
359 virtual io::IFileSystem* getFileSystem() = 0;
\r
361 //! Adds a scene node for rendering an animated mesh model.
\r
362 /** \param mesh: Pointer to the loaded animated mesh to be displayed.
\r
363 \param parent: Parent of the scene node. Can be NULL if no parent.
\r
364 \param id: Id of the node. This id can be used to identify the scene node.
\r
365 \param position: Position of the space relative to its parent where the
\r
366 scene node will be placed.
\r
367 \param rotation: Initial rotation of the scene node.
\r
368 \param scale: Initial scale of the scene node.
\r
369 \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
\r
370 \return Pointer to the created scene node.
\r
371 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
372 virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh,
\r
373 ISceneNode* parent=0, s32 id=-1,
\r
374 const core::vector3df& position = core::vector3df(0,0,0),
\r
375 const core::vector3df& rotation = core::vector3df(0,0,0),
\r
376 const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f),
\r
377 bool alsoAddIfMeshPointerZero=false) = 0;
\r
379 //! Adds a scene node for rendering a static mesh.
\r
380 /** \param mesh: Pointer to the loaded static mesh to be displayed.
\r
381 \param parent: Parent of the scene node. Can be NULL if no parent.
\r
382 \param id: Id of the node. This id can be used to identify the scene node.
\r
383 \param position: Position of the space relative to its parent where the
\r
384 scene node will be placed.
\r
385 \param rotation: Initial rotation of the scene node.
\r
386 \param scale: Initial scale of the scene node.
\r
387 \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
\r
388 \return Pointer to the created scene node.
\r
389 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
390 virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1,
\r
391 const core::vector3df& position = core::vector3df(0,0,0),
\r
392 const core::vector3df& rotation = core::vector3df(0,0,0),
\r
393 const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f),
\r
394 bool alsoAddIfMeshPointerZero=false) = 0;
\r
396 //! Adds a camera scene node to the scene graph and sets it as active camera.
\r
397 /** This camera does not react on user input.
\r
398 If you want to move or animate it, use ISceneNode::setPosition(),
\r
399 ICameraSceneNode::setTarget() etc methods.
\r
400 By default, a camera's look at position (set with setTarget()) and its scene node
\r
401 rotation (set with setRotation()) are independent. If you want to be able to
\r
402 control the direction that the camera looks by using setRotation() then call
\r
403 ICameraSceneNode::bindTargetAndRotation(true) on it.
\r
404 \param position: Position of the space relative to its parent where the camera will be placed.
\r
405 \param lookat: Position where the camera will look at. Also known as target.
\r
406 \param parent: Parent scene node of the camera. Can be null. If the parent moves,
\r
407 the camera will move too.
\r
408 \param id: id of the camera. This id can be used to identify the camera.
\r
409 \param makeActive Flag whether this camera should become the active one.
\r
410 Make sure you always have one active camera.
\r
411 \return Pointer to interface to camera if successful, otherwise 0.
\r
412 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
413 virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0,
\r
414 const core::vector3df& position = core::vector3df(0,0,0),
\r
415 const core::vector3df& lookat = core::vector3df(0,0,100),
\r
416 s32 id=-1, bool makeActive=true) = 0;
\r
418 //! Adds a billboard scene node to the scene graph.
\r
419 /** A billboard is like a 3d sprite: A 2d element,
\r
420 which always looks to the camera. It is usually used for things
\r
421 like explosions, fire, lensflares and things like that.
\r
422 \param parent Parent scene node of the billboard. Can be null.
\r
423 If the parent moves, the billboard will move too.
\r
424 \param size Size of the billboard. This size is 2 dimensional
\r
425 because a billboard only has width and height.
\r
426 \param position Position of the space relative to its parent
\r
427 where the billboard will be placed.
\r
428 \param id An id of the node. This id can be used to identify
\r
430 \param colorTop The color of the vertices at the top of the
\r
431 billboard (default: white).
\r
432 \param colorBottom The color of the vertices at the bottom of
\r
433 the billboard (default: white).
\r
434 \return Pointer to the billboard if successful, otherwise NULL.
\r
435 This pointer should not be dropped. See
\r
436 IReferenceCounted::drop() for more information. */
\r
437 virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0,
\r
438 const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f),
\r
439 const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1,
\r
440 video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0;
\r
442 //! Adds an empty scene node to the scene graph.
\r
443 /** Can be used for doing advanced transformations
\r
444 or structuring the scene graph.
\r
445 \return Pointer to the created scene node.
\r
446 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
447 virtual ISceneNode* addEmptySceneNode(ISceneNode* parent=0, s32 id=-1) = 0;
\r
449 //! Adds a dummy transformation scene node to the scene graph.
\r
450 /** This scene node does not render itself, and does not respond to set/getPosition,
\r
451 set/getRotation and set/getScale. Its just a simple scene node that takes a
\r
452 matrix as relative transformation, making it possible to insert any transformation
\r
453 anywhere into the scene graph.
\r
454 \return Pointer to the created scene node.
\r
455 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
456 virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode(
\r
457 ISceneNode* parent=0, s32 id=-1) = 0;
\r
459 //! Gets the root scene node.
\r
460 /** This is the scene node which is parent
\r
461 of all scene nodes. The root scene node is a special scene node which
\r
462 only exists to manage all scene nodes. It will not be rendered and cannot
\r
463 be removed from the scene.
\r
464 \return Pointer to the root scene node.
\r
465 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
466 virtual ISceneNode* getRootSceneNode() = 0;
\r
468 //! Get the first scene node with the specified id.
\r
469 /** \param id: The id to search for
\r
470 \param start: Scene node to start from. All children of this scene
\r
471 node are searched. If null is specified, the root scene node is
\r
473 \return Pointer to the first scene node with this id,
\r
474 and null if no scene node could be found.
\r
475 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
476 virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0) = 0;
\r
478 //! Get the first scene node with the specified name.
\r
479 /** \param name: The name to search for
\r
480 \param start: Scene node to start from. All children of this scene
\r
481 node are searched. If null is specified, the root scene node is
\r
483 \return Pointer to the first scene node with this id,
\r
484 and null if no scene node could be found.
\r
485 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
486 virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0) = 0;
\r
488 //! Get the first scene node with the specified type.
\r
489 /** \param type: The type to search for
\r
490 \param start: Scene node to start from. All children of this scene
\r
491 node are searched. If null is specified, the root scene node is
\r
493 \return Pointer to the first scene node with this type,
\r
494 and null if no scene node could be found.
\r
495 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
496 virtual ISceneNode* getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode* start=0) = 0;
\r
498 //! Get scene nodes by type.
\r
499 /** \param type: Type of scene node to find (ESNT_ANY will return all child nodes).
\r
500 \param outNodes: results will be added to this array (outNodes is not cleared).
\r
501 \param start: Scene node to start from. This node and all children of this scene
\r
502 node are checked (recursively, so also children of children, etc). If null is specified,
\r
503 the root scene node is taken as start-node. */
\r
504 virtual void getSceneNodesFromType(ESCENE_NODE_TYPE type,
\r
505 core::array<scene::ISceneNode*>& outNodes,
\r
506 ISceneNode* start=0) = 0;
\r
508 //! Get the current active camera.
\r
509 /** \return The active camera is returned. Note that this can
\r
510 be NULL, if there was no camera created yet.
\r
511 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
512 virtual ICameraSceneNode* getActiveCamera() const =0;
\r
514 //! Sets the currently active camera.
\r
515 /** The previous active camera will be deactivated.
\r
516 \param camera: The new camera which should be active. */
\r
517 virtual void setActiveCamera(ICameraSceneNode* camera) = 0;
\r
519 //! Registers a node for rendering it at a specific time.
\r
520 /** This method should only be used by SceneNodes when they get a
\r
521 ISceneNode::OnRegisterSceneNode() call.
\r
522 \param node: Node to register for drawing. Usually scene nodes would set 'this'
\r
523 as parameter here because they want to be drawn.
\r
524 \param pass: Specifies when the node wants to be drawn in relation to the other nodes.
\r
525 For example, if the node is a shadow, it usually wants to be drawn after all other nodes
\r
526 and will use ESNRP_SHADOW for this. See scene::E_SCENE_NODE_RENDER_PASS for details.
\r
527 Note: This is _not_ a bitfield. If you want to register a note for several render passes, then
\r
528 call this function once for each pass.
\r
529 \return scene will be rendered ( passed culling ) */
\r
530 virtual u32 registerNodeForRendering(ISceneNode* node,
\r
531 E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0;
\r
533 //! Clear all nodes which are currently registered for rendering
\r
534 /** Usually you don't have to care about this as drawAll will clear nodes
\r
535 after rendering them. But sometimes you might have to manully reset this.
\r
536 For example when you deleted nodes between registering and rendering. */
\r
537 virtual void clearAllRegisteredNodesForRendering() = 0;
\r
539 //! Draws all the scene nodes.
\r
540 /** This can only be invoked between
\r
541 IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that
\r
542 the scene is not only drawn when calling this, but also animated
\r
543 by existing scene node animators, culling of scene nodes is done, etc. */
\r
544 virtual void drawAll() = 0;
\r
546 //! Adds an external mesh loader for extending the engine with new file formats.
\r
547 /** If you want the engine to be extended with
\r
548 file formats it currently is not able to load (e.g. .cob), just implement
\r
549 the IMeshLoader interface in your loading class and add it with this method.
\r
550 Using this method it is also possible to override built-in mesh loaders with
\r
551 newer or updated versions without the need to recompile the engine.
\r
552 \param externalLoader: Implementation of a new mesh loader. */
\r
553 virtual void addExternalMeshLoader(IMeshLoader* externalLoader) = 0;
\r
555 //! Returns the number of mesh loaders supported by Irrlicht at this time
\r
556 virtual u32 getMeshLoaderCount() const = 0;
\r
558 //! Retrieve the given mesh loader
\r
559 /** \param index The index of the loader to retrieve. This parameter is an 0-based
\r
561 \return A pointer to the specified loader, 0 if the index is incorrect. */
\r
562 virtual IMeshLoader* getMeshLoader(u32 index) const = 0;
\r
564 //! Adds an external scene loader for extending the engine with new file formats.
\r
565 /** If you want the engine to be extended with
\r
566 file formats it currently is not able to load (e.g. .vrml), just implement
\r
567 the ISceneLoader interface in your loading class and add it with this method.
\r
568 Using this method it is also possible to override the built-in scene loaders
\r
569 with newer or updated versions without the need to recompile the engine.
\r
570 \param externalLoader: Implementation of a new mesh loader. */
\r
571 virtual void addExternalSceneLoader(ISceneLoader* externalLoader) = 0;
\r
573 //! Returns the number of scene loaders supported by Irrlicht at this time
\r
574 virtual u32 getSceneLoaderCount() const = 0;
\r
576 //! Retrieve the given scene loader
\r
577 /** \param index The index of the loader to retrieve. This parameter is an 0-based
\r
579 \return A pointer to the specified loader, 0 if the index is incorrect. */
\r
580 virtual ISceneLoader* getSceneLoader(u32 index) const = 0;
\r
582 //! Get pointer to the scene collision manager.
\r
583 /** \return Pointer to the collision manager
\r
584 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
585 virtual ISceneCollisionManager* getSceneCollisionManager() = 0;
\r
587 //! Get pointer to the mesh manipulator.
\r
588 /** \return Pointer to the mesh manipulator
\r
589 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
590 virtual IMeshManipulator* getMeshManipulator() = 0;
\r
592 //! Adds a scene node to the deletion queue.
\r
593 /** The scene node is immediately
\r
594 deleted when it's secure. Which means when the scene node does not
\r
595 execute animators and things like that. This method is for example
\r
596 used for deleting scene nodes by their scene node animators. In
\r
597 most other cases, a ISceneNode::remove() call is enough, using this
\r
598 deletion queue is not necessary.
\r
599 See ISceneManager::createDeleteAnimator() for details.
\r
600 \param node: Node to delete. */
\r
601 virtual void addToDeletionQueue(ISceneNode* node) = 0;
\r
603 //! Posts an input event to the environment.
\r
604 /** Usually you do not have to
\r
605 use this method, it is used by the internal engine. */
\r
606 virtual bool postEventFromUser(const SEvent& event) = 0;
\r
608 //! Clears the whole scene.
\r
609 /** All scene nodes are removed. */
\r
610 virtual void clear() = 0;
\r
612 //! Get interface to the parameters set in this scene.
\r
613 /** String parameters can be used by plugins and mesh loaders.
\r
614 See COLLADA_CREATE_SCENE_INSTANCES and DMF_USE_MATERIALS_DIRS */
\r
615 virtual io::IAttributes* getParameters() = 0;
\r
617 //! Get current render pass.
\r
618 /** All scene nodes are being rendered in a specific order.
\r
619 First lights, cameras, sky boxes, solid geometry, and then transparent
\r
620 stuff. During the rendering process, scene nodes may want to know what the scene
\r
621 manager is rendering currently, because for example they registered for rendering
\r
622 twice, once for transparent geometry and once for solid. When knowing what rendering
\r
623 pass currently is active they can render the correct part of their geometry. */
\r
624 virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const = 0;
\r
626 //! Get the default scene node factory which can create all built in scene nodes
\r
627 /** \return Pointer to the default scene node factory
\r
628 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
629 virtual ISceneNodeFactory* getDefaultSceneNodeFactory() = 0;
\r
631 //! Adds a scene node factory to the scene manager.
\r
632 /** Use this to extend the scene manager with new scene node types which it should be
\r
633 able to create automatically, for example when loading data from xml files. */
\r
634 virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) = 0;
\r
636 //! Get amount of registered scene node factories.
\r
637 virtual u32 getRegisteredSceneNodeFactoryCount() const = 0;
\r
639 //! Get a scene node factory by index
\r
640 /** \return Pointer to the requested scene node factory, or 0 if it does not exist.
\r
641 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
642 virtual ISceneNodeFactory* getSceneNodeFactory(u32 index) = 0;
\r
644 //! Get typename from a scene node type or null if not found
\r
645 virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type) = 0;
\r
647 //! Adds a scene node to the scene by name
\r
648 /** \return Pointer to the scene node added by a factory
\r
649 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
650 virtual ISceneNode* addSceneNode(const char* sceneNodeTypeName, ISceneNode* parent=0) = 0;
\r
652 //! Creates a new scene manager.
\r
653 /** This can be used to easily draw and/or store two
\r
654 independent scenes at the same time. The mesh cache will be
\r
655 shared between all existing scene managers, which means if you
\r
656 load a mesh in the original scene manager using for example
\r
657 getMesh(), the mesh will be available in all other scene
\r
658 managers too, without loading.
\r
659 The original/main scene manager will still be there and
\r
660 accessible via IrrlichtDevice::getSceneManager(). If you need
\r
661 input event in this new scene manager, for example for FPS
\r
662 cameras, you'll need to forward input to this manually: Just
\r
663 implement an IEventReceiver and call
\r
664 yourNewSceneManager->postEventFromUser(), and return true so
\r
665 that the original scene manager doesn't get the event.
\r
666 Otherwise, all input will go to the main scene manager
\r
668 If you no longer need the new scene manager, you should call
\r
669 ISceneManager::drop().
\r
670 See IReferenceCounted::drop() for more information. */
\r
671 virtual ISceneManager* createNewSceneManager(bool cloneContent=false) = 0;
\r
673 //! Saves the current scene into a file.
\r
674 /** Scene nodes with the option isDebugObject set to true are
\r
675 not being saved. The scene is usually written to an .irr file,
\r
676 an xml based format. .irr files can Be edited with the Irrlicht
\r
677 Engine Editor, irrEdit (http://www.ambiera.com/irredit/). To
\r
678 load .irr files again, see ISceneManager::loadScene().
\r
679 \param filename Name of the file.
\r
680 \param userDataSerializer If you want to save some user data
\r
681 for every scene node into the file, implement the
\r
682 ISceneUserDataSerializer interface and provide it as parameter
\r
683 here. Otherwise, simply specify 0 as this parameter.
\r
684 \param node Node which is taken as the top node of the scene.
\r
685 This node and all of its descendants are saved into the scene
\r
686 file. Pass 0 or the scene manager to save the full scene (which
\r
687 is also the default).
\r
688 \return True if successful. */
\r
689 virtual bool saveScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0) = 0;
\r
691 //! Saves the current scene into a file.
\r
692 /** Scene nodes with the option isDebugObject set to true are
\r
693 not being saved. The scene is usually written to an .irr file,
\r
694 an xml based format. .irr files can Be edited with the Irrlicht
\r
695 Engine Editor, irrEdit (http://www.ambiera.com/irredit/). To
\r
696 load .irr files again, see ISceneManager::loadScene().
\r
697 \param file File where the scene is saved into.
\r
698 \param userDataSerializer If you want to save some user data
\r
699 for every scene node into the file, implement the
\r
700 ISceneUserDataSerializer interface and provide it as parameter
\r
701 here. Otherwise, simply specify 0 as this parameter.
\r
702 \param node Node which is taken as the top node of the scene.
\r
703 This node and all of its descendants are saved into the scene
\r
704 file. Pass 0 or the scene manager to save the full scene (which
\r
705 is also the default).
\r
706 \return True if successful. */
\r
707 virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0) = 0;
\r
709 //! Loads a scene. Note that the current scene is not cleared before.
\r
710 /** The scene is usually loaded from an .irr file, an xml based
\r
711 format, but other scene formats can be added to the engine via
\r
712 ISceneManager::addExternalSceneLoader. .irr files can Be edited
\r
713 with the Irrlicht Engine Editor, irrEdit
\r
714 (http://www.ambiera.com/irredit/) or saved directly by the engine
\r
715 using ISceneManager::saveScene().
\r
716 \param filename Name of the file to load from.
\r
717 \param userDataSerializer If you want to load user data
\r
718 possibily saved in that file for some scene nodes in the file,
\r
719 implement the ISceneUserDataSerializer interface and provide it
\r
720 as parameter here. Otherwise, simply specify 0 as this
\r
722 \param rootNode Node which is taken as the root node of the
\r
723 scene. Pass 0 to add the scene directly to the scene manager
\r
724 (which is also the default).
\r
725 \return True if successful. */
\r
726 virtual bool loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0) = 0;
\r
728 //! Loads a scene. Note that the current scene is not cleared before.
\r
729 /** The scene is usually loaded from an .irr file, an xml based
\r
730 format, but other scene formats can be added to the engine via
\r
731 ISceneManager::addExternalSceneLoader. .irr files can Be edited
\r
732 with the Irrlicht Engine Editor, irrEdit
\r
733 (http://www.ambiera.com/irredit/) or saved directly by the engine
\r
734 using ISceneManager::saveScene().
\r
735 \param file File where the scene is loaded from.
\r
736 \param userDataSerializer If you want to load user data
\r
737 saved in that file for some scene nodes in the file,
\r
738 implement the ISceneUserDataSerializer interface and provide it
\r
739 as parameter here. Otherwise, simply specify 0 as this
\r
741 \param rootNode Node which is taken as the root node of the
\r
742 scene. Pass 0 to add the scene directly to the scene manager
\r
743 (which is also the default).
\r
744 \return True if successful. */
\r
745 virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0) = 0;
\r
747 //! Get a mesh writer implementation if available
\r
748 /** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop()
\r
750 virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type) = 0;
\r
752 //! Get a skinned mesh, which is not available as header-only code
\r
753 /** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop()
\r
755 virtual ISkinnedMesh* createSkinnedMesh() = 0;
\r
757 //! Sets ambient color of the scene
\r
758 virtual void setAmbientLight(const video::SColorf &ambientColor) = 0;
\r
760 //! Get ambient color of the scene
\r
761 virtual const video::SColorf& getAmbientLight() const = 0;
\r
763 //! Get current render pass.
\r
764 virtual E_SCENE_NODE_RENDER_PASS getCurrentRenderPass() const =0;
\r
766 //! Set current render pass.
\r
767 virtual void setCurrentRenderPass(E_SCENE_NODE_RENDER_PASS nextPass) =0;
\r
769 //! Check if node is culled in current view frustum
\r
770 /** Please note that depending on the used culling method this
\r
771 check can be rather coarse, or slow. A positive result is
\r
772 correct, though, i.e. if this method returns true the node is
\r
773 positively not visible. The node might still be invisible even
\r
774 if this method returns false.
\r
775 \param node The scene node which is checked for culling.
\r
776 \return True if node is not visible in the current scene, else
\r
778 virtual bool isCulled(const ISceneNode* node) const =0;
\r
782 } // end namespace scene
\r
783 } // end namespace irr
\r