ISceneManager.h 28 KB

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