ISceneManager.h 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697
  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. #ifndef __I_SCENE_MANAGER_H_INCLUDED__
  5. #define __I_SCENE_MANAGER_H_INCLUDED__
  6. #include "IReferenceCounted.h"
  7. #include "irrArray.h"
  8. #include "irrString.h"
  9. #include "path.h"
  10. #include "vector3d.h"
  11. #include "dimension2d.h"
  12. #include "SColor.h"
  13. #include "ETerrainElements.h"
  14. #include "ESceneNodeTypes.h"
  15. #include "ESceneNodeAnimatorTypes.h"
  16. #include "EMeshWriterEnums.h"
  17. #include "SceneParameters.h"
  18. #include "IGeometryCreator.h"
  19. #include "ISkinnedMesh.h"
  20. #include "IXMLWriter.h"
  21. namespace irr
  22. {
  23. struct SKeyMap;
  24. struct SEvent;
  25. namespace io
  26. {
  27. class IReadFile;
  28. class IAttributes;
  29. class IWriteFile;
  30. class IFileSystem;
  31. } // end namespace io
  32. namespace gui
  33. {
  34. class IGUIFont;
  35. class IGUIEnvironment;
  36. } // end namespace gui
  37. namespace video
  38. {
  39. class IVideoDriver;
  40. class SMaterial;
  41. class IImage;
  42. class ITexture;
  43. } // end namespace video
  44. namespace scene
  45. {
  46. //! Enumeration for render passes.
  47. /** A parameter passed to the registerNodeForRendering() method of the ISceneManager,
  48. specifying when the node wants to be drawn in relation to the other nodes.
  49. Note: Despite the numbering this is not used as bit-field.
  50. */
  51. enum E_SCENE_NODE_RENDER_PASS
  52. {
  53. //! No pass currently active
  54. ESNRP_NONE =0,
  55. //! Camera pass. The active view is set up here. The very first pass.
  56. ESNRP_CAMERA =1,
  57. //! In this pass, lights are transformed into camera space and added to the driver
  58. ESNRP_LIGHT =2,
  59. //! This is used for sky boxes.
  60. ESNRP_SKY_BOX =4,
  61. //! All normal objects can use this for registering themselves.
  62. /** This value will never be returned by
  63. ISceneManager::getSceneNodeRenderPass(). The scene manager
  64. will determine by itself if an object is transparent or solid
  65. and register the object as ESNRT_TRANSPARENT or ESNRP_SOLID
  66. automatically if you call registerNodeForRendering with this
  67. value (which is default). Note that it will register the node
  68. only as ONE type. If your scene node has both solid and
  69. transparent material types register it twice (one time as
  70. ESNRP_SOLID, the other time as ESNRT_TRANSPARENT) and in the
  71. render() method call getSceneNodeRenderPass() to find out the
  72. current render pass and render only the corresponding parts of
  73. the node. */
  74. ESNRP_AUTOMATIC =24,
  75. //! Solid scene nodes or special scene nodes without materials.
  76. ESNRP_SOLID =8,
  77. //! Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in that order.
  78. ESNRP_TRANSPARENT =16,
  79. //! Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and drawn in that order.
  80. ESNRP_TRANSPARENT_EFFECT =32,
  81. //! Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes
  82. ESNRP_SHADOW =64,
  83. //! Drawn after transparent effect nodes. For custom gui's. Unsorted (in order nodes registered themselves).
  84. ESNRP_GUI = 128
  85. };
  86. class IAnimatedMesh;
  87. class IAnimatedMeshSceneNode;
  88. class IBillboardSceneNode;
  89. class IBillboardTextSceneNode;
  90. class ICameraSceneNode;
  91. class IDummyTransformationSceneNode;
  92. class ILightManager;
  93. class ILightSceneNode;
  94. class IMesh;
  95. class IMeshBuffer;
  96. class IMeshCache;
  97. class IMeshLoader;
  98. class IMeshManipulator;
  99. class IMeshSceneNode;
  100. class IMeshWriter;
  101. class IMetaTriangleSelector;
  102. class IOctreeSceneNode;
  103. class IParticleSystemSceneNode;
  104. class ISceneCollisionManager;
  105. class ISceneLoader;
  106. class ISceneNode;
  107. class ISceneNodeAnimator;
  108. class ISceneNodeAnimatorCollisionResponse;
  109. class ISceneNodeAnimatorFactory;
  110. class ISceneNodeFactory;
  111. class ISceneUserDataSerializer;
  112. class IShadowVolumeSceneNode;
  113. class ITerrainSceneNode;
  114. class ITextSceneNode;
  115. class ITriangleSelector;
  116. class IVolumeLightSceneNode;
  117. namespace quake3
  118. {
  119. struct IShader;
  120. } // end namespace quake3
  121. //! The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff.
  122. /** All Scene nodes can be created only here. There is a always growing
  123. list of scene nodes for lots of purposes: Indoor rendering scene nodes
  124. like the Octree (addOctreeSceneNode()) or the terrain renderer
  125. (addTerrainSceneNode()), different Camera scene nodes
  126. (addCameraSceneNode(), addCameraSceneNodeMaya()), scene nodes for Light
  127. (addLightSceneNode()), Billboards (addBillboardSceneNode()) and so on.
  128. A scene node is a node in the hierarchical scene graph. Every scene node
  129. may have children, which are other scene nodes. Children move relative
  130. the their parents position. If the parent of a node is not visible, its
  131. children won't be visible, too. In this way, it is for example easily
  132. possible to attach a light to a moving car or to place a walking
  133. character on a moving platform on a moving ship.
  134. The SceneManager is also able to load 3d mesh files of different
  135. formats. Take a look at getMesh() to find out what formats are
  136. supported. If these formats are not enough, use
  137. addExternalMeshLoader() to add new formats to the engine.
  138. */
  139. class ISceneManager : public virtual IReferenceCounted
  140. {
  141. public:
  142. //! Get pointer to an animateable mesh. Loads the file if not loaded already.
  143. /**
  144. * If you want to remove a loaded mesh from the cache again, use removeMesh().
  145. * Currently there are the following mesh formats supported:
  146. * <TABLE border="1" cellpadding="2" cellspacing="0">
  147. * <TR>
  148. * <TD>Format</TD>
  149. * <TD>Description</TD>
  150. * </TR>
  151. * <TR>
  152. * <TD>3D Studio (.3ds)</TD>
  153. * <TD>Loader for 3D-Studio files which lots of 3D packages
  154. * are able to export. Only static meshes are currently
  155. * supported by this importer.</TD>
  156. * </TR>
  157. * <TR>
  158. * <TD>3D World Studio (.smf)</TD>
  159. * <TD>Loader for Leadwerks SMF mesh files, a simple mesh format
  160. * containing static geometry for games. The proprietary .STF texture format
  161. * is not supported yet. This loader was originally written by Joseph Ellis. </TD>
  162. * </TR>
  163. * <TR>
  164. * <TD>Bliz Basic B3D (.b3d)</TD>
  165. * <TD>Loader for blitz basic files, developed by Mark
  166. * Sibly. This is the ideal animated mesh format for game
  167. * characters as it is both rigidly defined and widely
  168. * supported by modeling and animation software.
  169. * As this format supports skeletal animations, an
  170. * ISkinnedMesh will be returned by this importer.</TD>
  171. * </TR>
  172. * <TR>
  173. * <TD>Cartography shop 4 (.csm)</TD>
  174. * <TD>Cartography Shop is a modeling program for creating
  175. * architecture and calculating lighting. Irrlicht can
  176. * directly import .csm files thanks to the IrrCSM library
  177. * created by Saurav Mohapatra which is now integrated
  178. * directly in Irrlicht.
  179. * </TR>
  180. * <TR>
  181. * <TD>COLLADA (.dae, .xml)</TD>
  182. * <TD>COLLADA is an open Digital Asset Exchange Schema for
  183. * the interactive 3D industry. There are exporters and
  184. * importers for this format available for most of the
  185. * big 3d packagesat http://collada.org. Irrlicht can
  186. * import COLLADA files by using the
  187. * ISceneManager::getMesh() method. COLLADA files need
  188. * not contain only one single mesh but multiple meshes
  189. * and a whole scene setup with lights, cameras and mesh
  190. * instances, this loader can set up a scene as
  191. * described by the COLLADA file instead of loading and
  192. * returning one single mesh. By default, this loader
  193. * behaves like the other loaders and does not create
  194. * instances, but it can be switched into this mode by
  195. * using
  196. * SceneManager-&gt;getParameters()-&gt;setAttribute(COLLADA_CREATE_SCENE_INSTANCES, true);
  197. * Created scene nodes will be named as the names of the
  198. * nodes in the COLLADA file. The returned mesh is just
  199. * a dummy object in this mode. Meshes included in the
  200. * scene will be added into the scene manager with the
  201. * following naming scheme:
  202. * "path/to/file/file.dea#meshname". The loading of such
  203. * meshes is logged. Currently, this loader is able to
  204. * create meshes (made of only polygons), lights, and
  205. * cameras. Materials and animations are currently not
  206. * supported but this will change with future releases.
  207. * </TD>
  208. * </TR>
  209. * <TR>
  210. * <TD>Delgine DeleD (.dmf)</TD>
  211. * <TD>DeleD (delgine.com) is a 3D editor and level-editor
  212. * combined into one and is specifically designed for 3D
  213. * game-development. With this loader, it is possible to
  214. * directly load all geometry is as well as textures and
  215. * lightmaps from .dmf files. To set texture and
  216. * material paths, see scene::DMF_USE_MATERIALS_DIRS.
  217. * It is also possible to flip the alpha texture by setting
  218. * scene::DMF_FLIP_ALPHA_TEXTURES to true and to set the
  219. * material transparent reference value by setting
  220. * scene::DMF_ALPHA_CHANNEL_REF to a float between 0 and
  221. * 1. The loader is based on Salvatore Russo's .dmf
  222. * loader, I just changed some parts of it. Thanks to
  223. * Salvatore for his work and for allowing me to use his
  224. * code in Irrlicht and put it under Irrlicht's license.
  225. * For newer and more enhanced versions of the loader,
  226. * take a look at delgine.com.
  227. * </TD>
  228. * </TR>
  229. * <TR>
  230. * <TD>DirectX (.x)</TD>
  231. * <TD>Platform independent importer (so not D3D-only) for
  232. * .x files. Most 3D packages can export these natively
  233. * and there are several tools for them available, e.g.
  234. * the Maya exporter included in the DX SDK.
  235. * .x files can include skeletal animations and Irrlicht
  236. * is able to play and display them, users can manipulate
  237. * the joints via the ISkinnedMesh interface. Currently,
  238. * Irrlicht only supports uncompressed .x files.</TD>
  239. * </TR>
  240. * <TR>
  241. * <TD>Half-Life model (.mdl)</TD>
  242. * <TD>This loader opens Half-life 1 models, it was contributed
  243. * by Fabio Concas and adapted by Thomas Alten.</TD>
  244. * </TR>
  245. * <TR>
  246. * <TD>Irrlicht Mesh (.irrMesh)</TD>
  247. * <TD>This is a static mesh format written in XML, native
  248. * to Irrlicht and written by the irr mesh writer.
  249. * This format is exported by the CopperCube engine's
  250. * lightmapper.</TD>
  251. * </TR>
  252. * <TR>
  253. * <TD>LightWave (.lwo)</TD>
  254. * <TD>Native to NewTek's LightWave 3D, the LWO format is well
  255. * known and supported by many exporters. This loader will
  256. * import LWO2 models including lightmaps, bumpmaps and
  257. * reflection textures.</TD>
  258. * </TR>
  259. * <TR>
  260. * <TD>Maya (.obj)</TD>
  261. * <TD>Most 3D software can create .obj files which contain
  262. * static geometry without material data. The material
  263. * files .mtl are also supported. This importer for
  264. * Irrlicht can load them directly. </TD>
  265. * </TR>
  266. * <TR>
  267. * <TD>Milkshape (.ms3d)</TD>
  268. * <TD>.MS3D files contain models and sometimes skeletal
  269. * animations from the Milkshape 3D modeling and animation
  270. * software. Like the other skeletal mesh loaders, joints
  271. * are exposed via the ISkinnedMesh animated mesh type.</TD>
  272. * </TR>
  273. * <TR>
  274. * <TD>My3D (.my3d)</TD>
  275. * <TD>.my3D is a flexible 3D file format. The My3DTools
  276. * contains plug-ins to export .my3D files from several
  277. * 3D packages. With this built-in importer, Irrlicht
  278. * can read and display those files directly. This
  279. * loader was written by Zhuck Dimitry who also created
  280. * the whole My3DTools package.
  281. * </TD>
  282. * </TR>
  283. * <TR>
  284. * <TD>OCT (.oct)</TD>
  285. * <TD>The oct file format contains 3D geometry and
  286. * lightmaps and can be loaded directly by Irrlicht. OCT
  287. * files<br> can be created by FSRad, Paul Nette's
  288. * radiosity processor or exported from Blender using
  289. * OCTTools which can be found in the exporters/OCTTools
  290. * directory of the SDK. Thanks to Murphy McCauley for
  291. * creating all this.</TD>
  292. * </TR>
  293. * <TR>
  294. * <TD>OGRE Meshes (.mesh)</TD>
  295. * <TD>Ogre .mesh files contain 3D data for the OGRE 3D
  296. * engine. Irrlicht can read and display them directly
  297. * with this importer. To define materials for the mesh,
  298. * copy a .material file named like the corresponding
  299. * .mesh file where the .mesh file is. (For example
  300. * ogrehead.material for ogrehead.mesh). Thanks to
  301. * Christian Stehno who wrote and contributed this
  302. * loader.</TD>
  303. * </TR>
  304. * <TR>
  305. * <TD>Pulsar LMTools (.lmts)</TD>
  306. * <TD>LMTools is a set of tools (Windows &amp; Linux) for
  307. * creating lightmaps. Irrlicht can directly read .lmts
  308. * files thanks to<br> the importer created by Jonas
  309. * Petersen.
  310. * Notes for<br> this version of the loader:<br>
  311. * - It does not recognize/support user data in the
  312. * *.lmts files.<br>
  313. * - The TGAs generated by LMTools don't work in
  314. * Irrlicht for some reason (the textures are upside
  315. * down). Opening and resaving them in a graphics app
  316. * will solve the problem.</TD>
  317. * </TR>
  318. * <TR>
  319. * <TD>Quake 3 levels (.bsp)</TD>
  320. * <TD>Quake 3 is a popular game by IDSoftware, and .pk3
  321. * files contain .bsp files and textures/lightmaps
  322. * describing huge prelighted levels. Irrlicht can read
  323. * .pk3 and .bsp files directly and thus render Quake 3
  324. * levels directly. Written by Nikolaus Gebhardt
  325. * enhanced by Dean P. Macri with the curved surfaces
  326. * feature. </TD>
  327. * </TR>
  328. * <TR>
  329. * <TD>Quake 2 models (.md2)</TD>
  330. * <TD>Quake 2 models are characters with morph target
  331. * animation. Irrlicht can read, display and animate
  332. * them directly with this importer. </TD>
  333. * </TR>
  334. * <TR>
  335. * <TD>Quake 3 models (.md3)</TD>
  336. * <TD>Quake 3 models are characters with morph target
  337. * animation, they contain mount points for weapons and body
  338. * parts and are typically made of several sections which are
  339. * manually joined together.</TD>
  340. * </TR>
  341. * <TR>
  342. * <TD>Stanford Triangle (.ply)</TD>
  343. * <TD>Invented by Stanford University and known as the native
  344. * format of the infamous "Stanford Bunny" model, this is a
  345. * popular static mesh format used by 3D scanning hardware
  346. * and software. This loader supports extremely large models
  347. * in both ASCII and binary format, but only has rudimentary
  348. * material support in the form of vertex colors and texture
  349. * coordinates.</TD>
  350. * </TR>
  351. * <TR>
  352. * <TD>Stereolithography (.stl)</TD>
  353. * <TD>The STL format is used for rapid prototyping and
  354. * computer-aided manufacturing, thus has no support for
  355. * materials.</TD>
  356. * </TR>
  357. * </TABLE>
  358. *
  359. * To load and display a mesh quickly, just do this:
  360. * \code
  361. * SceneManager->addAnimatedMeshSceneNode(
  362. * SceneManager->getMesh("yourmesh.3ds"));
  363. * \endcode
  364. * If you would like to implement and add your own file format loader to Irrlicht,
  365. * see addExternalMeshLoader().
  366. * \param filename: Filename of the mesh to load.
  367. * \param alternativeCacheName: In case you want to have the mesh under another name in the cache (to create real copies)
  368. * \return Null if failed, otherwise pointer to the mesh.
  369. * This pointer should not be dropped. See IReferenceCounted::drop() for more information.
  370. **/
  371. virtual IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName=io::path("")) = 0;
  372. //! Get pointer to an animateable mesh. Loads the file if not loaded already.
  373. /** Works just as getMesh(const char* filename). If you want to
  374. remove a loaded mesh from the cache again, use removeMesh().
  375. \param file File handle of the mesh to load.
  376. \return NULL if failed and pointer to the mesh if successful.
  377. This pointer should not be dropped. See
  378. IReferenceCounted::drop() for more information. */
  379. virtual IAnimatedMesh* getMesh(io::IReadFile* file) = 0;
  380. //! Get interface to the mesh cache which is shared between all existing scene managers.
  381. /** With this interface, it is possible to manually add new loaded
  382. meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate
  383. through already loaded meshes. */
  384. virtual IMeshCache* getMeshCache() = 0;
  385. //! Get the video driver.
  386. /** \return Pointer to the video Driver.
  387. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  388. virtual video::IVideoDriver* getVideoDriver() = 0;
  389. //! Get the active GUIEnvironment
  390. /** \return Pointer to the GUIEnvironment
  391. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  392. virtual gui::IGUIEnvironment* getGUIEnvironment() = 0;
  393. //! Get the active FileSystem
  394. /** \return Pointer to the FileSystem
  395. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  396. virtual io::IFileSystem* getFileSystem() = 0;
  397. //! adds Volume Lighting Scene Node.
  398. /** Example Usage:
  399. scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(0, -1,
  400. 32, 32, //Subdivide U/V
  401. video::SColor(0, 180, 180, 180), //foot color
  402. video::SColor(0, 0, 0, 0) //tail color
  403. );
  404. if (n)
  405. {
  406. n->setScale(core::vector3df(46.0f, 45.0f, 46.0f));
  407. n->getMaterial(0).setTexture(0, smgr->getVideoDriver()->getTexture("lightFalloff.png"));
  408. }
  409. \return Pointer to the volumeLight if successful, otherwise NULL.
  410. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  411. virtual IVolumeLightSceneNode* addVolumeLightSceneNode(ISceneNode* parent=0, s32 id=-1,
  412. const u32 subdivU = 32, const u32 subdivV = 32,
  413. const video::SColor foot = video::SColor(51, 0, 230, 180),
  414. const video::SColor tail = video::SColor(0, 0, 0, 0),
  415. const core::vector3df& position = core::vector3df(0,0,0),
  416. const core::vector3df& rotation = core::vector3df(0,0,0),
  417. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0;
  418. //! Adds a cube scene node
  419. /** \param size: Size of the cube, uniformly in each dimension.
  420. \param parent: Parent of the scene node. Can be 0 if no parent.
  421. \param id: Id of the node. This id can be used to identify the scene node.
  422. \param position: Position of the space relative to its parent
  423. where the scene node will be placed.
  424. \param rotation: Initial rotation of the scene node.
  425. \param scale: Initial scale of the scene node.
  426. \return Pointer to the created test scene node. This
  427. pointer should not be dropped. See IReferenceCounted::drop()
  428. for more information. */
  429. virtual IMeshSceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1,
  430. const core::vector3df& position = core::vector3df(0,0,0),
  431. const core::vector3df& rotation = core::vector3df(0,0,0),
  432. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0;
  433. //! Adds a sphere scene node of the given radius and detail
  434. /** \param radius: Radius of the sphere.
  435. \param polyCount: The number of vertices in horizontal and
  436. vertical direction. The total polyCount of the sphere is
  437. polyCount*polyCount. This parameter must be less than 256 to
  438. stay within the 16-bit limit of the indices of a meshbuffer.
  439. \param parent: Parent of the scene node. Can be 0 if no parent.
  440. \param id: Id of the node. This id can be used to identify the scene node.
  441. \param position: Position of the space relative to its parent
  442. where the scene node will be placed.
  443. \param rotation: Initial rotation of the scene node.
  444. \param scale: Initial scale of the scene node.
  445. \return Pointer to the created test scene node. This
  446. pointer should not be dropped. See IReferenceCounted::drop()
  447. for more information. */
  448. virtual IMeshSceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16,
  449. ISceneNode* parent=0, s32 id=-1,
  450. const core::vector3df& position = core::vector3df(0,0,0),
  451. const core::vector3df& rotation = core::vector3df(0,0,0),
  452. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0;
  453. //! Adds a scene node for rendering an animated mesh model.
  454. /** \param mesh: Pointer to the loaded animated mesh to be displayed.
  455. \param parent: Parent of the scene node. Can be NULL if no parent.
  456. \param id: Id of the node. This id can be used to identify the scene node.
  457. \param position: Position of the space relative to its parent where the
  458. scene node will be placed.
  459. \param rotation: Initial rotation of the scene node.
  460. \param scale: Initial scale of the scene node.
  461. \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
  462. \return Pointer to the created scene node.
  463. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  464. virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh,
  465. ISceneNode* parent=0, s32 id=-1,
  466. const core::vector3df& position = core::vector3df(0,0,0),
  467. const core::vector3df& rotation = core::vector3df(0,0,0),
  468. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f),
  469. bool alsoAddIfMeshPointerZero=false) = 0;
  470. //! Adds a scene node for rendering a static mesh.
  471. /** \param mesh: Pointer to the loaded static mesh to be displayed.
  472. \param parent: Parent of the scene node. Can be NULL if no parent.
  473. \param id: Id of the node. This id can be used to identify the scene node.
  474. \param position: Position of the space relative to its parent where the
  475. scene node will be placed.
  476. \param rotation: Initial rotation of the scene node.
  477. \param scale: Initial scale of the scene node.
  478. \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
  479. \return Pointer to the created scene node.
  480. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  481. virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1,
  482. const core::vector3df& position = core::vector3df(0,0,0),
  483. const core::vector3df& rotation = core::vector3df(0,0,0),
  484. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f),
  485. bool alsoAddIfMeshPointerZero=false) = 0;
  486. //! Adds a scene node for rendering a animated water surface mesh.
  487. /** Looks really good when the Material type EMT_TRANSPARENT_REFLECTION
  488. is used.
  489. \param waveHeight: Height of the water waves.
  490. \param waveSpeed: Speed of the water waves.
  491. \param waveLength: Length of a water wave.
  492. \param mesh: Pointer to the loaded static mesh to be displayed with water waves on it.
  493. \param parent: Parent of the scene node. Can be NULL if no parent.
  494. \param id: Id of the node. This id can be used to identify the scene node.
  495. \param position: Position of the space relative to its parent where the
  496. scene node will be placed.
  497. \param rotation: Initial rotation of the scene node.
  498. \param scale: Initial scale of the scene node.
  499. \return Pointer to the created scene node.
  500. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  501. virtual ISceneNode* addWaterSurfaceSceneNode(IMesh* mesh,
  502. f32 waveHeight=2.0f, f32 waveSpeed=300.0f, f32 waveLength=10.0f,
  503. ISceneNode* parent=0, s32 id=-1,
  504. const core::vector3df& position = core::vector3df(0,0,0),
  505. const core::vector3df& rotation = core::vector3df(0,0,0),
  506. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0;
  507. //! Adds a scene node for rendering using a octree to the scene graph.
  508. /** This a good method for rendering
  509. scenes with lots of geometry. The octree is built on the fly from the mesh.
  510. \param mesh: The mesh containing all geometry from which the octree will be build.
  511. If this animated mesh has more than one frames in it, the first frame is taken.
  512. \param parent: Parent node of the octree node.
  513. \param id: id of the node. This id can be used to identify the node.
  514. \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node.
  515. If a node gets less polys than this value it will not be split into
  516. smaller nodes.
  517. \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
  518. \return Pointer to the octree if successful, otherwise 0.
  519. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  520. virtual IOctreeSceneNode* addOctreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0,
  521. s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false) = 0;
  522. //! Adds a scene node for rendering using a octree to the scene graph.
  523. /** This a good method for rendering scenes with lots of
  524. geometry. The octree is built on the fly from the mesh, much
  525. faster then a bsp tree.
  526. \param mesh: The mesh containing all geometry from which the octree will be build.
  527. \param parent: Parent node of the octree node.
  528. \param id: id of the node. This id can be used to identify the node.
  529. \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node.
  530. If a node gets less polys than this value it will not be split into
  531. smaller nodes.
  532. \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
  533. \return Pointer to the octree if successful, otherwise 0.
  534. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  535. virtual IOctreeSceneNode* addOctreeSceneNode(IMesh* mesh, ISceneNode* parent=0,
  536. s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0;
  537. //! Adds a camera scene node to the scene graph and sets it as active camera.
  538. /** This camera does not react on user input like for example the one created with
  539. addCameraSceneNodeFPS(). If you want to move or animate it, use animators or the
  540. ISceneNode::setPosition(), ICameraSceneNode::setTarget() etc methods.
  541. By default, a camera's look at position (set with setTarget()) and its scene node
  542. rotation (set with setRotation()) are independent. If you want to be able to
  543. control the direction that the camera looks by using setRotation() then call
  544. ICameraSceneNode::bindTargetAndRotation(true) on it.
  545. \param position: Position of the space relative to its parent where the camera will be placed.
  546. \param lookat: Position where the camera will look at. Also known as target.
  547. \param parent: Parent scene node of the camera. Can be null. If the parent moves,
  548. the camera will move too.
  549. \param id: id of the camera. This id can be used to identify the camera.
  550. \param makeActive Flag whether this camera should become the active one.
  551. Make sure you always have one active camera.
  552. \return Pointer to interface to camera if successful, otherwise 0.
  553. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  554. virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0,
  555. const core::vector3df& position = core::vector3df(0,0,0),
  556. const core::vector3df& lookat = core::vector3df(0,0,100),
  557. s32 id=-1, bool makeActive=true) = 0;
  558. //! Adds a maya style user controlled camera scene node to the scene graph.
  559. /** This is a standard camera with an animator that provides mouse control similar
  560. to camera in the 3D Software Maya by Alias Wavefront.
  561. The camera does not react on setPosition anymore after applying this animator. Instead
  562. use setTarget, to fix the target the camera the camera hovers around. And setDistance
  563. to set the current distance from that target, i.e. the radius of the orbit the camera
  564. hovers on.
  565. \param parent: Parent scene node of the camera. Can be null.
  566. \param rotateSpeed: Rotation speed of the camera.
  567. \param zoomSpeed: Zoom speed of the camera.
  568. \param translationSpeed: TranslationSpeed of the camera.
  569. \param id: id of the camera. This id can be used to identify the camera.
  570. \param distance Initial distance of the camera from the object
  571. \param makeActive Flag whether this camera should become the active one.
  572. Make sure you always have one active camera.
  573. \return Returns a pointer to the interface of the camera if successful, otherwise 0.
  574. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  575. virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent=0,
  576. f32 rotateSpeed=-1500.f, f32 zoomSpeed=200.f,
  577. f32 translationSpeed=1500.f, s32 id=-1, f32 distance=70.f,
  578. bool makeActive=true) =0;
  579. //! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS).
  580. /** This FPS camera is intended to provide a demonstration of a
  581. camera that behaves like a typical First Person Shooter. It is
  582. useful for simple demos and prototyping but is not intended to
  583. provide a full solution for a production quality game. It binds
  584. the camera scene node rotation to the look-at target; @see
  585. ICameraSceneNode::bindTargetAndRotation(). With this camera,
  586. you look with the mouse, and move with cursor keys. If you want
  587. to change the key layout, you can specify your own keymap. For
  588. example to make the camera be controlled by the cursor keys AND
  589. the keys W,A,S, and D, do something like this:
  590. \code
  591. SKeyMap keyMap[8];
  592. keyMap[0].Action = EKA_MOVE_FORWARD;
  593. keyMap[0].KeyCode = KEY_UP;
  594. keyMap[1].Action = EKA_MOVE_FORWARD;
  595. keyMap[1].KeyCode = KEY_KEY_W;
  596. keyMap[2].Action = EKA_MOVE_BACKWARD;
  597. keyMap[2].KeyCode = KEY_DOWN;
  598. keyMap[3].Action = EKA_MOVE_BACKWARD;
  599. keyMap[3].KeyCode = KEY_KEY_S;
  600. keyMap[4].Action = EKA_STRAFE_LEFT;
  601. keyMap[4].KeyCode = KEY_LEFT;
  602. keyMap[5].Action = EKA_STRAFE_LEFT;
  603. keyMap[5].KeyCode = KEY_KEY_A;
  604. keyMap[6].Action = EKA_STRAFE_RIGHT;
  605. keyMap[6].KeyCode = KEY_RIGHT;
  606. keyMap[7].Action = EKA_STRAFE_RIGHT;
  607. keyMap[7].KeyCode = KEY_KEY_D;
  608. camera = sceneManager->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8);
  609. \endcode
  610. \param parent: Parent scene node of the camera. Can be null.
  611. \param rotateSpeed: Speed in degrees with which the camera is
  612. rotated. This can be done only with the mouse.
  613. \param moveSpeed: Speed in units per millisecond with which
  614. the camera is moved. Movement is done with the cursor keys.
  615. \param id: id of the camera. This id can be used to identify
  616. the camera.
  617. \param keyMapArray: Optional pointer to an array of a keymap,
  618. specifying what keys should be used to move the camera. If this
  619. is null, the default keymap is used. You can define actions
  620. more then one time in the array, to bind multiple keys to the
  621. same action.
  622. \param keyMapSize: Amount of items in the keymap array.
  623. \param noVerticalMovement: Setting this to true makes the
  624. camera only move within a horizontal plane, and disables
  625. vertical movement as known from most ego shooters. Default is
  626. 'false', with which it is possible to fly around in space, if
  627. no gravity is there.
  628. \param jumpSpeed: Speed with which the camera is moved when
  629. jumping.
  630. \param invertMouse: Setting this to true makes the camera look
  631. up when the mouse is moved down and down when the mouse is
  632. moved up, the default is 'false' which means it will follow the
  633. movement of the mouse cursor.
  634. \param makeActive Flag whether this camera should become the active one.
  635. Make sure you always have one active camera.
  636. \return Pointer to the interface of the camera if successful,
  637. otherwise 0. This pointer should not be dropped. See
  638. IReferenceCounted::drop() for more information. */
  639. virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
  640. f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.5f, s32 id=-1,
  641. SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false,
  642. f32 jumpSpeed = 0.f, bool invertMouse=false,
  643. bool makeActive=true) = 0;
  644. //! Adds a dynamic light scene node to the scene graph.
  645. /** The light will cast dynamic light on all
  646. other scene nodes in the scene, which have the material flag video::MTF_LIGHTING
  647. turned on. (This is the default setting in most scene nodes).
  648. \param parent: Parent scene node of the light. Can be null. If the parent moves,
  649. the light will move too.
  650. \param position: Position of the space relative to its parent where the light will be placed.
  651. \param color: Diffuse color of the light. Ambient or Specular colors can be set manually with
  652. the ILightSceneNode::getLightData() method.
  653. \param radius: Radius of the light.
  654. \param id: id of the node. This id can be used to identify the node.
  655. \return Pointer to the interface of the light if successful, otherwise NULL.
  656. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  657. virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0,
  658. const core::vector3df& position = core::vector3df(0,0,0),
  659. video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f),
  660. f32 radius=100.0f, s32 id=-1) = 0;
  661. //! Adds a billboard scene node to the scene graph.
  662. /** A billboard is like a 3d sprite: A 2d element,
  663. which always looks to the camera. It is usually used for things
  664. like explosions, fire, lensflares and things like that.
  665. \param parent Parent scene node of the billboard. Can be null.
  666. If the parent moves, the billboard will move too.
  667. \param size Size of the billboard. This size is 2 dimensional
  668. because a billboard only has width and height.
  669. \param position Position of the space relative to its parent
  670. where the billboard will be placed.
  671. \param id An id of the node. This id can be used to identify
  672. the node.
  673. \param colorTop The color of the vertices at the top of the
  674. billboard (default: white).
  675. \param colorBottom The color of the vertices at the bottom of
  676. the billboard (default: white).
  677. \return Pointer to the billboard if successful, otherwise NULL.
  678. This pointer should not be dropped. See
  679. IReferenceCounted::drop() for more information. */
  680. virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0,
  681. const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f),
  682. const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1,
  683. video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0;
  684. //! Adds a skybox scene node to the scene graph.
  685. /** A skybox is a big cube with 6 textures on it and
  686. is drawn around the camera position.
  687. \param top: Texture for the top plane of the box.
  688. \param bottom: Texture for the bottom plane of the box.
  689. \param left: Texture for the left plane of the box.
  690. \param right: Texture for the right plane of the box.
  691. \param front: Texture for the front plane of the box.
  692. \param back: Texture for the back plane of the box.
  693. \param parent: Parent scene node of the skybox. A skybox usually has no parent,
  694. so this should be null. Note: If a parent is set to the skybox, the box will not
  695. change how it is drawn.
  696. \param id: An id of the node. This id can be used to identify the node.
  697. \return Pointer to the sky box if successful, otherwise NULL.
  698. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  699. virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom,
  700. video::ITexture* left, video::ITexture* right, video::ITexture* front,
  701. video::ITexture* back, ISceneNode* parent = 0, s32 id=-1) = 0;
  702. //! Adds a skydome scene node to the scene graph.
  703. /** A skydome is a large (half-) sphere with a panoramic texture
  704. on the inside and is drawn around the camera position.
  705. \param texture: Texture for the dome.
  706. \param horiRes: Number of vertices of a horizontal layer of the sphere.
  707. \param vertRes: Number of vertices of a vertical layer of the sphere.
  708. \param texturePercentage: How much of the height of the
  709. texture is used. Should be between 0 and 1.
  710. \param spherePercentage: How much of the sphere is drawn.
  711. Value should be between 0 and 2, where 1 is an exact
  712. half-sphere and 2 is a full sphere.
  713. \param radius The Radius of the sphere
  714. \param parent: Parent scene node of the dome. A dome usually has no parent,
  715. so this should be null. Note: If a parent is set, the dome will not
  716. change how it is drawn.
  717. \param id: An id of the node. This id can be used to identify the node.
  718. \return Pointer to the sky dome if successful, otherwise NULL.
  719. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  720. virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture,
  721. u32 horiRes=16, u32 vertRes=8,
  722. f32 texturePercentage=0.9, f32 spherePercentage=2.0,f32 radius = 1000.f,
  723. ISceneNode* parent=0, s32 id=-1) = 0;
  724. //! Adds a particle system scene node to the scene graph.
  725. /** \param withDefaultEmitter: Creates a default working point emitter
  726. which emits some particles. Set this to true to see a particle system
  727. in action. If set to false, you'll have to set the emitter you want by
  728. calling IParticleSystemSceneNode::setEmitter().
  729. \param parent: Parent of the scene node. Can be NULL if no parent.
  730. \param id: Id of the node. This id can be used to identify the scene node.
  731. \param position: Position of the space relative to its parent where the
  732. scene node will be placed.
  733. \param rotation: Initial rotation of the scene node.
  734. \param scale: Initial scale of the scene node.
  735. \return Pointer to the created scene node.
  736. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  737. virtual IParticleSystemSceneNode* addParticleSystemSceneNode(
  738. bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1,
  739. const core::vector3df& position = core::vector3df(0,0,0),
  740. const core::vector3df& rotation = core::vector3df(0,0,0),
  741. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0;
  742. //! Adds a terrain scene node to the scene graph.
  743. /** This node implements is a simple terrain renderer which uses
  744. a technique known as geo mip mapping
  745. for reducing the detail of triangle blocks which are far away.
  746. The code for the TerrainSceneNode is based on the terrain
  747. renderer by Soconne and the GeoMipMapSceneNode developed by
  748. Spintz. They made their code available for Irrlicht and allowed
  749. it to be distributed under this licence. I only modified some
  750. parts. A lot of thanks go to them.
  751. This scene node is capable of loading terrains and updating
  752. the indices at runtime to enable viewing very large terrains
  753. very quickly. It uses a CLOD (Continuous Level of Detail)
  754. algorithm which updates the indices for each patch based on
  755. a LOD (Level of Detail) which is determined based on a patch's
  756. distance from the camera.
  757. The patch size of the terrain must always be a size of 2^N+1,
  758. i.e. 8+1(9), 16+1(17), etc.
  759. The MaxLOD available is directly dependent on the patch size
  760. of the terrain. LOD 0 contains all of the indices to draw all
  761. the triangles at the max detail for a patch. As each LOD goes
  762. up by 1 the step taken, in generating indices increases by
  763. -2^LOD, so for LOD 1, the step taken is 2, for LOD 2, the step
  764. taken is 4, LOD 3 - 8, etc. The step can be no larger than
  765. the size of the patch, so having a LOD of 8, with a patch size
  766. of 17, is asking the algorithm to generate indices every 2^8 (
  767. 256 ) vertices, which is not possible with a patch size of 17.
  768. The maximum LOD for a patch size of 17 is 2^4 ( 16 ). So,
  769. with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 (
  770. every 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every
  771. 8 vertices ) and LOD 4 ( every 16 vertices ).
  772. \param heightMapFileName: The name of the file on disk, to read vertex data from. This should
  773. be a gray scale bitmap.
  774. \param parent: Parent of the scene node. Can be 0 if no parent.
  775. \param id: Id of the node. This id can be used to identify the scene node.
  776. \param position: The absolute position of this node.
  777. \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED )
  778. \param scale: The scale factor for the terrain. If you're
  779. using a heightmap of size 129x129 and would like your terrain
  780. to be 12900x12900 in game units, then use a scale factor of (
  781. core::vector ( 100.0f, 100.0f, 100.0f ). If you use a Y
  782. scaling factor of 0.0f, then your terrain will be flat.
  783. \param vertexColor: The default color of all the vertices. If no texture is associated
  784. with the scene node, then all vertices will be this color. Defaults to white.
  785. \param maxLOD: The maximum LOD (level of detail) for the node. Only change if you
  786. know what you are doing, this might lead to strange behavior.
  787. \param patchSize: patch size of the terrain. Only change if you
  788. know what you are doing, this might lead to strange behavior.
  789. \param smoothFactor: The number of times the vertices are smoothed.
  790. \param addAlsoIfHeightmapEmpty: Add terrain node even with empty heightmap.
  791. \return Pointer to the created scene node. Can be null
  792. if the terrain could not be created, for example because the
  793. heightmap could not be loaded. The returned pointer should
  794. not be dropped. See IReferenceCounted::drop() for more
  795. information. */
  796. virtual ITerrainSceneNode* addTerrainSceneNode(
  797. const io::path& heightMapFileName,
  798. ISceneNode* parent=0, s32 id=-1,
  799. const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f),
  800. const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f),
  801. const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f),
  802. video::SColor vertexColor = video::SColor(255,255,255,255),
  803. s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0,
  804. bool addAlsoIfHeightmapEmpty = false) = 0;
  805. //! Adds a terrain scene node to the scene graph.
  806. /** Just like the other addTerrainSceneNode() method, but takes an IReadFile
  807. pointer as parameter for the heightmap. For more information take a look
  808. at the other function.
  809. \param heightMapFile: The file handle to read vertex data from. This should
  810. be a gray scale bitmap.
  811. \param parent: Parent of the scene node. Can be 0 if no parent.
  812. \param id: Id of the node. This id can be used to identify the scene node.
  813. \param position: The absolute position of this node.
  814. \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED )
  815. \param scale: The scale factor for the terrain. If you're
  816. using a heightmap of size 129x129 and would like your terrain
  817. to be 12900x12900 in game units, then use a scale factor of (
  818. core::vector ( 100.0f, 100.0f, 100.0f ). If you use a Y
  819. scaling factor of 0.0f, then your terrain will be flat.
  820. \param vertexColor: The default color of all the vertices. If no texture is associated
  821. with the scene node, then all vertices will be this color. Defaults to white.
  822. \param maxLOD: The maximum LOD (level of detail) for the node. Only change if you
  823. know what you are doing, this might lead to strange behavior.
  824. \param patchSize: patch size of the terrain. Only change if you
  825. know what you are doing, this might lead to strange behavior.
  826. \param smoothFactor: The number of times the vertices are smoothed.
  827. \param addAlsoIfHeightmapEmpty: Add terrain node even with empty heightmap.
  828. \return Pointer to the created scene node. Can be null
  829. if the terrain could not be created, for example because the
  830. heightmap could not be loaded. The returned pointer should
  831. not be dropped. See IReferenceCounted::drop() for more
  832. information. */
  833. virtual ITerrainSceneNode* addTerrainSceneNode(
  834. io::IReadFile* heightMapFile,
  835. ISceneNode* parent=0, s32 id=-1,
  836. const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f),
  837. const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f),
  838. const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f),
  839. video::SColor vertexColor = video::SColor(255,255,255,255),
  840. s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0,
  841. bool addAlsoIfHeightmapEmpty = false) = 0;
  842. //! Adds a quake3 scene node to the scene graph.
  843. /** A Quake3 Scene renders multiple meshes for a specific HighLanguage Shader (Quake3 Style )
  844. \return Pointer to the quake3 scene node if successful, otherwise NULL.
  845. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  846. virtual IMeshSceneNode* addQuake3SceneNode(const IMeshBuffer* meshBuffer, const quake3::IShader * shader,
  847. ISceneNode* parent=0, s32 id=-1
  848. ) = 0;
  849. //! Adds an empty scene node to the scene graph.
  850. /** Can be used for doing advanced transformations
  851. or structuring the scene graph.
  852. \return Pointer to the created scene node.
  853. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  854. virtual ISceneNode* addEmptySceneNode(ISceneNode* parent=0, s32 id=-1) = 0;
  855. //! Adds a dummy transformation scene node to the scene graph.
  856. /** This scene node does not render itself, and does not respond to set/getPosition,
  857. set/getRotation and set/getScale. Its just a simple scene node that takes a
  858. matrix as relative transformation, making it possible to insert any transformation
  859. anywhere into the scene graph.
  860. \return Pointer to the created scene node.
  861. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  862. virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode(
  863. ISceneNode* parent=0, s32 id=-1) = 0;
  864. //! Adds a text scene node, which is able to display 2d text at a position in three dimensional space
  865. virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text,
  866. video::SColor color=video::SColor(100,255,255,255),
  867. ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0),
  868. s32 id=-1) = 0;
  869. //! Adds a text scene node, which uses billboards. The node, and the text on it, will scale with distance.
  870. /**
  871. \param font The font to use on the billboard. Pass 0 to use the GUI environment's default font.
  872. \param text The text to display on the billboard.
  873. \param parent The billboard's parent. Pass 0 to use the root scene node.
  874. \param size The billboard's width and height.
  875. \param position The billboards position relative to its parent.
  876. \param id: An id of the node. This id can be used to identify the node.
  877. \param colorTop: The color of the vertices at the top of the billboard (default: white).
  878. \param colorBottom: The color of the vertices at the bottom of the billboard (default: white).
  879. \return Pointer to the billboard if successful, otherwise NULL.
  880. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  881. virtual IBillboardTextSceneNode* addBillboardTextSceneNode( gui::IGUIFont* font, const wchar_t* text,
  882. ISceneNode* parent = 0,
  883. const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f),
  884. const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1,
  885. video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0;
  886. //! Adds a Hill Plane mesh to the mesh pool.
  887. /** The mesh is generated on the fly
  888. and looks like a plane with some hills on it. It is uses mostly for quick
  889. tests of the engine only. You can specify how many hills there should be
  890. on the plane and how high they should be. Also you must specify a name for
  891. the mesh, because the mesh is added to the mesh pool, and can be retrieved
  892. again using ISceneManager::getMesh() with the name as parameter.
  893. \param name: The name of this mesh which must be specified in order
  894. to be able to retrieve the mesh later with ISceneManager::getMesh().
  895. \param tileSize: Size of a tile of the mesh. (10.0f, 10.0f) would be a
  896. good value to start, for example.
  897. \param tileCount: Specifies how much tiles there will be. If you specify
  898. for example that a tile has the size (10.0f, 10.0f) and the tileCount is
  899. (10,10), than you get a field of 100 tiles which has the dimension 100.0f x 100.0f.
  900. \param material: Material of the hill mesh.
  901. \param hillHeight: Height of the hills. If you specify a negative value
  902. you will get holes instead of hills. If the height is 0, no hills will be
  903. created.
  904. \param countHills: Amount of hills on the plane. There will be countHills.X
  905. hills along the X axis and countHills.Y along the Y axis. So in total there
  906. will be countHills.X * countHills.Y hills.
  907. \param textureRepeatCount: Defines how often the texture will be repeated in
  908. x and y direction.
  909. return Null if the creation failed. The reason could be that you
  910. specified some invalid parameters or that a mesh with that name already
  911. exists. If successful, a pointer to the mesh is returned.
  912. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  913. virtual IAnimatedMesh* addHillPlaneMesh(const io::path& name,
  914. const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount,
  915. video::SMaterial* material = 0, f32 hillHeight = 0.0f,
  916. const core::dimension2d<f32>& countHills = core::dimension2d<f32>(0.0f, 0.0f),
  917. const core::dimension2d<f32>& textureRepeatCount = core::dimension2d<f32>(1.0f, 1.0f)) = 0;
  918. //! Adds a static terrain mesh to the mesh pool.
  919. /** The mesh is generated on the fly
  920. from a texture file and a height map file. Both files may be huge
  921. (8000x8000 pixels would be no problem) because the generator splits the
  922. files into smaller textures if necessary.
  923. You must specify a name for the mesh, because the mesh is added to the mesh pool,
  924. and can be retrieved again using ISceneManager::getMesh() with the name as parameter.
  925. \param meshname: The name of this mesh which must be specified in order
  926. to be able to retrieve the mesh later with ISceneManager::getMesh().
  927. \param texture: Texture for the terrain. Please note that this is not a
  928. hardware texture as usual (ITexture), but an IImage software texture.
  929. You can load this texture with IVideoDriver::createImageFromFile().
  930. \param heightmap: A grayscaled heightmap image. Like the texture,
  931. it can be created with IVideoDriver::createImageFromFile(). The amount
  932. of triangles created depends on the size of this texture, so use a small
  933. heightmap to increase rendering speed.
  934. \param stretchSize: Parameter defining how big a is pixel on the heightmap.
  935. \param maxHeight: Defines how high a white pixel on the heightmap is.
  936. \param defaultVertexBlockSize: Defines the initial dimension between vertices.
  937. \return Null if the creation failed. The reason could be that you
  938. specified some invalid parameters, that a mesh with that name already
  939. exists, or that a texture could not be found. If successful, a pointer to the mesh is returned.
  940. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  941. virtual IAnimatedMesh* addTerrainMesh(const io::path& meshname,
  942. video::IImage* texture, video::IImage* heightmap,
  943. const core::dimension2d<f32>& stretchSize = core::dimension2d<f32>(10.0f,10.0f),
  944. f32 maxHeight=200.0f,
  945. const core::dimension2d<u32>& defaultVertexBlockSize = core::dimension2d<u32>(64,64)) = 0;
  946. //! add a static arrow mesh to the meshpool
  947. /** \param name Name of the mesh
  948. \param vtxColorCylinder color of the cylinder
  949. \param vtxColorCone color of the cone
  950. \param tesselationCylinder Number of quads the cylinder side consists of
  951. \param tesselationCone Number of triangles the cone's roof consists of
  952. \param height Total height of the arrow
  953. \param cylinderHeight Total height of the cylinder, should be lesser than total height
  954. \param widthCylinder Diameter of the cylinder
  955. \param widthCone Diameter of the cone's base, should be not smaller than the cylinder's diameter
  956. \return Pointer to the arrow mesh if successful, otherwise 0.
  957. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  958. virtual IAnimatedMesh* addArrowMesh(const io::path& name,
  959. video::SColor vtxColorCylinder=0xFFFFFFFF,
  960. video::SColor vtxColorCone=0xFFFFFFFF,
  961. u32 tesselationCylinder=4, u32 tesselationCone=8,
  962. f32 height=1.f, f32 cylinderHeight=0.6f,
  963. f32 widthCylinder=0.05f, f32 widthCone=0.3f) = 0;
  964. //! add a static sphere mesh to the meshpool
  965. /** \param name Name of the mesh
  966. \param radius Radius of the sphere
  967. \param polyCountX Number of quads used for the horizontal tiling
  968. \param polyCountY Number of quads used for the vertical tiling
  969. \return Pointer to the sphere mesh if successful, otherwise 0.
  970. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  971. virtual IAnimatedMesh* addSphereMesh(const io::path& name,
  972. f32 radius=5.f, u32 polyCountX = 16,
  973. u32 polyCountY = 16) = 0;
  974. //! Add a volume light mesh to the meshpool
  975. /** \param name Name of the mesh
  976. \param SubdivideU Horizontal subdivision count
  977. \param SubdivideV Vertical subdivision count
  978. \param FootColor Color of the bottom of the light
  979. \param TailColor Color of the top of the light
  980. \return Pointer to the volume light mesh if successful, otherwise 0.
  981. This pointer should not be dropped. See IReferenceCounted::drop() for more information.
  982. */
  983. virtual IAnimatedMesh* addVolumeLightMesh(const io::path& name,
  984. const u32 SubdivideU = 32, const u32 SubdivideV = 32,
  985. const video::SColor FootColor = video::SColor(51, 0, 230, 180),
  986. const video::SColor TailColor = video::SColor(0, 0, 0, 0)) = 0;
  987. //! Gets the root scene node.
  988. /** This is the scene node which is parent
  989. of all scene nodes. The root scene node is a special scene node which
  990. only exists to manage all scene nodes. It will not be rendered and cannot
  991. be removed from the scene.
  992. \return Pointer to the root scene node.
  993. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  994. virtual ISceneNode* getRootSceneNode() = 0;
  995. //! Get the first scene node with the specified id.
  996. /** \param id: The id to search for
  997. \param start: Scene node to start from. All children of this scene
  998. node are searched. If null is specified, the root scene node is
  999. taken.
  1000. \return Pointer to the first scene node with this id,
  1001. and null if no scene node could be found.
  1002. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1003. virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0) = 0;
  1004. //! Get the first scene node with the specified name.
  1005. /** \param name: The name to search for
  1006. \param start: Scene node to start from. All children of this scene
  1007. node are searched. If null is specified, the root scene node is
  1008. taken.
  1009. \return Pointer to the first scene node with this id,
  1010. and null if no scene node could be found.
  1011. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1012. virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0) = 0;
  1013. //! Get the first scene node with the specified type.
  1014. /** \param type: The type to search for
  1015. \param start: Scene node to start from. All children of this scene
  1016. node are searched. If null is specified, the root scene node is
  1017. taken.
  1018. \return Pointer to the first scene node with this type,
  1019. and null if no scene node could be found.
  1020. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1021. virtual ISceneNode* getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode* start=0) = 0;
  1022. //! Get scene nodes by type.
  1023. /** \param type: Type of scene node to find (ESNT_ANY will return all child nodes).
  1024. \param outNodes: results will be added to this array (outNodes is not cleared).
  1025. \param start: Scene node to start from. This node and all children of this scene
  1026. node are checked (recursively, so also children of children, etc). If null is specified,
  1027. the root scene node is taken as start-node. */
  1028. virtual void getSceneNodesFromType(ESCENE_NODE_TYPE type,
  1029. core::array<scene::ISceneNode*>& outNodes,
  1030. ISceneNode* start=0) = 0;
  1031. //! Get the current active camera.
  1032. /** \return The active camera is returned. Note that this can
  1033. be NULL, if there was no camera created yet.
  1034. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1035. virtual ICameraSceneNode* getActiveCamera() const =0;
  1036. //! Sets the currently active camera.
  1037. /** The previous active camera will be deactivated.
  1038. \param camera: The new camera which should be active. */
  1039. virtual void setActiveCamera(ICameraSceneNode* camera) = 0;
  1040. //! Sets the color of stencil buffers shadows drawn by the scene manager.
  1041. virtual void setShadowColor(video::SColor color = video::SColor(150,0,0,0)) = 0;
  1042. //! Get the current color of shadows.
  1043. virtual video::SColor getShadowColor() const = 0;
  1044. //! Create a shadow volume scene node to be used with custom nodes
  1045. /** Use this if you implement your own SceneNodes and need shadow volumes in them.
  1046. Otherwise you should generally use addShadowVolumeSceneNode functions from IMeshSceneNode or IAnimatedMeshSceneNode.*/
  1047. virtual IShadowVolumeSceneNode* createShadowVolumeSceneNode(const IMesh* shadowMesh, ISceneNode* parent, s32 id, bool zfailmethod, f32 infinity) = 0;
  1048. //! Registers a node for rendering it at a specific time.
  1049. /** This method should only be used by SceneNodes when they get a
  1050. ISceneNode::OnRegisterSceneNode() call.
  1051. \param node: Node to register for drawing. Usually scene nodes would set 'this'
  1052. as parameter here because they want to be drawn.
  1053. \param pass: Specifies when the node wants to be drawn in relation to the other nodes.
  1054. For example, if the node is a shadow, it usually wants to be drawn after all other nodes
  1055. and will use ESNRP_SHADOW for this. See scene::E_SCENE_NODE_RENDER_PASS for details.
  1056. Note: This is _not_ a bitfield. If you want to register a note for several render passes, then
  1057. call this function once for each pass.
  1058. \return scene will be rendered ( passed culling ) */
  1059. virtual u32 registerNodeForRendering(ISceneNode* node,
  1060. E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0;
  1061. //! Clear all nodes which are currently registered for rendering
  1062. /** Usually you don't have to care about this as drawAll will clear nodes
  1063. after rendering them. But sometimes you might have to manully reset this.
  1064. For example when you deleted nodes between registering and rendering. */
  1065. virtual void clearAllRegisteredNodesForRendering() = 0;
  1066. //! Draws all the scene nodes.
  1067. /** This can only be invoked between
  1068. IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that
  1069. the scene is not only drawn when calling this, but also animated
  1070. by existing scene node animators, culling of scene nodes is done, etc. */
  1071. virtual void drawAll() = 0;
  1072. //! Creates a rotation animator, which rotates the attached scene node around itself.
  1073. /** \param rotationSpeed Specifies the speed of the animation in degree per 10 milliseconds.
  1074. \return The animator. Attach it to a scene node with ISceneNode::addAnimator()
  1075. and the animator will animate it.
  1076. If you no longer need the animator, you should call ISceneNodeAnimator::drop().
  1077. See IReferenceCounted::drop() for more information. */
  1078. virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationSpeed) = 0;
  1079. //! Creates a fly circle animator, which lets the attached scene node fly around a center.
  1080. /** \param center: Center of the circle.
  1081. \param radius: Radius of the circle.
  1082. \param speed: The orbital speed, in radians per millisecond.
  1083. \param direction: Specifies the upvector used for alignment of the mesh.
  1084. \param startPosition: The position on the circle where the animator will
  1085. begin. Value is in multiples of a circle, i.e. 0.5 is half way around. (phase)
  1086. \param radiusEllipsoid: if radiusEllipsoid != 0 then radius2 from a ellipsoid
  1087. begin. Value is in multiples of a circle, i.e. 0.5 is half way around. (phase)
  1088. \return The animator. Attach it to a scene node with ISceneNode::addAnimator()
  1089. and the animator will animate it.
  1090. If you no longer need the animator, you should call ISceneNodeAnimator::drop().
  1091. See IReferenceCounted::drop() for more information. */
  1092. virtual ISceneNodeAnimator* createFlyCircleAnimator(
  1093. const core::vector3df& center=core::vector3df(0.f,0.f,0.f),
  1094. f32 radius=100.f, f32 speed=0.001f,
  1095. const core::vector3df& direction=core::vector3df(0.f, 1.f, 0.f),
  1096. f32 startPosition = 0.f,
  1097. f32 radiusEllipsoid = 0.f) = 0;
  1098. //! Creates a fly straight animator, which lets the attached scene node fly or move along a line between two points.
  1099. /** \param startPoint: Start point of the line.
  1100. \param endPoint: End point of the line.
  1101. \param timeForWay: Time in milliseconds how long the node should need to
  1102. move from the start point to the end point.
  1103. \param loop: If set to false, the node stops when the end point is reached.
  1104. If loop is true, the node begins again at the start.
  1105. \param pingpong Flag to set whether the animator should fly
  1106. back from end to start again.
  1107. \return The animator. Attach it to a scene node with ISceneNode::addAnimator()
  1108. and the animator will animate it.
  1109. If you no longer need the animator, you should call ISceneNodeAnimator::drop().
  1110. See IReferenceCounted::drop() for more information. */
  1111. virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint,
  1112. const core::vector3df& endPoint, u32 timeForWay, bool loop=false, bool pingpong = false) = 0;
  1113. //! Creates a texture animator, which switches the textures of the target scene node based on a list of textures.
  1114. /** \param textures: List of textures to use.
  1115. \param timePerFrame: Time in milliseconds, how long any texture in the list
  1116. should be visible.
  1117. \param loop: If set to to false, the last texture remains set, and the animation
  1118. stops. If set to true, the animation restarts with the first texture.
  1119. \return The animator. Attach it to a scene node with ISceneNode::addAnimator()
  1120. and the animator will animate it.
  1121. If you no longer need the animator, you should call ISceneNodeAnimator::drop().
  1122. See IReferenceCounted::drop() for more information. */
  1123. virtual ISceneNodeAnimator* createTextureAnimator(const core::array<video::ITexture*>& textures,
  1124. s32 timePerFrame, bool loop=true) = 0;
  1125. //! Creates a scene node animator, which deletes the scene node after some time automatically.
  1126. /** \param timeMs: Time in milliseconds, after when the node will be deleted.
  1127. \return The animator. Attach it to a scene node with ISceneNode::addAnimator()
  1128. and the animator will animate it.
  1129. If you no longer need the animator, you should call ISceneNodeAnimator::drop().
  1130. See IReferenceCounted::drop() for more information. */
  1131. virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMs) = 0;
  1132. //! Creates a special scene node animator for doing automatic collision detection and response.
  1133. /** See ISceneNodeAnimatorCollisionResponse for details.
  1134. \param world: Triangle selector holding all triangles of the world with which
  1135. the scene node may collide. You can create a triangle selector with
  1136. ISceneManager::createTriangleSelector();
  1137. \param sceneNode: SceneNode which should be manipulated. After you added this animator
  1138. to the scene node, the scene node will not be able to move through walls and is
  1139. affected by gravity. If you need to teleport the scene node to a new position without
  1140. it being effected by the collision geometry, then call sceneNode->setPosition(); then
  1141. animator->setTargetNode(sceneNode);
  1142. \param ellipsoidRadius: Radius of the ellipsoid with which collision detection and
  1143. response is done. If you have got a scene node, and you are unsure about
  1144. how big the radius should be, you could use the following code to determine
  1145. it:
  1146. \code
  1147. const core::aabbox3d<f32>& box = yourSceneNode->getBoundingBox();
  1148. core::vector3df radius = box.MaxEdge - box.getCenter();
  1149. \endcode
  1150. \param gravityPerSecond: Sets the gravity of the environment, as an acceleration in
  1151. units per second per second. If your units are equivalent to meters, then
  1152. core::vector3df(0,-10.0f,0) would give an approximately realistic gravity.
  1153. You can disable gravity by setting it to core::vector3df(0,0,0).
  1154. \param ellipsoidTranslation: By default, the ellipsoid for collision detection is created around
  1155. the center of the scene node, which means that the ellipsoid surrounds
  1156. it completely. If this is not what you want, you may specify a translation
  1157. for the ellipsoid.
  1158. \param slidingValue: DOCUMENTATION NEEDED.
  1159. \return The animator. Attach it to a scene node with ISceneNode::addAnimator()
  1160. and the animator will cause it to do collision detection and response.
  1161. If you no longer need the animator, you should call ISceneNodeAnimator::drop().
  1162. See IReferenceCounted::drop() for more information. */
  1163. virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator(
  1164. ITriangleSelector* world, ISceneNode* sceneNode,
  1165. const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30),
  1166. const core::vector3df& gravityPerSecond = core::vector3df(0,-10.0f,0),
  1167. const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0),
  1168. f32 slidingValue = 0.0005f) = 0;
  1169. //! Creates a follow spline animator.
  1170. /** The animator modifies the position of
  1171. the attached scene node to make it follow a Hermite spline.
  1172. It uses a subset of Hermite splines: either cardinal splines
  1173. (tightness != 0.5) or Catmull-Rom-splines (tightness == 0.5).
  1174. The animator moves from one control point to the next in
  1175. 1/speed seconds. This code was sent in by Matthias Gall.
  1176. If you no longer need the animator, you should call ISceneNodeAnimator::drop().
  1177. See IReferenceCounted::drop() for more information. */
  1178. virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime,
  1179. const core::array< core::vector3df >& points,
  1180. f32 speed = 1.0f, f32 tightness = 0.5f, bool loop=true, bool pingpong=false) = 0;
  1181. //! Creates a simple ITriangleSelector, based on a mesh.
  1182. /** Triangle selectors
  1183. can be used for doing collision detection. Don't use this selector
  1184. for a huge amount of triangles like in Quake3 maps.
  1185. Instead, use for example ISceneManager::createOctreeTriangleSelector().
  1186. Please note that the created triangle selector is not automatically attached
  1187. to the scene node. You will have to call ISceneNode::setTriangleSelector()
  1188. for this. To create and attach a triangle selector is done like this:
  1189. \code
  1190. ITriangleSelector* s = sceneManager->createTriangleSelector(yourMesh,
  1191. yourSceneNode);
  1192. yourSceneNode->setTriangleSelector(s);
  1193. s->drop();
  1194. \endcode
  1195. \param mesh: Mesh of which the triangles are taken.
  1196. \param node: Scene node of which transformation is used.
  1197. \param separateMeshbuffers: When true it's possible to get information which meshbuffer
  1198. got hit in collision tests. But has a slight speed cost.
  1199. \return The selector, or null if not successful.
  1200. If you no longer need the selector, you should call ITriangleSelector::drop().
  1201. See IReferenceCounted::drop() for more information. */
  1202. virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node, bool separateMeshbuffers=false) = 0;
  1203. //! Creates a simple ITriangleSelector, based on a meshbuffer.
  1204. /**
  1205. This is a static selector which won't update when the mesh changes.
  1206. \param meshBuffer Triangles of that meshbuffer are used
  1207. \param materialIndex If you pass a material index that index can be returned by the triangle selector.
  1208. \para node: Scene node of which transformation is used.
  1209. */
  1210. virtual ITriangleSelector* createTriangleSelector(const IMeshBuffer* meshBuffer, irr::u32 materialIndex, ISceneNode* node) = 0;
  1211. //! Creates a simple ITriangleSelector, based on an animated mesh scene node.
  1212. /** Details of the mesh associated with the node will be extracted internally.
  1213. \param node The animated mesh scene node from which to build the selector
  1214. \param separateMeshbuffers: When true it's possible to get information which meshbuffer
  1215. got hit in collision tests. But has a slight speed cost.
  1216. */
  1217. virtual ITriangleSelector* createTriangleSelector(IAnimatedMeshSceneNode* node, bool separateMeshbuffers=false) = 0;
  1218. //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box.
  1219. /** Triangle selectors
  1220. can be used for doing collision detection. Every time when triangles are
  1221. queried, the triangle selector gets the bounding box of the scene node,
  1222. an creates new triangles. In this way, it works good with animated scene nodes.
  1223. \param node: Scene node of which the bounding box, visibility and transformation is used.
  1224. \return The selector, or null if not successful.
  1225. If you no longer need the selector, you should call ITriangleSelector::drop().
  1226. See IReferenceCounted::drop() for more information. */
  1227. virtual ITriangleSelector* createTriangleSelectorFromBoundingBox(ISceneNode* node) = 0;
  1228. //! Creates a Triangle Selector, optimized by an octree.
  1229. /** Triangle selectors
  1230. can be used for doing collision detection. This triangle selector is
  1231. optimized for huge amounts of triangle, it organizes them in an octree.
  1232. Please note that the created triangle selector is not automatically attached
  1233. to the scene node. You will have to call ISceneNode::setTriangleSelector()
  1234. for this. To create and attach a triangle selector is done like this:
  1235. \code
  1236. ITriangleSelector* s = sceneManager->createOctreeTriangleSelector(yourMesh,
  1237. yourSceneNode);
  1238. yourSceneNode->setTriangleSelector(s);
  1239. s->drop();
  1240. \endcode
  1241. For more information and examples on this, take a look at the collision
  1242. tutorial in the SDK.
  1243. \param mesh: Mesh of which the triangles are taken.
  1244. \param node: Scene node of which visibility and transformation is used.
  1245. \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node.
  1246. If a node gets less polys than this value, it will not be split into
  1247. smaller nodes.
  1248. \return The selector, or null if not successful.
  1249. If you no longer need the selector, you should call ITriangleSelector::drop().
  1250. See IReferenceCounted::drop() for more information. */
  1251. virtual ITriangleSelector* createOctreeTriangleSelector(IMesh* mesh,
  1252. ISceneNode* node, s32 minimalPolysPerNode=32) = 0;
  1253. //! Creates a Triangle Selector for a single meshbuffer, optimized by an octree.
  1254. /** Triangle selectors
  1255. can be used for doing collision detection. This triangle selector is
  1256. optimized for huge amounts of triangle, it organizes them in an octree.
  1257. Please note that the created triangle selector is not automatically attached
  1258. to the scene node. You will have to call ISceneNode::setTriangleSelector()
  1259. for this. To create and attach a triangle selector is done like this:
  1260. \code
  1261. ITriangleSelector* s = sceneManager->createOctreeTriangleSelector(yourMesh,
  1262. yourSceneNode);
  1263. yourSceneNode->setTriangleSelector(s);
  1264. s->drop();
  1265. \endcode
  1266. For more information and examples on this, take a look at the collision
  1267. tutorial in the SDK.
  1268. \param meshBuffer: Meshbuffer of which the triangles are taken.
  1269. \param materialIndex: Setting this value allows the triangle selector to return the material index
  1270. \param node: Scene node of which visibility and transformation is used.
  1271. \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node.
  1272. If a node gets less polys than this value, it will not be split into
  1273. smaller nodes.
  1274. \return The selector, or null if not successful.
  1275. If you no longer need the selector, you should call ITriangleSelector::drop().
  1276. See IReferenceCounted::drop() for more information. */
  1277. virtual ITriangleSelector* createOctreeTriangleSelector(IMeshBuffer* meshBuffer, irr::u32 materialIndex,
  1278. ISceneNode* node, s32 minimalPolysPerNode=32) = 0;
  1279. //! //! Creates a Triangle Selector, optimized by an octree.
  1280. /** \deprecated Use createOctreeTriangleSelector instead. This method may be removed by Irrlicht 1.9. */
  1281. _IRR_DEPRECATED_ ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh,
  1282. ISceneNode* node, s32 minimalPolysPerNode=32)
  1283. {
  1284. return createOctreeTriangleSelector(mesh, node, minimalPolysPerNode);
  1285. }
  1286. //! Creates a meta triangle selector.
  1287. /** A meta triangle selector is nothing more than a
  1288. collection of one or more triangle selectors providing together
  1289. the interface of one triangle selector. In this way,
  1290. collision tests can be done with different triangle soups in one pass.
  1291. \return The selector, or null if not successful.
  1292. If you no longer need the selector, you should call ITriangleSelector::drop().
  1293. See IReferenceCounted::drop() for more information. */
  1294. virtual IMetaTriangleSelector* createMetaTriangleSelector() = 0;
  1295. //! Creates a triangle selector which can select triangles from a terrain scene node.
  1296. /** \param node: Pointer to the created terrain scene node
  1297. \param LOD: Level of detail, 0 for highest detail.
  1298. \return The selector, or null if not successful.
  1299. If you no longer need the selector, you should call ITriangleSelector::drop().
  1300. See IReferenceCounted::drop() for more information. */
  1301. virtual ITriangleSelector* createTerrainTriangleSelector(
  1302. ITerrainSceneNode* node, s32 LOD=0) = 0;
  1303. //! Adds an external mesh loader for extending the engine with new file formats.
  1304. /** If you want the engine to be extended with
  1305. file formats it currently is not able to load (e.g. .cob), just implement
  1306. the IMeshLoader interface in your loading class and add it with this method.
  1307. Using this method it is also possible to override built-in mesh loaders with
  1308. newer or updated versions without the need to recompile the engine.
  1309. \param externalLoader: Implementation of a new mesh loader. */
  1310. virtual void addExternalMeshLoader(IMeshLoader* externalLoader) = 0;
  1311. //! Returns the number of mesh loaders supported by Irrlicht at this time
  1312. virtual u32 getMeshLoaderCount() const = 0;
  1313. //! Retrieve the given mesh loader
  1314. /** \param index The index of the loader to retrieve. This parameter is an 0-based
  1315. array index.
  1316. \return A pointer to the specified loader, 0 if the index is incorrect. */
  1317. virtual IMeshLoader* getMeshLoader(u32 index) const = 0;
  1318. //! Adds an external scene loader for extending the engine with new file formats.
  1319. /** If you want the engine to be extended with
  1320. file formats it currently is not able to load (e.g. .vrml), just implement
  1321. the ISceneLoader interface in your loading class and add it with this method.
  1322. Using this method it is also possible to override the built-in scene loaders
  1323. with newer or updated versions without the need to recompile the engine.
  1324. \param externalLoader: Implementation of a new mesh loader. */
  1325. virtual void addExternalSceneLoader(ISceneLoader* externalLoader) = 0;
  1326. //! Returns the number of scene loaders supported by Irrlicht at this time
  1327. virtual u32 getSceneLoaderCount() const = 0;
  1328. //! Retrieve the given scene loader
  1329. /** \param index The index of the loader to retrieve. This parameter is an 0-based
  1330. array index.
  1331. \return A pointer to the specified loader, 0 if the index is incorrect. */
  1332. virtual ISceneLoader* getSceneLoader(u32 index) const = 0;
  1333. //! Get pointer to the scene collision manager.
  1334. /** \return Pointer to the collision manager
  1335. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1336. virtual ISceneCollisionManager* getSceneCollisionManager() = 0;
  1337. //! Get pointer to the mesh manipulator.
  1338. /** \return Pointer to the mesh manipulator
  1339. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1340. virtual IMeshManipulator* getMeshManipulator() = 0;
  1341. //! Adds a scene node to the deletion queue.
  1342. /** The scene node is immediately
  1343. deleted when it's secure. Which means when the scene node does not
  1344. execute animators and things like that. This method is for example
  1345. used for deleting scene nodes by their scene node animators. In
  1346. most other cases, a ISceneNode::remove() call is enough, using this
  1347. deletion queue is not necessary.
  1348. See ISceneManager::createDeleteAnimator() for details.
  1349. \param node: Node to delete. */
  1350. virtual void addToDeletionQueue(ISceneNode* node) = 0;
  1351. //! Posts an input event to the environment.
  1352. /** Usually you do not have to
  1353. use this method, it is used by the internal engine. */
  1354. virtual bool postEventFromUser(const SEvent& event) = 0;
  1355. //! Clears the whole scene.
  1356. /** All scene nodes are removed. */
  1357. virtual void clear() = 0;
  1358. //! Get interface to the parameters set in this scene.
  1359. /** String parameters can be used by plugins and mesh loaders.
  1360. See COLLADA_CREATE_SCENE_INSTANCES and DMF_USE_MATERIALS_DIRS */
  1361. virtual io::IAttributes* getParameters() = 0;
  1362. //! Get current render pass.
  1363. /** All scene nodes are being rendered in a specific order.
  1364. First lights, cameras, sky boxes, solid geometry, and then transparent
  1365. stuff. During the rendering process, scene nodes may want to know what the scene
  1366. manager is rendering currently, because for example they registered for rendering
  1367. twice, once for transparent geometry and once for solid. When knowing what rendering
  1368. pass currently is active they can render the correct part of their geometry. */
  1369. virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const = 0;
  1370. //! Get the default scene node factory which can create all built in scene nodes
  1371. /** \return Pointer to the default scene node factory
  1372. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1373. virtual ISceneNodeFactory* getDefaultSceneNodeFactory() = 0;
  1374. //! Adds a scene node factory to the scene manager.
  1375. /** Use this to extend the scene manager with new scene node types which it should be
  1376. able to create automatically, for example when loading data from xml files. */
  1377. virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) = 0;
  1378. //! Get amount of registered scene node factories.
  1379. virtual u32 getRegisteredSceneNodeFactoryCount() const = 0;
  1380. //! Get a scene node factory by index
  1381. /** \return Pointer to the requested scene node factory, or 0 if it does not exist.
  1382. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1383. virtual ISceneNodeFactory* getSceneNodeFactory(u32 index) = 0;
  1384. //! Get the default scene node animator factory which can create all built-in scene node animators
  1385. /** \return Pointer to the default scene node animator factory
  1386. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1387. virtual ISceneNodeAnimatorFactory* getDefaultSceneNodeAnimatorFactory() = 0;
  1388. //! Adds a scene node animator factory to the scene manager.
  1389. /** Use this to extend the scene manager with new scene node animator types which it should be
  1390. able to create automatically, for example when loading data from xml files. */
  1391. virtual void registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd) = 0;
  1392. //! Get amount of registered scene node animator factories.
  1393. virtual u32 getRegisteredSceneNodeAnimatorFactoryCount() const = 0;
  1394. //! Get scene node animator factory by index
  1395. /** \return Pointer to the requested scene node animator factory, or 0 if it does not exist.
  1396. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1397. virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(u32 index) = 0;
  1398. //! Get typename from a scene node type or null if not found
  1399. virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type) = 0;
  1400. //! Returns a typename from a scene node animator type or null if not found
  1401. virtual const c8* getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) = 0;
  1402. //! Adds a scene node to the scene by name
  1403. /** \return Pointer to the scene node added by a factory
  1404. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  1405. virtual ISceneNode* addSceneNode(const char* sceneNodeTypeName, ISceneNode* parent=0) = 0;
  1406. //! creates a scene node animator based on its type name
  1407. /** \param typeName: Type of the scene node animator to add.
  1408. \param target: Target scene node of the new animator.
  1409. \return Returns pointer to the new scene node animator or null if not successful. You need to
  1410. drop this pointer after calling this, see IReferenceCounted::drop() for details. */
  1411. virtual ISceneNodeAnimator* createSceneNodeAnimator(const char* typeName, ISceneNode* target=0) = 0;
  1412. //! Creates a new scene manager.
  1413. /** This can be used to easily draw and/or store two
  1414. independent scenes at the same time. The mesh cache will be
  1415. shared between all existing scene managers, which means if you
  1416. load a mesh in the original scene manager using for example
  1417. getMesh(), the mesh will be available in all other scene
  1418. managers too, without loading.
  1419. The original/main scene manager will still be there and
  1420. accessible via IrrlichtDevice::getSceneManager(). If you need
  1421. input event in this new scene manager, for example for FPS
  1422. cameras, you'll need to forward input to this manually: Just
  1423. implement an IEventReceiver and call
  1424. yourNewSceneManager->postEventFromUser(), and return true so
  1425. that the original scene manager doesn't get the event.
  1426. Otherwise, all input will go to the main scene manager
  1427. automatically.
  1428. If you no longer need the new scene manager, you should call
  1429. ISceneManager::drop().
  1430. See IReferenceCounted::drop() for more information. */
  1431. virtual ISceneManager* createNewSceneManager(bool cloneContent=false) = 0;
  1432. //! Saves the current scene into a file.
  1433. /** Scene nodes with the option isDebugObject set to true are
  1434. not being saved. The scene is usually written to an .irr file,
  1435. an xml based format. .irr files can Be edited with the Irrlicht
  1436. Engine Editor, irrEdit (http://www.ambiera.com/irredit/). To
  1437. load .irr files again, see ISceneManager::loadScene().
  1438. \param filename Name of the file.
  1439. \param userDataSerializer If you want to save some user data
  1440. for every scene node into the file, implement the
  1441. ISceneUserDataSerializer interface and provide it as parameter
  1442. here. Otherwise, simply specify 0 as this parameter.
  1443. \param node Node which is taken as the top node of the scene.
  1444. This node and all of its descendants are saved into the scene
  1445. file. Pass 0 or the scene manager to save the full scene (which
  1446. is also the default).
  1447. \return True if successful. */
  1448. virtual bool saveScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0) = 0;
  1449. //! Saves the current scene into a file.
  1450. /** Scene nodes with the option isDebugObject set to true are
  1451. not being saved. The scene is usually written to an .irr file,
  1452. an xml based format. .irr files can Be edited with the Irrlicht
  1453. Engine Editor, irrEdit (http://www.ambiera.com/irredit/). To
  1454. load .irr files again, see ISceneManager::loadScene().
  1455. \param file File where the scene is saved into.
  1456. \param userDataSerializer If you want to save some user data
  1457. for every scene node into the file, implement the
  1458. ISceneUserDataSerializer interface and provide it as parameter
  1459. here. Otherwise, simply specify 0 as this parameter.
  1460. \param node Node which is taken as the top node of the scene.
  1461. This node and all of its descendants are saved into the scene
  1462. file. Pass 0 or the scene manager to save the full scene (which
  1463. is also the default).
  1464. \return True if successful. */
  1465. virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0) = 0;
  1466. //! Saves the current scene into a file.
  1467. /** Scene nodes with the option isDebugObject set to true are
  1468. not being saved. The scene is usually written to an .irr file,
  1469. an xml based format. .irr files can Be edited with the Irrlicht
  1470. Engine Editor, irrEdit (http://www.ambiera.com/irredit/). To
  1471. load .irr files again, see ISceneManager::loadScene().
  1472. \param writer XMLWriter with which the scene is saved.
  1473. \param currentPath Path which is used for relative file names.
  1474. Usually the directory of the file written into.
  1475. \param userDataSerializer If you want to save some user data
  1476. for every scene node into the file, implement the
  1477. ISceneUserDataSerializer interface and provide it as parameter
  1478. here. Otherwise, simply specify 0 as this parameter.
  1479. \param node Node which is taken as the top node of the scene.
  1480. This node and all of its descendants are saved into the scene
  1481. file. Pass 0 or the scene manager to save the full scene (which
  1482. is also the default).
  1483. \return True if successful. */
  1484. virtual bool saveScene(io::IXMLWriter* writer, const io::path& currentPath, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* node=0) = 0;
  1485. //! Loads a scene. Note that the current scene is not cleared before.
  1486. /** The scene is usually loaded from an .irr file, an xml based
  1487. format, but other scene formats can be added to the engine via
  1488. ISceneManager::addExternalSceneLoader. .irr files can Be edited
  1489. with the Irrlicht Engine Editor, irrEdit
  1490. (http://www.ambiera.com/irredit/) or saved directly by the engine
  1491. using ISceneManager::saveScene().
  1492. \param filename Name of the file to load from.
  1493. \param userDataSerializer If you want to load user data
  1494. possibily saved in that file for some scene nodes in the file,
  1495. implement the ISceneUserDataSerializer interface and provide it
  1496. as parameter here. Otherwise, simply specify 0 as this
  1497. parameter.
  1498. \param rootNode Node which is taken as the root node of the
  1499. scene. Pass 0 to add the scene directly to the scene manager
  1500. (which is also the default).
  1501. \return True if successful. */
  1502. virtual bool loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0) = 0;
  1503. //! Loads a scene. Note that the current scene is not cleared before.
  1504. /** The scene is usually loaded from an .irr file, an xml based
  1505. format, but other scene formats can be added to the engine via
  1506. ISceneManager::addExternalSceneLoader. .irr files can Be edited
  1507. with the Irrlicht Engine Editor, irrEdit
  1508. (http://www.ambiera.com/irredit/) or saved directly by the engine
  1509. using ISceneManager::saveScene().
  1510. \param file File where the scene is loaded from.
  1511. \param userDataSerializer If you want to load user data
  1512. saved in that file for some scene nodes in the file,
  1513. implement the ISceneUserDataSerializer interface and provide it
  1514. as parameter here. Otherwise, simply specify 0 as this
  1515. parameter.
  1516. \param rootNode Node which is taken as the root node of the
  1517. scene. Pass 0 to add the scene directly to the scene manager
  1518. (which is also the default).
  1519. \return True if successful. */
  1520. virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0, ISceneNode* rootNode=0) = 0;
  1521. //! Get a mesh writer implementation if available
  1522. /** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop()
  1523. for details. */
  1524. virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type) = 0;
  1525. //! Get a skinned mesh, which is not available as header-only code
  1526. /** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop()
  1527. for details. */
  1528. virtual ISkinnedMesh* createSkinnedMesh() = 0;
  1529. //! Sets ambient color of the scene
  1530. virtual void setAmbientLight(const video::SColorf &ambientColor) = 0;
  1531. //! Get ambient color of the scene
  1532. virtual const video::SColorf& getAmbientLight() const = 0;
  1533. //! Register a custom callbacks manager which gets callbacks during scene rendering.
  1534. /** \param[in] lightManager: the new callbacks manager. You may pass 0 to remove the
  1535. current callbacks manager and restore the default behavior. */
  1536. virtual void setLightManager(ILightManager* lightManager) = 0;
  1537. //! Get current render pass.
  1538. virtual E_SCENE_NODE_RENDER_PASS getCurrentRenderPass() const =0;
  1539. //! Set current render pass.
  1540. virtual void setCurrentRenderPass(E_SCENE_NODE_RENDER_PASS nextPass) =0;
  1541. //! Get an instance of a geometry creator.
  1542. /** The geometry creator provides some helper methods to create various types of
  1543. basic geometry. This can be useful for custom scene nodes. */
  1544. virtual const IGeometryCreator* getGeometryCreator(void) const = 0;
  1545. //! Check if node is culled in current view frustum
  1546. /** Please note that depending on the used culling method this
  1547. check can be rather coarse, or slow. A positive result is
  1548. correct, though, i.e. if this method returns true the node is
  1549. positively not visible. The node might still be invisible even
  1550. if this method returns false.
  1551. \param node The scene node which is checked for culling.
  1552. \return True if node is not visible in the current scene, else
  1553. false. */
  1554. virtual bool isCulled(const ISceneNode* node) const =0;
  1555. };
  1556. } // end namespace scene
  1557. } // end namespace irr
  1558. #endif