ISceneManager.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. #pragma once
  5. #include "IReferenceCounted.h"
  6. #include "irrArray.h"
  7. #include "irrString.h"
  8. #include "path.h"
  9. #include "vector3d.h"
  10. #include "dimension2d.h"
  11. #include "SColor.h"
  12. #include "ESceneNodeTypes.h"
  13. #include "SceneParameters.h"
  14. #include "ISkinnedMesh.h"
  15. namespace irr
  16. {
  17. struct SKeyMap;
  18. struct SEvent;
  19. namespace io
  20. {
  21. class IReadFile;
  22. class IAttributes;
  23. class IWriteFile;
  24. class IFileSystem;
  25. } // end namespace io
  26. namespace gui
  27. {
  28. class IGUIFont;
  29. class IGUIEnvironment;
  30. } // end namespace gui
  31. namespace video
  32. {
  33. class IVideoDriver;
  34. class SMaterial;
  35. class IImage;
  36. class ITexture;
  37. } // end namespace video
  38. namespace scene
  39. {
  40. //! Enumeration for render passes.
  41. /** A parameter passed to the registerNodeForRendering() method of the ISceneManager,
  42. specifying when the node wants to be drawn in relation to the other nodes.
  43. Note: Despite the numbering this is not used as bit-field.
  44. */
  45. enum E_SCENE_NODE_RENDER_PASS
  46. {
  47. //! No pass currently active
  48. ESNRP_NONE = 0,
  49. //! Camera pass. The active view is set up here. The very first pass.
  50. ESNRP_CAMERA = 1,
  51. //! In this pass, lights are transformed into camera space and added to the driver
  52. ESNRP_LIGHT = 2,
  53. //! This is used for sky boxes.
  54. ESNRP_SKY_BOX = 4,
  55. //! All normal objects can use this for registering themselves.
  56. /** This value will never be returned by
  57. ISceneManager::getSceneNodeRenderPass(). The scene manager
  58. will determine by itself if an object is transparent or solid
  59. and register the object as ESNRT_TRANSPARENT or ESNRP_SOLID
  60. automatically if you call registerNodeForRendering with this
  61. value (which is default). Note that it will register the node
  62. only as ONE type. If your scene node has both solid and
  63. transparent material types register it twice (one time as
  64. ESNRP_SOLID, the other time as ESNRT_TRANSPARENT) and in the
  65. render() method call getSceneNodeRenderPass() to find out the
  66. current render pass and render only the corresponding parts of
  67. the node. */
  68. ESNRP_AUTOMATIC = 24,
  69. //! Solid scene nodes or special scene nodes without materials.
  70. ESNRP_SOLID = 8,
  71. //! Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in that order.
  72. ESNRP_TRANSPARENT = 16,
  73. //! Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and drawn in that order.
  74. ESNRP_TRANSPARENT_EFFECT = 32,
  75. //! Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes
  76. ESNRP_SHADOW = 64,
  77. //! Drawn after transparent effect nodes. For custom gui's. Unsorted (in order nodes registered themselves).
  78. ESNRP_GUI = 128
  79. };
  80. class IAnimatedMesh;
  81. class IAnimatedMeshSceneNode;
  82. class IBillboardSceneNode;
  83. class ICameraSceneNode;
  84. class IDummyTransformationSceneNode;
  85. class IMesh;
  86. class IMeshBuffer;
  87. class IMeshCache;
  88. class ISceneCollisionManager;
  89. class IMeshLoader;
  90. class IMeshManipulator;
  91. class IMeshSceneNode;
  92. class ISceneNode;
  93. class ISceneNodeFactory;
  94. //! The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff.
  95. /** All Scene nodes can be created only here.
  96. A scene node is a node in the hierarchical scene graph. Every scene node
  97. may have children, which are other scene nodes. Children move relative
  98. the their parents position. If the parent of a node is not visible, its
  99. children won't be visible, too. In this way, it is for example easily
  100. possible to attach a light to a moving car or to place a walking
  101. character on a moving platform on a moving ship.
  102. The SceneManager is also able to load 3d mesh files of different
  103. formats. Take a look at getMesh() to find out what formats are
  104. supported. If these formats are not enough, use
  105. addExternalMeshLoader() to add new formats to the engine.
  106. */
  107. class ISceneManager : public virtual IReferenceCounted
  108. {
  109. public:
  110. //! Get pointer to an animatable mesh. Loads the file if not loaded already.
  111. /**
  112. * If you want to remove a loaded mesh from the cache again, use removeMesh().
  113. * Currently there are the following mesh formats supported:
  114. * <TABLE border="1" cellpadding="2" cellspacing="0">
  115. * <TR>
  116. * <TD>Format</TD>
  117. * <TD>Description</TD>
  118. * </TR>
  119. * <TR>
  120. * <TD>3D Studio (.3ds)</TD>
  121. * <TD>Loader for 3D-Studio files which lots of 3D packages
  122. * are able to export. Only static meshes are currently
  123. * supported by this importer.</TD>
  124. * </TR>
  125. * <TR>
  126. * <TD>3D World Studio (.smf)</TD>
  127. * <TD>Loader for Leadwerks SMF mesh files, a simple mesh format
  128. * containing static geometry for games. The proprietary .STF texture format
  129. * is not supported yet. This loader was originally written by Joseph Ellis. </TD>
  130. * </TR>
  131. * <TR>
  132. * <TD>Bliz Basic B3D (.b3d)</TD>
  133. * <TD>Loader for blitz basic files, developed by Mark
  134. * Sibly. This is the ideal animated mesh format for game
  135. * characters as it is both rigidly defined and widely
  136. * supported by modeling and animation software.
  137. * As this format supports skeletal animations, an
  138. * ISkinnedMesh will be returned by this importer.</TD>
  139. * </TR>
  140. * <TR>
  141. * <TD>Cartography shop 4 (.csm)</TD>
  142. * <TD>Cartography Shop is a modeling program for creating
  143. * architecture and calculating lighting. Irrlicht can
  144. * directly import .csm files thanks to the IrrCSM library
  145. * created by Saurav Mohapatra which is now integrated
  146. * directly in Irrlicht.
  147. * </TR>
  148. * <TR>
  149. * <TD>Delgine DeleD (.dmf)</TD>
  150. * <TD>DeleD (delgine.com) is a 3D editor and level-editor
  151. * combined into one and is specifically designed for 3D
  152. * game-development. With this loader, it is possible to
  153. * directly load all geometry is as well as textures and
  154. * lightmaps from .dmf files. To set texture and
  155. * material paths, see scene::DMF_USE_MATERIALS_DIRS.
  156. * It is also possible to flip the alpha texture by setting
  157. * scene::DMF_FLIP_ALPHA_TEXTURES to true and to set the
  158. * material transparent reference value by setting
  159. * scene::DMF_ALPHA_CHANNEL_REF to a float between 0 and
  160. * 1. The loader is based on Salvatore Russo's .dmf
  161. * loader, I just changed some parts of it. Thanks to
  162. * Salvatore for his work and for allowing me to use his
  163. * code in Irrlicht and put it under Irrlicht's license.
  164. * For newer and more enhanced versions of the loader,
  165. * take a look at delgine.com.
  166. * </TD>
  167. * </TR>
  168. * <TR>
  169. * <TD>DirectX (.x)</TD>
  170. * <TD>Platform independent importer (so not D3D-only) for
  171. * .x files. Most 3D packages can export these natively
  172. * and there are several tools for them available, e.g.
  173. * the Maya exporter included in the DX SDK.
  174. * .x files can include skeletal animations and Irrlicht
  175. * is able to play and display them, users can manipulate
  176. * the joints via the ISkinnedMesh interface. Currently,
  177. * Irrlicht only supports uncompressed .x files.</TD>
  178. * </TR>
  179. * <TR>
  180. * <TD>Half-Life model (.mdl)</TD>
  181. * <TD>This loader opens Half-life 1 models, it was contributed
  182. * by Fabio Concas and adapted by Thomas Alten.</TD>
  183. * </TR>
  184. * <TR>
  185. * <TD>LightWave (.lwo)</TD>
  186. * <TD>Native to NewTek's LightWave 3D, the LWO format is well
  187. * known and supported by many exporters. This loader will
  188. * import LWO2 models including lightmaps, bumpmaps and
  189. * reflection textures.</TD>
  190. * </TR>
  191. * <TR>
  192. * <TD>Maya (.obj)</TD>
  193. * <TD>Most 3D software can create .obj files which contain
  194. * static geometry without material data. The material
  195. * files .mtl are also supported. This importer for
  196. * Irrlicht can load them directly. </TD>
  197. * </TR>
  198. * <TR>
  199. * <TD>Milkshape (.ms3d)</TD>
  200. * <TD>.MS3D files contain models and sometimes skeletal
  201. * animations from the Milkshape 3D modeling and animation
  202. * software. Like the other skeletal mesh loaders, joints
  203. * are exposed via the ISkinnedMesh animated mesh type.</TD>
  204. * </TR>
  205. * <TR>
  206. * <TD>My3D (.my3d)</TD>
  207. * <TD>.my3D is a flexible 3D file format. The My3DTools
  208. * contains plug-ins to export .my3D files from several
  209. * 3D packages. With this built-in importer, Irrlicht
  210. * can read and display those files directly. This
  211. * loader was written by Zhuck Dimitry who also created
  212. * the whole My3DTools package.
  213. * </TD>
  214. * </TR>
  215. * <TR>
  216. * <TD>OCT (.oct)</TD>
  217. * <TD>The oct file format contains 3D geometry and
  218. * lightmaps and can be loaded directly by Irrlicht. OCT
  219. * files<br> can be created by FSRad, Paul Nette's
  220. * radiosity processor or exported from Blender using
  221. * OCTTools which can be found in the exporters/OCTTools
  222. * directory of the SDK. Thanks to Murphy McCauley for
  223. * creating all this.</TD>
  224. * </TR>
  225. * <TR>
  226. * <TD>OGRE Meshes (.mesh)</TD>
  227. * <TD>Ogre .mesh files contain 3D data for the OGRE 3D
  228. * engine. Irrlicht can read and display them directly
  229. * with this importer. To define materials for the mesh,
  230. * copy a .material file named like the corresponding
  231. * .mesh file where the .mesh file is. (For example
  232. * ogrehead.material for ogrehead.mesh). Thanks to
  233. * Christian Stehno who wrote and contributed this
  234. * loader.</TD>
  235. * </TR>
  236. * <TR>
  237. * <TD>Pulsar LMTools (.lmts)</TD>
  238. * <TD>LMTools is a set of tools (Windows &amp; Linux) for
  239. * creating lightmaps. Irrlicht can directly read .lmts
  240. * files thanks to<br> the importer created by Jonas
  241. * Petersen.
  242. * Notes for<br> this version of the loader:<br>
  243. * - It does not recognize/support user data in the
  244. * *.lmts files.<br>
  245. * - The TGAs generated by LMTools don't work in
  246. * Irrlicht for some reason (the textures are upside
  247. * down). Opening and resaving them in a graphics app
  248. * will solve the problem.</TD>
  249. * </TR>
  250. * <TR>
  251. * <TD>Quake 3 levels (.bsp)</TD>
  252. * <TD>Quake 3 is a popular game by IDSoftware, and .pk3
  253. * files contain .bsp files and textures/lightmaps
  254. * describing huge prelighted levels. Irrlicht can read
  255. * .pk3 and .bsp files directly and thus render Quake 3
  256. * levels directly. Written by Nikolaus Gebhardt
  257. * enhanced by Dean P. Macri with the curved surfaces
  258. * feature. </TD>
  259. * </TR>
  260. * <TR>
  261. * <TD>Quake 2 models (.md2)</TD>
  262. * <TD>Quake 2 models are characters with morph target
  263. * animation. Irrlicht can read, display and animate
  264. * them directly with this importer. </TD>
  265. * </TR>
  266. * <TR>
  267. * <TD>Quake 3 models (.md3)</TD>
  268. * <TD>Quake 3 models are characters with morph target
  269. * animation, they contain mount points for weapons and body
  270. * parts and are typically made of several sections which are
  271. * manually joined together.</TD>
  272. * </TR>
  273. * <TR>
  274. * <TD>Stanford Triangle (.ply)</TD>
  275. * <TD>Invented by Stanford University and known as the native
  276. * format of the infamous "Stanford Bunny" model, this is a
  277. * popular static mesh format used by 3D scanning hardware
  278. * and software. This loader supports extremely large models
  279. * in both ASCII and binary format, but only has rudimentary
  280. * material support in the form of vertex colors and texture
  281. * coordinates.</TD>
  282. * </TR>
  283. * <TR>
  284. * <TD>Stereolithography (.stl)</TD>
  285. * <TD>The STL format is used for rapid prototyping and
  286. * computer-aided manufacturing, thus has no support for
  287. * materials.</TD>
  288. * </TR>
  289. * </TABLE>
  290. *
  291. * To load and display a mesh quickly, just do this:
  292. * \code
  293. * SceneManager->addAnimatedMeshSceneNode(
  294. * SceneManager->getMesh("yourmesh.3ds"));
  295. * \endcode
  296. * If you would like to implement and add your own file format loader to Irrlicht,
  297. * see addExternalMeshLoader().
  298. * \param file File handle of the mesh to load.
  299. * \return Null if failed, otherwise pointer to the mesh.
  300. * This pointer should not be dropped. See IReferenceCounted::drop() for more information.
  301. **/
  302. virtual IAnimatedMesh *getMesh(io::IReadFile *file) = 0;
  303. //! Get interface to the mesh cache which is shared between all existing scene managers.
  304. /** With this interface, it is possible to manually add new loaded
  305. meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate
  306. through already loaded meshes. */
  307. virtual IMeshCache *getMeshCache() = 0;
  308. //! Get the video driver.
  309. /** \return Pointer to the video Driver.
  310. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  311. virtual video::IVideoDriver *getVideoDriver() = 0;
  312. //! Adds a scene node for rendering an animated mesh model.
  313. /** \param mesh: Pointer to the loaded animated mesh to be displayed.
  314. \param parent: Parent of the scene node. Can be NULL if no parent.
  315. \param id: Id of the node. This id can be used to identify the scene node.
  316. \param position: Position of the space relative to its parent where the
  317. scene node will be placed.
  318. \param rotation: Initial rotation of the scene node.
  319. \param scale: Initial scale of the scene node.
  320. \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
  321. \return Pointer to the created scene node.
  322. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  323. virtual IAnimatedMeshSceneNode *addAnimatedMeshSceneNode(IAnimatedMesh *mesh,
  324. ISceneNode *parent = 0, s32 id = -1,
  325. const core::vector3df &position = core::vector3df(0, 0, 0),
  326. const core::vector3df &rotation = core::vector3df(0, 0, 0),
  327. const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f),
  328. bool alsoAddIfMeshPointerZero = false) = 0;
  329. //! Adds a scene node for rendering a static mesh.
  330. /** \param mesh: Pointer to the loaded static mesh to be displayed.
  331. \param parent: Parent of the scene node. Can be NULL if no parent.
  332. \param id: Id of the node. This id can be used to identify the scene node.
  333. \param position: Position of the space relative to its parent where the
  334. scene node will be placed.
  335. \param rotation: Initial rotation of the scene node.
  336. \param scale: Initial scale of the scene node.
  337. \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
  338. \return Pointer to the created scene node.
  339. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  340. virtual IMeshSceneNode *addMeshSceneNode(IMesh *mesh, ISceneNode *parent = 0, s32 id = -1,
  341. const core::vector3df &position = core::vector3df(0, 0, 0),
  342. const core::vector3df &rotation = core::vector3df(0, 0, 0),
  343. const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f),
  344. bool alsoAddIfMeshPointerZero = false) = 0;
  345. //! Adds a camera scene node to the scene graph and sets it as active camera.
  346. /** This camera does not react on user input.
  347. If you want to move or animate it, use ISceneNode::setPosition(),
  348. ICameraSceneNode::setTarget() etc methods.
  349. By default, a camera's look at position (set with setTarget()) and its scene node
  350. rotation (set with setRotation()) are independent. If you want to be able to
  351. control the direction that the camera looks by using setRotation() then call
  352. ICameraSceneNode::bindTargetAndRotation(true) on it.
  353. \param position: Position of the space relative to its parent where the camera will be placed.
  354. \param lookat: Position where the camera will look at. Also known as target.
  355. \param parent: Parent scene node of the camera. Can be null. If the parent moves,
  356. the camera will move too.
  357. \param id: id of the camera. This id can be used to identify the camera.
  358. \param makeActive Flag whether this camera should become the active one.
  359. Make sure you always have one active camera.
  360. \return Pointer to interface to camera if successful, otherwise 0.
  361. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  362. virtual ICameraSceneNode *addCameraSceneNode(ISceneNode *parent = 0,
  363. const core::vector3df &position = core::vector3df(0, 0, 0),
  364. const core::vector3df &lookat = core::vector3df(0, 0, 100),
  365. s32 id = -1, bool makeActive = true) = 0;
  366. //! Adds a billboard scene node to the scene graph.
  367. /** A billboard is like a 3d sprite: A 2d element,
  368. which always looks to the camera. It is usually used for things
  369. like explosions, fire, lensflares and things like that.
  370. \param parent Parent scene node of the billboard. Can be null.
  371. If the parent moves, the billboard will move too.
  372. \param size Size of the billboard. This size is 2 dimensional
  373. because a billboard only has width and height.
  374. \param position Position of the space relative to its parent
  375. where the billboard will be placed.
  376. \param id An id of the node. This id can be used to identify
  377. the node.
  378. \param colorTop The color of the vertices at the top of the
  379. billboard (default: white).
  380. \param colorBottom The color of the vertices at the bottom of
  381. the billboard (default: white).
  382. \return Pointer to the billboard if successful, otherwise NULL.
  383. This pointer should not be dropped. See
  384. IReferenceCounted::drop() for more information. */
  385. virtual IBillboardSceneNode *addBillboardSceneNode(ISceneNode *parent = 0,
  386. const core::dimension2d<f32> &size = core::dimension2d<f32>(10.0f, 10.0f),
  387. const core::vector3df &position = core::vector3df(0, 0, 0), s32 id = -1,
  388. video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0;
  389. //! Adds an empty scene node to the scene graph.
  390. /** Can be used for doing advanced transformations
  391. or structuring the scene graph.
  392. \return Pointer to the created scene node.
  393. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  394. virtual ISceneNode *addEmptySceneNode(ISceneNode *parent = 0, s32 id = -1) = 0;
  395. //! Adds a dummy transformation scene node to the scene graph.
  396. /** This scene node does not render itself, and does not respond to set/getPosition,
  397. set/getRotation and set/getScale. Its just a simple scene node that takes a
  398. matrix as relative transformation, making it possible to insert any transformation
  399. anywhere into the scene graph.
  400. \return Pointer to the created scene node.
  401. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  402. virtual IDummyTransformationSceneNode *addDummyTransformationSceneNode(
  403. ISceneNode *parent = 0, s32 id = -1) = 0;
  404. //! Gets the root scene node.
  405. /** This is the scene node which is parent
  406. of all scene nodes. The root scene node is a special scene node which
  407. only exists to manage all scene nodes. It will not be rendered and cannot
  408. be removed from the scene.
  409. \return Pointer to the root scene node.
  410. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  411. virtual ISceneNode *getRootSceneNode() = 0;
  412. //! Get the first scene node with the specified id.
  413. /** \param id: The id to search for
  414. \param start: Scene node to start from. All children of this scene
  415. node are searched. If null is specified, the root scene node is
  416. taken.
  417. \return Pointer to the first scene node with this id,
  418. and null if no scene node could be found.
  419. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  420. virtual ISceneNode *getSceneNodeFromId(s32 id, ISceneNode *start = 0) = 0;
  421. //! Get the first scene node with the specified name.
  422. /** \param name: The name to search for
  423. \param start: Scene node to start from. All children of this scene
  424. node are searched. If null is specified, the root scene node is
  425. taken.
  426. \return Pointer to the first scene node with this id,
  427. and null if no scene node could be found.
  428. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  429. virtual ISceneNode *getSceneNodeFromName(const c8 *name, ISceneNode *start = 0) = 0;
  430. //! Get the first scene node with the specified type.
  431. /** \param type: The type to search for
  432. \param start: Scene node to start from. All children of this scene
  433. node are searched. If null is specified, the root scene node is
  434. taken.
  435. \return Pointer to the first scene node with this type,
  436. and null if no scene node could be found.
  437. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  438. virtual ISceneNode *getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode *start = 0) = 0;
  439. //! Get scene nodes by type.
  440. /** \param type: Type of scene node to find (ESNT_ANY will return all child nodes).
  441. \param outNodes: results will be added to this array (outNodes is not cleared).
  442. \param start: Scene node to start from. This node and all children of this scene
  443. node are checked (recursively, so also children of children, etc). If null is specified,
  444. the root scene node is taken as start-node. */
  445. virtual void getSceneNodesFromType(ESCENE_NODE_TYPE type,
  446. core::array<scene::ISceneNode *> &outNodes,
  447. ISceneNode *start = 0) = 0;
  448. //! Get the current active camera.
  449. /** \return The active camera is returned. Note that this can
  450. be NULL, if there was no camera created yet.
  451. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  452. virtual ICameraSceneNode *getActiveCamera() const = 0;
  453. //! Sets the currently active camera.
  454. /** The previous active camera will be deactivated.
  455. \param camera: The new camera which should be active. */
  456. virtual void setActiveCamera(ICameraSceneNode *camera) = 0;
  457. //! Registers a node for rendering it at a specific time.
  458. /** This method should only be used by SceneNodes when they get a
  459. ISceneNode::OnRegisterSceneNode() call.
  460. \param node: Node to register for drawing. Usually scene nodes would set 'this'
  461. as parameter here because they want to be drawn.
  462. \param pass: Specifies when the node wants to be drawn in relation to the other nodes.
  463. For example, if the node is a shadow, it usually wants to be drawn after all other nodes
  464. and will use ESNRP_SHADOW for this. See scene::E_SCENE_NODE_RENDER_PASS for details.
  465. Note: This is _not_ a bitfield. If you want to register a note for several render passes, then
  466. call this function once for each pass.
  467. \return scene will be rendered ( passed culling ) */
  468. virtual u32 registerNodeForRendering(ISceneNode *node,
  469. E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0;
  470. //! Clear all nodes which are currently registered for rendering
  471. /** Usually you don't have to care about this as drawAll will clear nodes
  472. after rendering them. But sometimes you might have to manually reset this.
  473. For example when you deleted nodes between registering and rendering. */
  474. virtual void clearAllRegisteredNodesForRendering() = 0;
  475. //! Draws all the scene nodes.
  476. /** This can only be invoked between
  477. IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that
  478. the scene is not only drawn when calling this, but also animated
  479. by existing scene node animators, culling of scene nodes is done, etc. */
  480. virtual void drawAll() = 0;
  481. //! Adds an external mesh loader for extending the engine with new file formats.
  482. /** If you want the engine to be extended with
  483. file formats it currently is not able to load (e.g. .cob), just implement
  484. the IMeshLoader interface in your loading class and add it with this method.
  485. Using this method it is also possible to override built-in mesh loaders with
  486. newer or updated versions without the need to recompile the engine.
  487. \param externalLoader: Implementation of a new mesh loader. */
  488. virtual void addExternalMeshLoader(IMeshLoader *externalLoader) = 0;
  489. //! Returns the number of mesh loaders supported by Irrlicht at this time
  490. virtual u32 getMeshLoaderCount() const = 0;
  491. //! Retrieve the given mesh loader
  492. /** \param index The index of the loader to retrieve. This parameter is an 0-based
  493. array index.
  494. \return A pointer to the specified loader, 0 if the index is incorrect. */
  495. virtual IMeshLoader *getMeshLoader(u32 index) const = 0;
  496. //! Get pointer to the scene collision manager.
  497. /** \return Pointer to the collision manager
  498. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  499. virtual ISceneCollisionManager *getSceneCollisionManager() = 0;
  500. //! Get pointer to the mesh manipulator.
  501. /** \return Pointer to the mesh manipulator
  502. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  503. virtual IMeshManipulator *getMeshManipulator() = 0;
  504. //! Adds a scene node to the deletion queue.
  505. /** The scene node is immediately
  506. deleted when it's secure. Which means when the scene node does not
  507. execute animators and things like that. This method is for example
  508. used for deleting scene nodes by their scene node animators. In
  509. most other cases, a ISceneNode::remove() call is enough, using this
  510. deletion queue is not necessary.
  511. See ISceneManager::createDeleteAnimator() for details.
  512. \param node: Node to delete. */
  513. virtual void addToDeletionQueue(ISceneNode *node) = 0;
  514. //! Posts an input event to the environment.
  515. /** Usually you do not have to
  516. use this method, it is used by the internal engine. */
  517. virtual bool postEventFromUser(const SEvent &event) = 0;
  518. //! Clears the whole scene.
  519. /** All scene nodes are removed. */
  520. virtual void clear() = 0;
  521. //! Get interface to the parameters set in this scene.
  522. /** String parameters can be used by plugins and mesh loaders.
  523. See COLLADA_CREATE_SCENE_INSTANCES and DMF_USE_MATERIALS_DIRS */
  524. virtual io::IAttributes *getParameters() = 0;
  525. //! Get current render pass.
  526. /** All scene nodes are being rendered in a specific order.
  527. First lights, cameras, sky boxes, solid geometry, and then transparent
  528. stuff. During the rendering process, scene nodes may want to know what the scene
  529. manager is rendering currently, because for example they registered for rendering
  530. twice, once for transparent geometry and once for solid. When knowing what rendering
  531. pass currently is active they can render the correct part of their geometry. */
  532. virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const = 0;
  533. //! Creates a new scene manager.
  534. /** This can be used to easily draw and/or store two
  535. independent scenes at the same time. The mesh cache will be
  536. shared between all existing scene managers, which means if you
  537. load a mesh in the original scene manager using for example
  538. getMesh(), the mesh will be available in all other scene
  539. managers too, without loading.
  540. The original/main scene manager will still be there and
  541. accessible via IrrlichtDevice::getSceneManager(). If you need
  542. input event in this new scene manager, for example for FPS
  543. cameras, you'll need to forward input to this manually: Just
  544. implement an IEventReceiver and call
  545. yourNewSceneManager->postEventFromUser(), and return true so
  546. that the original scene manager doesn't get the event.
  547. Otherwise, all input will go to the main scene manager
  548. automatically.
  549. If you no longer need the new scene manager, you should call
  550. ISceneManager::drop().
  551. See IReferenceCounted::drop() for more information. */
  552. virtual ISceneManager *createNewSceneManager(bool cloneContent = false) = 0;
  553. //! Get a skinned mesh, which is not available as header-only code
  554. /** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop()
  555. for details. */
  556. virtual ISkinnedMesh *createSkinnedMesh() = 0;
  557. //! Sets ambient color of the scene
  558. virtual void setAmbientLight(const video::SColorf &ambientColor) = 0;
  559. //! Get ambient color of the scene
  560. virtual const video::SColorf &getAmbientLight() const = 0;
  561. //! Get current render pass.
  562. virtual E_SCENE_NODE_RENDER_PASS getCurrentRenderPass() const = 0;
  563. //! Set current render pass.
  564. virtual void setCurrentRenderPass(E_SCENE_NODE_RENDER_PASS nextPass) = 0;
  565. //! Check if node is culled in current view frustum
  566. /** Please note that depending on the used culling method this
  567. check can be rather coarse, or slow. A positive result is
  568. correct, though, i.e. if this method returns true the node is
  569. positively not visible. The node might still be invisible even
  570. if this method returns false.
  571. \param node The scene node which is checked for culling.
  572. \return True if node is not visible in the current scene, else
  573. false. */
  574. virtual bool isCulled(const ISceneNode *node) const = 0;
  575. };
  576. } // end namespace scene
  577. } // end namespace irr