Commit 28a04fbd authored by cutealien's avatar cutealien

Renamed OctTree to Octree


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3062 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 1a876af3
Changes in 1.7 Changes in 1.7
- Renamed OctTree to Octree
- Allow getting a ConstIterator from a non-const core:list - Allow getting a ConstIterator from a non-const core:list
- Add swap functions to irrMath and to the core classes. - Add swap functions to irrMath and to the core classes.
......
...@@ -1648,7 +1648,7 @@ Even less visible changes have been made in this version. Only the automatic Sol ...@@ -1648,7 +1648,7 @@ Even less visible changes have been made in this version. Only the automatic Sol
Changes for Version 1.6.0 Changes for Version 1.6.0
------------------------- -------------------------
This releases has many changes in method signatures. The most obvious ones are signedness changes from s32 to u32. Since many templates won't accept both types, you need to change the ypes manually in your code. The other major change is from many different types of strings to the new class io::path. These changes should be transparent to the app, unless you need proper overrides in derived classes. This releases has many changes in method signatures. The most obvious ones are signedness changes from s32 to u32. Since many templates won't accept both types, you need to change the types manually in your code. The other major change is from many different types of strings to the new class io::path. These changes should be transparent to the app, unless you need proper overrides in derived classes.
Finally, some deprecated methods have been removed, and some were simply renamed. Just check the API if some methods is not found anymore. Finally, some deprecated methods have been removed, and some were simply renamed. Just check the API if some methods is not found anymore.
IMeshSceneNode.h IMeshSceneNode.h
......
...@@ -6,7 +6,7 @@ controlled camera. ...@@ -6,7 +6,7 @@ controlled camera.
Please note that you should know the basics of the engine before starting this Please note that you should know the basics of the engine before starting this
tutorial. Just take a short look at the first tutorial, if you haven't done tutorial. Just take a short look at the first tutorial, if you haven't done
this yet: http://irrlicht.sourceforge.net/tut001.html this yet: http://irrlicht.sourceforge.net/tut001.html
Lets start like the HelloWorld example: We include the irrlicht header files Lets start like the HelloWorld example: We include the irrlicht header files
and an additional file to be able to ask the user for a driver type using the and an additional file to be able to ask the user for a driver type using the
...@@ -70,7 +70,7 @@ int main() ...@@ -70,7 +70,7 @@ int main()
case 'e': driverType = video::EDT_BURNINGSVIDEO;break; case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
case 'f': driverType = video::EDT_NULL; break; case 'f': driverType = video::EDT_NULL; break;
default: return 1; default: return 1;
} }
// create device and exit if creation failed // create device and exit if creation failed
...@@ -104,24 +104,24 @@ int main() ...@@ -104,24 +104,24 @@ int main()
really animated, they are only a huge chunk of static geometry with really animated, they are only a huge chunk of static geometry with
some materials attached. Hence the IAnimatedMesh consists of only one some materials attached. Hence the IAnimatedMesh consists of only one
frame, so we get the "first frame" of the "animation", which is our frame, so we get the "first frame" of the "animation", which is our
quake level and create an OctTree scene node with it, using quake level and create an Octree scene node with it, using
irr::scene::ISceneManager::addOctTreeSceneNode(). irr::scene::ISceneManager::addOctreeSceneNode().
The OctTree optimizes the scene a little bit, trying to draw only geometry The Octree optimizes the scene a little bit, trying to draw only geometry
which is currently visible. An alternative to the OctTree would be a which is currently visible. An alternative to the Octree would be a
irr::scene::IMeshSceneNode, which would always draw the complete irr::scene::IMeshSceneNode, which would always draw the complete
geometry of the mesh, without optimization. Try it: Use geometry of the mesh, without optimization. Try it: Use
irr::scene::ISceneManager::addMeshSceneNode() instead of irr::scene::ISceneManager::addMeshSceneNode() instead of
addOctTreeSceneNode() and compare the primitives drawn by the video addOctreeSceneNode() and compare the primitives drawn by the video
driver. (There is a irr::video::IVideoDriver::getPrimitiveCountDrawn() driver. (There is a irr::video::IVideoDriver::getPrimitiveCountDrawn()
method in the irr::video::IVideoDriver class). Note that this method in the irr::video::IVideoDriver class). Note that this
optimization with the OctTree is only useful when drawing huge meshes optimization with the Octree is only useful when drawing huge meshes
consisting of lots of geometry. consisting of lots of geometry.
*/ */
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp"); scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0; scene::ISceneNode* node = 0;
if (mesh) if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -1, 1024); node = smgr->addOctreeSceneNode(mesh->getMesh(0), 0, -1, 1024);
// node = smgr->addMeshSceneNode(mesh->getMesh(0)); // node = smgr->addMeshSceneNode(mesh->getMesh(0));
/* /*
......
...@@ -78,7 +78,7 @@ int main() ...@@ -78,7 +78,7 @@ int main()
// The Quake mesh is pickable, but doesn't get highlighted. // The Quake mesh is pickable, but doesn't get highlighted.
if (q3levelmesh) if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0), 0, IDFlag_IsPickable); q3node = smgr->addOctreeSceneNode(q3levelmesh->getMesh(0), 0, IDFlag_IsPickable);
/* /*
So far so good, we've loaded the quake 3 level like in tutorial 2. Now, So far so good, we've loaded the quake 3 level like in tutorial 2. Now,
...@@ -87,7 +87,7 @@ int main() ...@@ -87,7 +87,7 @@ int main()
nodes for doing different things with them, for example collision nodes for doing different things with them, for example collision
detection. There are different triangle selectors, and all can be detection. There are different triangle selectors, and all can be
created with the ISceneManager. In this example, we create an created with the ISceneManager. In this example, we create an
OctTreeTriangleSelector, which optimizes the triangle output a little OctreeTriangleSelector, which optimizes the triangle output a little
bit by reducing it like an octree. This is very useful for huge meshes bit by reducing it like an octree. This is very useful for huge meshes
like quake 3 levels. After we created the triangle selector, we attach like quake 3 levels. After we created the triangle selector, we attach
it to the q3node. This is not necessary, but in this way, we do not it to the q3node. This is not necessary, but in this way, we do not
...@@ -101,7 +101,7 @@ int main() ...@@ -101,7 +101,7 @@ int main()
{ {
q3node->setPosition(core::vector3df(-1350,-130,-1400)); q3node->setPosition(core::vector3df(-1350,-130,-1400));
selector = smgr->createOctTreeTriangleSelector( selector = smgr->createOctreeTriangleSelector(
q3node->getMesh(), q3node, 128); q3node->getMesh(), q3node, 128);
q3node->setTriangleSelector(selector); q3node->setTriangleSelector(selector);
// We're not done with this selector yet, so don't drop it. // We're not done with this selector yet, so don't drop it.
......
...@@ -229,7 +229,7 @@ void loadModel(const c8* fn) ...@@ -229,7 +229,7 @@ void loadModel(const c8* fn)
// set default material properties // set default material properties
if (Octree) if (Octree)
Model = Device->getSceneManager()->addOctTreeSceneNode(m->getMesh(0)); Model = Device->getSceneManager()->addOctreeSceneNode(m->getMesh(0));
else else
{ {
scene::IAnimatedMeshSceneNode* animModel = Device->getSceneManager()->addAnimatedMeshSceneNode(m); scene::IAnimatedMeshSceneNode* animModel = Device->getSceneManager()->addAnimatedMeshSceneNode(m);
......
...@@ -115,8 +115,8 @@ int main(int argc, char** argv) ...@@ -115,8 +115,8 @@ int main(int argc, char** argv)
selector = smgr->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node); selector = smgr->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node);
break; break;
case scene::ESNT_OCT_TREE: case scene::ESNT_OCTREE:
selector = smgr->createOctTreeTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node); selector = smgr->createOctreeTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
break; break;
default: default:
......
...@@ -146,7 +146,7 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -146,7 +146,7 @@ int IRRCALLCONV main(int argc, char* argv[])
case 'e': driverType = video::EDT_BURNINGSVIDEO;break; case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
case 'f': driverType = video::EDT_NULL; break; case 'f': driverType = video::EDT_NULL; break;
default: return 1; default: return 1;
} }
// create device and exit if creation failed // create device and exit if creation failed
const core::dimension2du videoDim ( 800,600 ); const core::dimension2du videoDim ( 800,600 );
...@@ -200,12 +200,12 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -200,12 +200,12 @@ int IRRCALLCONV main(int argc, char* argv[])
they are only a huge chunk of static geometry with some materials they are only a huge chunk of static geometry with some materials
attached. Hence the IAnimated mesh consists of only one frame, attached. Hence the IAnimated mesh consists of only one frame,
so we get the "first frame" of the "animation", which is our quake level so we get the "first frame" of the "animation", which is our quake level
and create an OctTree scene node with it, using addOctTreeSceneNode(). and create an Octree scene node with it, using addOctreeSceneNode().
The OctTree optimizes the scene a little bit, trying to draw only geometry The Octree optimizes the scene a little bit, trying to draw only geometry
which is currently visible. An alternative to the OctTree would be a which is currently visible. An alternative to the Octree would be a
AnimatedMeshSceneNode, which would draw always the complete geometry of AnimatedMeshSceneNode, which would draw always the complete geometry of
the mesh, without optimization. Try it out: Write addAnimatedMeshSceneNode the mesh, without optimization. Try it out: Write addAnimatedMeshSceneNode
instead of addOctTreeSceneNode and compare the primitives drawed by the instead of addOctreeSceneNode and compare the primitives drawed by the
video driver. (There is a getPrimitiveCountDrawed() method in the video driver. (There is a getPrimitiveCountDrawed() method in the
IVideoDriver class). Note that this optimization with the Octree is only IVideoDriver class). Note that this optimization with the Octree is only
useful when drawing huge meshes consisting of lots of geometry. useful when drawing huge meshes consisting of lots of geometry.
...@@ -222,7 +222,7 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -222,7 +222,7 @@ int IRRCALLCONV main(int argc, char* argv[])
{ {
scene::IMesh *geometry = mesh->getMesh(quake3::E_Q3_MESH_GEOMETRY); scene::IMesh *geometry = mesh->getMesh(quake3::E_Q3_MESH_GEOMETRY);
// node = smgr->addMeshSceneNode ( geometry ); // node = smgr->addMeshSceneNode ( geometry );
node = smgr->addOctTreeSceneNode(geometry, 0, -1, 1024); node = smgr->addOctreeSceneNode(geometry, 0, -1, 1024);
} }
// create an event receiver for making screenshots // create an event receiver for making screenshots
...@@ -305,7 +305,7 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -305,7 +305,7 @@ int IRRCALLCONV main(int argc, char* argv[])
we can ask the Quake3 Loader for all entities with class_name we can ask the Quake3 Loader for all entities with class_name
"info_player_deathmatch" "info_player_deathmatch"
we choose a random launch we choose a random launch
*/ */
if ( mesh ) if ( mesh )
{ {
...@@ -427,7 +427,7 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -427,7 +427,7 @@ int IRRCALLCONV main(int argc, char* argv[])
In the end, delete the Irrlicht device. In the end, delete the Irrlicht device.
*/ */
device->drop(); device->drop();
return 0; return 0;
} }
......
...@@ -129,7 +129,7 @@ int main() ...@@ -129,7 +129,7 @@ int main()
IAnimatedMesh *map = smgr->getMesh("20kdm2.bsp"); IAnimatedMesh *map = smgr->getMesh("20kdm2.bsp");
if (map) if (map)
{ {
ISceneNode *map_node = smgr->addOctTreeSceneNode(map->getMesh(0)); ISceneNode *map_node = smgr->addOctreeSceneNode(map->getMesh(0));
//Set position //Set position
map_node->setPosition(vector3df(-850,-220,-850)); map_node->setPosition(vector3df(-850,-220,-850));
} }
......
...@@ -1073,11 +1073,11 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision ) ...@@ -1073,11 +1073,11 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision )
s32 minimalNodes = 2048; s32 minimalNodes = 2048;
MapParent = smgr->addMeshSceneNode( geometry ); MapParent = smgr->addMeshSceneNode( geometry );
//MapParent = smgr->addOctTreeSceneNode(geometry, 0, -1, minimalNodes); //MapParent = smgr->addOctreeSceneNode(geometry, 0, -1, minimalNodes);
MapParent->setName ( mapName ); MapParent->setName ( mapName );
if ( Meta ) if ( Meta )
{ {
selector = smgr->createOctTreeTriangleSelector( geometry,MapParent, minimalNodes); selector = smgr->createOctreeTriangleSelector( geometry,MapParent, minimalNodes);
//selector = smgr->createTriangleSelector ( geometry, MapParent ); //selector = smgr->createTriangleSelector ( geometry, MapParent );
Meta->addTriangleSelector( selector); Meta->addTriangleSelector( selector);
selector->drop (); selector->drop ();
...@@ -1142,7 +1142,7 @@ void CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNod ...@@ -1142,7 +1142,7 @@ void CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNod
case ESNT_CAMERA: imageIndex = 1; break; case ESNT_CAMERA: imageIndex = 1; break;
case ESNT_EMPTY: imageIndex = 2; break; case ESNT_EMPTY: imageIndex = 2; break;
case ESNT_MESH: imageIndex = 3; break; case ESNT_MESH: imageIndex = 3; break;
case ESNT_OCT_TREE: imageIndex = 3; break; case ESNT_OCTREE: imageIndex = 3; break;
case ESNT_ANIMATED_MESH: imageIndex = 4; break; case ESNT_ANIMATED_MESH: imageIndex = 4; break;
case ESNT_SKY_BOX: imageIndex = 5; break; case ESNT_SKY_BOX: imageIndex = 5; break;
case ESNT_BILLBOARD: imageIndex = 6; break; case ESNT_BILLBOARD: imageIndex = 6; break;
......
/*! /*!
Model Factory. Model Factory.
create the additional scenenodes for ( bullets, health... ) create the additional scenenodes for ( bullets, health... )
Defines the Entities for Quake3 Defines the Entities for Quake3
*/ */
...@@ -29,8 +29,8 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -29,8 +29,8 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_BOUNCE | SPECIAL_SFX_ROTATE_1 SPECIAL_SFX_BOUNCE | SPECIAL_SFX_ROTATE_1
}, },
{ "item_health_large", { "item_health_large",
"models/powerups/health/large_cross.md3", "models/powerups/health/large_cross.md3",
"models/powerups/health/large_sphere.md3", "models/powerups/health/large_sphere.md3",
"sound/items/l_health.wav", "sound/items/l_health.wav",
"icons/iconh_red", "icons/iconh_red",
"50 Health", "50 Health",
...@@ -41,8 +41,8 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -41,8 +41,8 @@ static const SItemElement Quake3ItemElement [] = {
}, },
{ {
"item_health_mega", "item_health_mega",
"models/powerups/health/mega_cross.md3", "models/powerups/health/mega_cross.md3",
"models/powerups/health/mega_sphere.md3", "models/powerups/health/mega_sphere.md3",
"sound/items/m_health.wav", "sound/items/m_health.wav",
"icons/iconh_mega", "icons/iconh_mega",
"Mega Health", "Mega Health",
...@@ -53,8 +53,8 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -53,8 +53,8 @@ static const SItemElement Quake3ItemElement [] = {
}, },
{ {
"item_health_small", "item_health_small",
"models/powerups/health/small_cross.md3", "models/powerups/health/small_cross.md3",
"models/powerups/health/small_sphere.md3", "models/powerups/health/small_sphere.md3",
"sound/items/s_health.wav", "sound/items/s_health.wav",
"icons/iconh_green", "icons/iconh_green",
"5 Health", "5 Health",
...@@ -64,7 +64,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -64,7 +64,7 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_BOUNCE | SPECIAL_SFX_ROTATE_1 SPECIAL_SFX_BOUNCE | SPECIAL_SFX_ROTATE_1
}, },
{ "ammo_bullets", { "ammo_bullets",
"models/powerups/ammo/machinegunam.md3", "models/powerups/ammo/machinegunam.md3",
"", "",
"sound/misc/am_pkup.wav", "sound/misc/am_pkup.wav",
"icons/icona_machinegun", "icons/icona_machinegun",
...@@ -99,7 +99,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -99,7 +99,7 @@ static const SItemElement Quake3ItemElement [] = {
}, },
{ {
"ammo_shells", "ammo_shells",
"models/powerups/ammo/shotgunam.md3", "models/powerups/ammo/shotgunam.md3",
"", "",
"sound/misc/am_pkup.wav", "sound/misc/am_pkup.wav",
"icons/icona_shotgun", "icons/icona_shotgun",
...@@ -111,7 +111,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -111,7 +111,7 @@ static const SItemElement Quake3ItemElement [] = {
}, },
{ {
"ammo_slugs", "ammo_slugs",
"models/powerups/ammo/railgunam.md3", "models/powerups/ammo/railgunam.md3",
"", "",
"sound/misc/am_pkup.wav", "sound/misc/am_pkup.wav",
"icons/icona_railgun", "icons/icona_railgun",
...@@ -122,7 +122,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -122,7 +122,7 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"item_armor_body", "item_armor_body",
"models/powerups/armor/armor_red.md3", "models/powerups/armor/armor_red.md3",
"", "",
"sound/misc/ar2_pkup.wav", "sound/misc/ar2_pkup.wav",
...@@ -134,7 +134,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -134,7 +134,7 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"item_armor_combat", "item_armor_combat",
"models/powerups/armor/armor_yel.md3", "models/powerups/armor/armor_yel.md3",
"", "",
"sound/misc/ar2_pkup.wav", "sound/misc/ar2_pkup.wav",
...@@ -146,7 +146,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -146,7 +146,7 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"item_armor_shard", "item_armor_shard",
"models/powerups/armor/shard.md3", "models/powerups/armor/shard.md3",
"", "",
"sound/misc/ar1_pkup.wav", "sound/misc/ar1_pkup.wav",
...@@ -158,7 +158,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -158,7 +158,7 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"weapon_gauntlet", "weapon_gauntlet",
"models/weapons2/gauntlet/gauntlet.md3", "models/weapons2/gauntlet/gauntlet.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
...@@ -170,7 +170,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -170,7 +170,7 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"weapon_shotgun", "weapon_shotgun",
"models/weapons2/shotgun/shotgun.md3", "models/weapons2/shotgun/shotgun.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
...@@ -182,8 +182,8 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -182,8 +182,8 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"weapon_machinegun", "weapon_machinegun",
"models/weapons2/machinegun/machinegun.md3", "models/weapons2/machinegun/machinegun.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
"icons/iconw_machinegun", "icons/iconw_machinegun",
...@@ -195,7 +195,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -195,7 +195,7 @@ static const SItemElement Quake3ItemElement [] = {
}, },
{ {
"weapon_grenadelauncher", "weapon_grenadelauncher",
"models/weapons2/grenadel/grenadel.md3", "models/weapons2/grenadel/grenadel.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
"icons/iconw_grenade", "icons/iconw_grenade",
...@@ -207,7 +207,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -207,7 +207,7 @@ static const SItemElement Quake3ItemElement [] = {
}, },
{ {
"weapon_rocketlauncher", "weapon_rocketlauncher",
"models/weapons2/rocketl/rocketl.md3", "models/weapons2/rocketl/rocketl.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
"icons/iconw_rocket", "icons/iconw_rocket",
...@@ -218,8 +218,8 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -218,8 +218,8 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"weapon_lightning", "weapon_lightning",
"models/weapons2/lightning/lightning.md3", "models/weapons2/lightning/lightning.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
"icons/iconw_lightning", "icons/iconw_lightning",
...@@ -230,8 +230,8 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -230,8 +230,8 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"weapon_railgun", "weapon_railgun",
"models/weapons2/railgun/railgun.md3", "models/weapons2/railgun/railgun.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
"icons/iconw_railgun", "icons/iconw_railgun",
...@@ -242,8 +242,8 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -242,8 +242,8 @@ static const SItemElement Quake3ItemElement [] = {
SPECIAL_SFX_ROTATE SPECIAL_SFX_ROTATE
}, },
{ {
"weapon_plasmagun", "weapon_plasmagun",
"models/weapons2/plasma/plasma.md3", "models/weapons2/plasma/plasma.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
"icons/iconw_plasma", "icons/iconw_plasma",
...@@ -255,7 +255,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -255,7 +255,7 @@ static const SItemElement Quake3ItemElement [] = {
}, },
{ {
"weapon_bfg", "weapon_bfg",
"models/weapons2/bfg/bfg.md3", "models/weapons2/bfg/bfg.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
"icons/iconw_bfg", "icons/iconw_bfg",
...@@ -267,7 +267,7 @@ static const SItemElement Quake3ItemElement [] = { ...@@ -267,7 +267,7 @@ static const SItemElement Quake3ItemElement [] = {
}, },
{ {
"weapon_grapplinghook", "weapon_grapplinghook",
"models/weapons2/grapple/grapple.md3", "models/weapons2/grapple/grapple.md3",
"", "",
"sound/misc/w_pkup.wav", "sound/misc/w_pkup.wav",
"icons/iconw_grapple", "icons/iconw_grapple",
...@@ -304,8 +304,8 @@ const SItemElement * getItemElement ( const stringc& key ) ...@@ -304,8 +304,8 @@ const SItemElement * getItemElement ( const stringc& key )
Takes the mesh buffers and creates scenenodes for their associated shaders Takes the mesh buffers and creates scenenodes for their associated shaders
*/ */
void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam, void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam,
IrrlichtDevice *device, IrrlichtDevice *device,
IQ3LevelMesh* mesh, IQ3LevelMesh* mesh,
eQ3MeshIndex meshIndex, eQ3MeshIndex meshIndex,
ISceneNode *parent, ISceneNode *parent,
IMetaTriangleSelector *meta, IMetaTriangleSelector *meta,
...@@ -463,7 +463,7 @@ void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam, ...@@ -463,7 +463,7 @@ void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam,
m = node->getMesh(); m = node->getMesh();
} }
//selector = smgr->createOctTreeTriangleSelector ( m, 0, 128 ); //selector = smgr->createOctreeTriangleSelector ( m, 0, 128 );
selector = smgr->createTriangleSelector ( m, 0 ); selector = smgr->createTriangleSelector ( m, 0 );
meta->addTriangleSelector ( selector ); meta->addTriangleSelector ( selector );
selector->drop (); selector->drop ();
...@@ -479,7 +479,7 @@ void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam, ...@@ -479,7 +479,7 @@ void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam,
#if 0 #if 0
if ( meta ) if ( meta )
{ {
selector = smgr->createOctTreeTriangleSelector ( additional_mesh, 0 ); selector = smgr->createOctreeTriangleSelector ( additional_mesh, 0 );
meta->addTriangleSelector ( selector ); meta->addTriangleSelector ( selector );
selector->drop (); selector->drop ();
} }
...@@ -488,8 +488,8 @@ void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam, ...@@ -488,8 +488,8 @@ void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam,
if ( loadParam.verbose > 0 ) if ( loadParam.verbose > 0 )
{ {
loadParam.endTime = device->getTimer()->getRealTime (); loadParam.endTime = device->getTimer()->getRealTime ();
snprintf(buf, 128, "q3shaderfactory needed %04d ms to create %d shader nodes", snprintf(buf, 128, "q3shaderfactory needed %04d ms to create %d shader nodes",
loadParam.endTime - loadParam.startTime, loadParam.endTime - loadParam.startTime,
sceneNodeID sceneNodeID
); );
device->getLogger()->log(buf, ELL_INFORMATION); device->getLogger()->log(buf, ELL_INFORMATION);
...@@ -502,8 +502,8 @@ void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam, ...@@ -502,8 +502,8 @@ void Q3ShaderFactory ( Q3LevelLoadParameter &loadParam,
create Items from Entity create Items from Entity
*/ */
void Q3ModelFactory ( Q3LevelLoadParameter &loadParam, void Q3ModelFactory ( Q3LevelLoadParameter &loadParam,
IrrlichtDevice *device, IrrlichtDevice *device,
IQ3LevelMesh* masterMesh, IQ3LevelMesh* masterMesh,
ISceneNode *parent, ISceneNode *parent,
bool showShaderName bool showShaderName
) )
...@@ -620,7 +620,7 @@ void Q3ModelFactory ( Q3LevelLoadParameter &loadParam, ...@@ -620,7 +620,7 @@ void Q3ModelFactory ( Q3LevelLoadParameter &loadParam,
if ( itemElement->special & SPECIAL_SFX_BOUNCE ) if ( itemElement->special & SPECIAL_SFX_BOUNCE )
{ {
//anim = smgr->createFlyStraightAnimator ( //anim = smgr->createFlyStraightAnimator (
// p, p + vector3df ( 0.f, 60.f, 0.f ), 1000, true, true ); // p, p + vector3df ( 0.f, 60.f, 0.f ), 1000, true, true );
anim = smgr->createFlyCircleAnimator ( anim = smgr->createFlyCircleAnimator (
p + vector3df( 0.f, 20.f, 0.f ), p + vector3df( 0.f, 20.f, 0.f ),
...@@ -745,7 +745,7 @@ vector3df getGravity ( const c8 * surface ) ...@@ -745,7 +745,7 @@ vector3df getGravity ( const c8 * surface )
if ( 0 == strcmp ( surface, "moon" ) ) return vector3df ( 0.f, -6.f / 100.f, 0.f ); if ( 0 == strcmp ( surface, "moon" ) ) return vector3df ( 0.f, -6.f / 100.f, 0.f );
if ( 0 == strcmp ( surface, "water" ) ) return vector3df ( 0.1f / 100.f, -2.f / 100.f, 0.f ); if ( 0 == strcmp ( surface, "water" ) ) return vector3df ( 0.1f / 100.f, -2.f / 100.f, 0.f );
if ( 0 == strcmp ( surface, "ice" ) ) return vector3df ( 0.2f / 100.f, -9.f / 100.f, 0.3f / 100.f ); if ( 0 == strcmp ( surface, "ice" ) ) return vector3df ( 0.2f / 100.f, -9.f / 100.f, 0.3f / 100.f );
return vector3df ( 0.f, 0.f, 0.f ); return vector3df ( 0.f, 0.f, 0.f );
} }
......
...@@ -369,7 +369,7 @@ void CDemo::loadSceneData() ...@@ -369,7 +369,7 @@ void CDemo::loadSceneData()
sm->getMeshManipulator()->transformMesh ( quakeLevelMesh->getMesh(i), m ); sm->getMeshManipulator()->transformMesh ( quakeLevelMesh->getMesh(i), m );
} }
quakeLevelNode = sm->addOctTreeSceneNode( quakeLevelNode = sm->addOctreeSceneNode(
quakeLevelMesh->getMesh( scene::quake3::E_Q3_MESH_GEOMETRY) quakeLevelMesh->getMesh( scene::quake3::E_Q3_MESH_GEOMETRY)
); );
if (quakeLevelNode) if (quakeLevelNode)
...@@ -378,7 +378,7 @@ void CDemo::loadSceneData() ...@@ -378,7 +378,7 @@ void CDemo::loadSceneData()
quakeLevelNode->setVisible(true); quakeLevelNode->setVisible(true);
// create map triangle selector // create map triangle selector
mapSelector = sm->createOctTreeTriangleSelector(quakeLevelMesh->getMesh(0), mapSelector = sm->createOctreeTriangleSelector(quakeLevelMesh->getMesh(0),
quakeLevelNode, 128); quakeLevelNode, 128);
// if not using shader and no gamma it's better to use more lighting, because // if not using shader and no gamma it's better to use more lighting, because
......
...@@ -47,22 +47,22 @@ int main() ...@@ -47,22 +47,22 @@ int main()
IrrlichtDevice *device = IrrlichtDevice *device =
createDevice(driverType, core::dimension2d<s32>(640, 480), 16, false); createDevice(driverType, core::dimension2d<s32>(640, 480), 16, false);
if (device == 0) if (device == 0)
return 1; // could not create selected driver. return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3"); device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp"); scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* q3node = 0; scene::ISceneNode* q3node = 0;
if (q3levelmesh) if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0)); q3node = smgr->addOctreeSceneNode(q3levelmesh->getMesh(0));
/* /*
So far so good, we've loaded the quake 3 level like in tutorial 2. Now, here So far so good, we've loaded the quake 3 level like in tutorial 2. Now, here
...@@ -70,7 +70,7 @@ int main() ...@@ -70,7 +70,7 @@ int main()
is a class which can fetch the triangles from scene nodes for doing different is a class which can fetch the triangles from scene nodes for doing different
things with them, for example collision detection. There are different triangle things with them, for example collision detection. There are different triangle
selectors, and all can be created with the ISceneManager. In this example, selectors, and all can be created with the ISceneManager. In this example,
we create an OctTreeTriangleSelector, which optimizes the triangle output a l we create an OctreeTriangleSelector, which optimizes the triangle output a l
little bit by reducing it like an octree. This is very useful for huge meshes little bit by reducing it like an octree. This is very useful for huge meshes
like quake 3 levels. like quake 3 levels.
Afte we created the triangle selector, we attach it to the q3node. This is not Afte we created the triangle selector, we attach it to the q3node. This is not
...@@ -79,12 +79,12 @@ int main() ...@@ -79,12 +79,12 @@ int main()
*/ */
scene::ITriangleSelector* selector = 0; scene::ITriangleSelector* selector = 0;
if (q3node) if (q3node)
{ {
q3node->setPosition(core::vector3df(-1350,-130,-1400)); q3node->setPosition(core::vector3df(-1350,-130,-1400));
selector = smgr->createOctTreeTriangleSelector( selector = smgr->createOctreeTriangleSelector(
q3levelmesh->getMesh(0), q3node, 128); q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector); q3node->setTriangleSelector(selector);
selector->drop(); selector->drop();
...@@ -122,16 +122,16 @@ int main() ...@@ -122,16 +122,16 @@ int main()
are used to have our eyes on top of the body, with which we collide are used to have our eyes on top of the body, with which we collide
with our world, not in the middle of it. So we place the scene node 50 with our world, not in the middle of it. So we place the scene node 50
units over the center of the ellipsoid with this parameter. And that's units over the center of the ellipsoid with this parameter. And that's
it, collision detection works now. it, collision detection works now.
*/ */
scene::ICameraSceneNode* camera = scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0, 100.0f, 300.0f, -1, 0, 0, true); smgr->addCameraSceneNodeFPS(0, 100.0f, 300.0f, -1, 0, 0, true);
camera->setPosition(core::vector3df(-100,50,-150)); camera->setPosition(core::vector3df(-100,50,-150));
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator( scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30), selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-3,0), core::vector3df(0,-3,0),
core::vector3df(0,50,0)); core::vector3df(0,50,0));
camera->addAnimator(anim); camera->addAnimator(anim);
anim->drop(); anim->drop();
...@@ -139,7 +139,7 @@ int main() ...@@ -139,7 +139,7 @@ int main()
/* /*
Because collision detection is no big deal in irrlicht, I'll describe how to Because collision detection is no big deal in irrlicht, I'll describe how to
do two different types of picking in the next section. But before this, do two different types of picking in the next section. But before this,
I'll prepare the scene a little. I need three animated characters which we I'll prepare the scene a little. I need three animated characters which we
could pick later, a dynamic light for lighting them, could pick later, a dynamic light for lighting them,
a billboard for drawing where we found an intersection, and, yes, I need to a billboard for drawing where we found an intersection, and, yes, I need to
get rid of this mouse cursor. :) get rid of this mouse cursor. :)
...@@ -197,7 +197,7 @@ int main() ...@@ -197,7 +197,7 @@ int main()
/* /*
For not making it to complicated, I'm doing picking inside the drawing loop. For not making it to complicated, I'm doing picking inside the drawing loop.
We take two pointers for storing the current and the last selected scene node and We take two pointers for storing the current and the last selected scene node and
start the loop. start the loop.
*/ */
...@@ -205,7 +205,7 @@ int main() ...@@ -205,7 +205,7 @@ int main()
scene::ISceneNode* selectedSceneNode = 0; scene::ISceneNode* selectedSceneNode = 0;
scene::ISceneNode* lastSelectedSceneNode = 0; scene::ISceneNode* lastSelectedSceneNode = 0;
int lastFPS = -1; int lastFPS = -1;
while(device->run()) while(device->run())
...@@ -239,7 +239,7 @@ int main() ...@@ -239,7 +239,7 @@ int main()
line, selector, intersection, tri)) line, selector, intersection, tri))
{ {
bill->setPosition(intersection); bill->setPosition(intersection);
driver->setTransform(video::ETS_WORLD, core::matrix4()); driver->setTransform(video::ETS_WORLD, core::matrix4());
driver->setMaterial(material); driver->setMaterial(material);
driver->draw3DTriangle(tri, video::SColor(0,255,0,0)); driver->draw3DTriangle(tri, video::SColor(0,255,0,0));
...@@ -251,7 +251,7 @@ int main() ...@@ -251,7 +251,7 @@ int main()
based on bouding boxes. Every scene node has got a bounding box, and because of based on bouding boxes. Every scene node has got a bounding box, and because of
that, it's very fast for example to get the scene node which the camera looks that, it's very fast for example to get the scene node which the camera looks
at. Again, we ask the collision manager for this, and if we've got a scene node, at. Again, we ask the collision manager for this, and if we've got a scene node,
we highlight it by disabling Lighting in its material, if it is not the we highlight it by disabling Lighting in its material, if it is not the
billboard or the quake 3 level. billboard or the quake 3 level.
*/ */
...@@ -292,7 +292,7 @@ int main() ...@@ -292,7 +292,7 @@ int main()
} }
device->drop(); device->drop();
return 0; return 0;
} }
...@@ -42,8 +42,8 @@ namespace scene ...@@ -42,8 +42,8 @@ namespace scene
//! Shadow Volume Scene Node //! Shadow Volume Scene Node
ESNT_SHADOW_VOLUME = MAKE_IRR_ID('s','h','d','w'), ESNT_SHADOW_VOLUME = MAKE_IRR_ID('s','h','d','w'),
//! OctTree Scene Node //! Octree Scene Node
ESNT_OCT_TREE = MAKE_IRR_ID('o','c','t','t'), ESNT_OCTREE = MAKE_IRR_ID('o','c','t','r'),
//! Mesh Scene Node //! Mesh Scene Node
ESNT_MESH = MAKE_IRR_ID('m','e','s','h'), ESNT_MESH = MAKE_IRR_ID('m','e','s','h'),
......
...@@ -30,7 +30,7 @@ namespace scene ...@@ -30,7 +30,7 @@ namespace scene
\param selector: TriangleSelector containing the triangles. It \param selector: TriangleSelector containing the triangles. It
can be created for example using can be created for example using
ISceneManager::createTriangleSelector() or ISceneManager::createTriangleSelector() or
ISceneManager::createTriangleOctTreeSelector(). ISceneManager::createTriangleOctreeSelector().
\param outCollisionPoint: If a collision is detected, this will \param outCollisionPoint: If a collision is detected, this will
contain the position of the nearest collision to the line-start. contain the position of the nearest collision to the line-start.
\param outTriangle: If a collision is detected, this will \param outTriangle: If a collision is detected, this will
...@@ -51,7 +51,7 @@ namespace scene ...@@ -51,7 +51,7 @@ namespace scene
\param selector: TriangleSelector containing the triangles of \param selector: TriangleSelector containing the triangles of
the world. It can be created for example using the world. It can be created for example using
ISceneManager::createTriangleSelector() or ISceneManager::createTriangleSelector() or
ISceneManager::createTriangleOctTreeSelector(). ISceneManager::createTriangleOctreeSelector().
\param ellipsoidPosition: Position of the ellipsoid. \param ellipsoidPosition: Position of the ellipsoid.
\param ellipsoidRadius: Radius of the ellipsoid. \param ellipsoidRadius: Radius of the ellipsoid.
\param ellipsoidDirectionAndSpeed: Direction and speed of the \param ellipsoidDirectionAndSpeed: Direction and speed of the
......
...@@ -132,7 +132,7 @@ namespace scene ...@@ -132,7 +132,7 @@ namespace scene
//! The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. //! The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff.
/** All Scene nodes can be created only here. There is a always growing /** All Scene nodes can be created only here. There is a always growing
list of scene nodes for lots of purposes: Indoor rendering scene nodes list of scene nodes for lots of purposes: Indoor rendering scene nodes
like the Octree (addOctTreeSceneNode()) or the terrain renderer like the Octree (addOctreeSceneNode()) or the terrain renderer
(addTerrainSceneNode()), different Camera scene nodes (addTerrainSceneNode()), different Camera scene nodes
(addCameraSceneNode(), addCameraSceneNodeMaya()), scene nodes for Light (addCameraSceneNode(), addCameraSceneNodeMaya()), scene nodes for Light
(addLightSceneNode()), Billboards (addBillboardSceneNode()) and so on. (addLightSceneNode()), Billboards (addBillboardSceneNode()) and so on.
...@@ -493,36 +493,36 @@ namespace scene ...@@ -493,36 +493,36 @@ namespace scene
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0;
//! Adds a scene node for rendering using a octtree to the scene graph. //! Adds a scene node for rendering using a octree to the scene graph.
/** This a good method for rendering /** This a good method for rendering
scenes with lots of geometry. The Octree is built on the fly from the mesh. scenes with lots of geometry. The Octree is built on the fly from the mesh.
\param mesh: The mesh containing all geometry from which the octtree will be build. \param mesh: The mesh containing all geometry from which the octree will be build.
If this animated mesh has more than one frames in it, the first frame is taken. If this animated mesh has more than one frames in it, the first frame is taken.
\param parent: Parent node of the octtree node. \param parent: Parent node of the octree node.
\param id: id of the node. This id can be used to identify the node. \param id: id of the node. This id can be used to identify the node.
\param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node.
If a node gets less polys than this value it will not be split into If a node gets less polys than this value it will not be split into
smaller nodes. smaller nodes.
\param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
\return Pointer to the OctTree if successful, otherwise 0. \return Pointer to the Octree if successful, otherwise 0.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IMeshSceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, virtual IMeshSceneNode* addOctreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false) = 0; s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false) = 0;
//! Adds a scene node for rendering using a octtree to the scene graph. //! Adds a scene node for rendering using a octree to the scene graph.
/** This a good method for rendering scenes with lots of /** This a good method for rendering scenes with lots of
geometry. The Octree is built on the fly from the mesh, much geometry. The Octree is built on the fly from the mesh, much
faster then a bsp tree. faster then a bsp tree.
\param mesh: The mesh containing all geometry from which the octtree will be build. \param mesh: The mesh containing all geometry from which the octree will be build.
\param parent: Parent node of the octtree node. \param parent: Parent node of the octree node.
\param id: id of the node. This id can be used to identify the node. \param id: id of the node. This id can be used to identify the node.
\param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node.
If a node gets less polys than this value it will not be split into If a node gets less polys than this value it will not be split into
smaller nodes. smaller nodes.
\param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed.
\return Pointer to the octtree if successful, otherwise 0. \return Pointer to the octree if successful, otherwise 0.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual IMeshSceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, virtual IMeshSceneNode* addOctreeSceneNode(IMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0;
//! Adds a camera scene node to the scene graph and sets it as active camera. //! Adds a camera scene node to the scene graph and sets it as active camera.
...@@ -1194,7 +1194,7 @@ namespace scene ...@@ -1194,7 +1194,7 @@ namespace scene
/** Triangle selectors /** Triangle selectors
can be used for doing collision detection. Don't use this selector can be used for doing collision detection. Don't use this selector
for a huge amount of triangles like in Quake3 maps. for a huge amount of triangles like in Quake3 maps.
Instead, use for example ISceneManager::createOctTreeTriangleSelector(). Instead, use for example ISceneManager::createOctreeTriangleSelector().
Please note that the created triangle selector is not automaticly attached Please note that the created triangle selector is not automaticly attached
to the scene node. You will have to call ISceneNode::setTriangleSelector() to the scene node. You will have to call ISceneNode::setTriangleSelector()
for this. To create and attach a triangle selector is done like this: for this. To create and attach a triangle selector is done like this:
...@@ -1231,15 +1231,15 @@ namespace scene ...@@ -1231,15 +1231,15 @@ namespace scene
See IReferenceCounted::drop() for more information. */ See IReferenceCounted::drop() for more information. */
virtual ITriangleSelector* createTriangleSelectorFromBoundingBox(ISceneNode* node) = 0; virtual ITriangleSelector* createTriangleSelectorFromBoundingBox(ISceneNode* node) = 0;
//! Creates a Triangle Selector, optimized by an octtree. //! Creates a Triangle Selector, optimized by an octree.
/** Triangle selectors /** Triangle selectors
can be used for doing collision detection. This triangle selector is can be used for doing collision detection. This triangle selector is
optimized for huge amounts of triangle, it organizes them in an octtree. optimized for huge amounts of triangle, it organizes them in an octree.
Please note that the created triangle selector is not automaticly attached Please note that the created triangle selector is not automaticly attached
to the scene node. You will have to call ISceneNode::setTriangleSelector() to the scene node. You will have to call ISceneNode::setTriangleSelector()
for this. To create and attach a triangle selector is done like this: for this. To create and attach a triangle selector is done like this:
\code \code
ITriangleSelector* s = sceneManager->createOctTreeTriangleSelector(yourMesh, ITriangleSelector* s = sceneManager->createOctreeTriangleSelector(yourMesh,
yourSceneNode); yourSceneNode);
yourSceneNode->setTriangleSelector(s); yourSceneNode->setTriangleSelector(s);
s->drop(); s->drop();
...@@ -1254,7 +1254,7 @@ namespace scene ...@@ -1254,7 +1254,7 @@ namespace scene
\return The selector, or null if not successful. \return The selector, or null if not successful.
If you no longer need the selector, you should call ITriangleSelector::drop(). If you no longer need the selector, you should call ITriangleSelector::drop().
See IReferenceCounted::drop() for more information. */ See IReferenceCounted::drop() for more information. */
virtual ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh, virtual ITriangleSelector* createOctreeTriangleSelector(IMesh* mesh,
ISceneNode* node, s32 minimalPolysPerNode=32) = 0; ISceneNode* node, s32 minimalPolysPerNode=32) = 0;
//! Creates a meta triangle selector. //! Creates a meta triangle selector.
......
...@@ -120,7 +120,7 @@ namespace scene ...@@ -120,7 +120,7 @@ namespace scene
ISceneNodeAnimator* anim = *ait; ISceneNodeAnimator* anim = *ait;
++ait; ++ait;
anim->animateNode(this, timeMs); anim->animateNode(this, timeMs);
} }
// update absolute position // update absolute position
updateAbsolutePosition(); updateAbsolutePosition();
...@@ -448,8 +448,8 @@ namespace scene ...@@ -448,8 +448,8 @@ namespace scene
//! Gets the scale of the scene node relative to its parent. //! Gets the scale of the scene node relative to its parent.
/** This is the scale of this node relative to its parent. /** This is the scale of this node relative to its parent.
If you want the absolute scale, use If you want the absolute scale, use
getAbsoluteTransformation().getScale() getAbsoluteTransformation().getScale()
\return The scale of the scene node. */ \return The scale of the scene node. */
virtual const core::vector3df& getScale() const virtual const core::vector3df& getScale() const
...@@ -537,7 +537,7 @@ namespace scene ...@@ -537,7 +537,7 @@ namespace scene
//! Sets if debug data like bounding boxes should be drawn. //! Sets if debug data like bounding boxes should be drawn.
/** A bitwise OR of the types from @ref irr::scene::E_DEBUG_SCENE_TYPE. /** A bitwise OR of the types from @ref irr::scene::E_DEBUG_SCENE_TYPE.
Please note that not all scene nodes support all debug data types. Please note that not all scene nodes support all debug data types.
\param state The debug data visibility state to be used. */ \param state The debug data visibility state to be used. */
virtual void setDebugDataVisible(s32 state) virtual void setDebugDataVisible(s32 state)
...@@ -546,7 +546,7 @@ namespace scene ...@@ -546,7 +546,7 @@ namespace scene
} }
//! Returns if debug data like bounding boxes are drawn. //! Returns if debug data like bounding boxes are drawn.
/** \return A bitwise OR of the debug data values from /** \return A bitwise OR of the debug data values from
@ref irr::scene::E_DEBUG_SCENE_TYPE that are currently visible. */ @ref irr::scene::E_DEBUG_SCENE_TYPE that are currently visible. */
s32 isDebugDataVisible() const s32 isDebugDataVisible() const
{ {
...@@ -602,7 +602,7 @@ namespace scene ...@@ -602,7 +602,7 @@ namespace scene
/** The Selector can be used by the engine for doing collision /** The Selector can be used by the engine for doing collision
detection. You can create a TriangleSelector with detection. You can create a TriangleSelector with
ISceneManager::createTriangleSelector() or ISceneManager::createTriangleSelector() or
ISceneManager::createOctTreeTriangleSelector and set it with ISceneManager::createOctreeTriangleSelector and set it with
ISceneNode::setTriangleSelector(). If a scene node got no triangle ISceneNode::setTriangleSelector(). If a scene node got no triangle
selector, but collision tests should be done with it, a triangle selector, but collision tests should be done with it, a triangle
selector is created using the bounding box of the scene node. selector is created using the bounding box of the scene node.
...@@ -618,7 +618,7 @@ namespace scene ...@@ -618,7 +618,7 @@ namespace scene
/** The Selector can be used by the engine for doing collision /** The Selector can be used by the engine for doing collision
detection. You can create a TriangleSelector with detection. You can create a TriangleSelector with
ISceneManager::createTriangleSelector() or ISceneManager::createTriangleSelector() or
ISceneManager::createOctTreeTriangleSelector(). Some nodes may ISceneManager::createOctreeTriangleSelector(). Some nodes may
create their own selector by default, so it would be good to create their own selector by default, so it would be good to
check if there is already a selector in this node by calling check if there is already a selector in this node by calling
ISceneNode::getTriangleSelector(). ISceneNode::getTriangleSelector().
...@@ -638,7 +638,7 @@ namespace scene ...@@ -638,7 +638,7 @@ namespace scene
//! Updates the absolute position based on the relative and the parents position //! Updates the absolute position based on the relative and the parents position
/** Note: This does not recursively update the parents absolute positions, so if you have a deeper /** Note: This does not recursively update the parents absolute positions, so if you have a deeper
hierarchy you might want to update the parents first.*/ hierarchy you might want to update the parents first.*/
virtual void updateAbsolutePosition() virtual void updateAbsolutePosition()
{ {
......
...@@ -263,15 +263,15 @@ ...@@ -263,15 +263,15 @@
* *
* Irrlicht can load a lot of file formats automaticly, see irr::scene::ISceneManager::getMesh() * Irrlicht can load a lot of file formats automaticly, see irr::scene::ISceneManager::getMesh()
* for a detailed list. So if you would like to replace the simple blue screen background by * for a detailed list. So if you would like to replace the simple blue screen background by
* a cool Quake 3 Map, optimized by an octtree, just insert this code * a cool Quake 3 Map, optimized by an octree, just insert this code
* somewhere before the while loop: * somewhere before the while loop:
* *
* \code * \code
* // add .pk3 archive to the file system * // add .pk3 archive to the file system
* device->getFileSystem()->addZipFileArchive("quake3map.pk3"); * device->getFileSystem()->addZipFileArchive("quake3map.pk3");
* *
* // load .bsp file and show it using an octtree * // load .bsp file and show it using an octree
* scenemgr->addOctTreeSceneNode( * scenemgr->addOctreeSceneNode(
* scenemgr->getMesh("quake3map.bsp")); * scenemgr->getMesh("quake3map.bsp"));
* \endcode * \endcode
* *
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
// The IrrCSM library features the following capabilities // The IrrCSM library features the following capabilities
// //
// * Loads the .csm 4.0 and 4.1 files transparently // * Loads the .csm 4.0 and 4.1 files transparently
// * Presents the loaded file as irr::scene::IAnimatedMesh for easy creation of IOctTreeSceneNode // * Presents the loaded file as irr::scene::IAnimatedMesh for easy creation of IOctreeSceneNode
// * Loads the textures given the correct texture root. hence map and textures can be in separate directories // * Loads the textures given the correct texture root. hence map and textures can be in separate directories
// //
// For more informations go to http://www.geocities.com/standard_template/irrcsm/downloads.html // For more informations go to http://www.geocities.com/standard_template/irrcsm/downloads.html
......
...@@ -38,7 +38,7 @@ CDefaultSceneNodeFactory::CDefaultSceneNodeFactory(ISceneManager* mgr) ...@@ -38,7 +38,7 @@ CDefaultSceneNodeFactory::CDefaultSceneNodeFactory(ISceneManager* mgr)
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_BOX, "skyBox")); SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_BOX, "skyBox"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_DOME, "skyDome")); SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_DOME, "skyDome"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SHADOW_VOLUME, "shadowVolume")); SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SHADOW_VOLUME, "shadowVolume"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_OCT_TREE, "octTree")); SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_OCTREE, "octree"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MESH, "mesh")); SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MESH, "mesh"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_LIGHT, "light")); SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_LIGHT, "light"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_EMPTY, "empty")); SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_EMPTY, "empty"));
...@@ -82,8 +82,8 @@ ISceneNode* CDefaultSceneNodeFactory::addSceneNode(ESCENE_NODE_TYPE type, IScene ...@@ -82,8 +82,8 @@ ISceneNode* CDefaultSceneNodeFactory::addSceneNode(ESCENE_NODE_TYPE type, IScene
return Manager->addSkyDomeSceneNode(0, 16, 8, 0.9f, 2.0f, 1000.0f, parent); return Manager->addSkyDomeSceneNode(0, 16, 8, 0.9f, 2.0f, 1000.0f, parent);
case ESNT_SHADOW_VOLUME: case ESNT_SHADOW_VOLUME:
return 0; return 0;
case ESNT_OCT_TREE: case ESNT_OCTREE:
return Manager->addOctTreeSceneNode((IMesh*)0, parent, -1, 128, true); return Manager->addOctreeSceneNode((IMesh*)0, parent, -1, 128, true);
case ESNT_MESH: case ESNT_MESH:
return Manager->addMeshSceneNode(0, parent, -1, core::vector3df(), return Manager->addMeshSceneNode(0, parent, -1, core::vector3df(),
core::vector3df(), core::vector3df(1,1,1), true); core::vector3df(), core::vector3df(1,1,1), true);
......
...@@ -2,27 +2,27 @@ ...@@ -2,27 +2,27 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ #ifndef __C_OCTREE_SCENE_NODE_H_INCLUDED__
#define __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ #define __C_OCTREE_SCENE_NODE_H_INCLUDED__
#include "IMeshSceneNode.h" #include "IMeshSceneNode.h"
#include "OctTree.h" #include "Octree.h"
namespace irr namespace irr
{ {
namespace scene namespace scene
{ {
//! implementation of the IBspTreeSceneNode //! implementation of the IBspTreeSceneNode
class COctTreeSceneNode : public IMeshSceneNode class COctreeSceneNode : public IMeshSceneNode
{ {
public: public:
//! constructor //! constructor
COctTreeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, COctreeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
s32 minimalPolysPerNode=512); s32 minimalPolysPerNode=512);
//! destructor //! destructor
virtual ~COctTreeSceneNode(); virtual ~COctreeSceneNode();
virtual void OnRegisterSceneNode(); virtual void OnRegisterSceneNode();
...@@ -41,7 +41,7 @@ namespace scene ...@@ -41,7 +41,7 @@ namespace scene
//! optimal position for minimizing renderstate changes, but can also be used //! optimal position for minimizing renderstate changes, but can also be used
//! to directly modify the material of a scene node. //! to directly modify the material of a scene node.
virtual video::SMaterial& getMaterial(u32 i); virtual video::SMaterial& getMaterial(u32 i);
//! returns amount of materials used by this scene node. //! returns amount of materials used by this scene node.
virtual u32 getMaterialCount() const; virtual u32 getMaterialCount() const;
...@@ -52,7 +52,7 @@ namespace scene ...@@ -52,7 +52,7 @@ namespace scene
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
//! Returns type of the scene node //! Returns type of the scene node
virtual ESCENE_NODE_TYPE getType() const { return ESNT_OCT_TREE; } virtual ESCENE_NODE_TYPE getType() const { return ESNT_OCTREE; }
//! Sets a new mesh to display //! Sets a new mesh to display
virtual void setMesh(IMesh* mesh); virtual void setMesh(IMesh* mesh);
...@@ -72,14 +72,14 @@ namespace scene ...@@ -72,14 +72,14 @@ namespace scene
core::aabbox3d<f32> Box; core::aabbox3d<f32> Box;
OctTree<video::S3DVertex>* StdOctTree; Octree<video::S3DVertex>* StdOctree;
core::array< OctTree<video::S3DVertex>::SMeshChunk > StdMeshes; core::array< Octree<video::S3DVertex>::SMeshChunk > StdMeshes;
OctTree<video::S3DVertex2TCoords>* LightMapOctTree; Octree<video::S3DVertex2TCoords>* LightMapOctree;
core::array< OctTree<video::S3DVertex2TCoords>::SMeshChunk > LightMapMeshes; core::array< Octree<video::S3DVertex2TCoords>::SMeshChunk > LightMapMeshes;
OctTree<video::S3DVertexTangents>* TangentsOctTree; Octree<video::S3DVertexTangents>* TangentsOctree;
core::array< OctTree<video::S3DVertexTangents>::SMeshChunk > TangentsMeshes; core::array< Octree<video::S3DVertexTangents>::SMeshChunk > TangentsMeshes;
video::E_VERTEX_TYPE vertexType; video::E_VERTEX_TYPE vertexType;
core::array< video::SMaterial > Materials; core::array< video::SMaterial > Materials;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#include "COctTreeTriangleSelector.h" #include "COctreeTriangleSelector.h"
#include "ISceneNode.h" #include "ISceneNode.h"
#include "os.h" #include "os.h"
...@@ -13,26 +13,26 @@ namespace scene ...@@ -13,26 +13,26 @@ namespace scene
{ {
//! constructor //! constructor
COctTreeTriangleSelector::COctTreeTriangleSelector(const IMesh* mesh, COctreeTriangleSelector::COctreeTriangleSelector(const IMesh* mesh,
const ISceneNode* node, s32 minimalPolysPerNode) const ISceneNode* node, s32 minimalPolysPerNode)
: CTriangleSelector(mesh, node), Root(0), NodeCount(0), : CTriangleSelector(mesh, node), Root(0), NodeCount(0),
MinimalPolysPerNode(minimalPolysPerNode) MinimalPolysPerNode(minimalPolysPerNode)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COctTreeTriangleSelector"); setDebugName("COctreeTriangleSelector");
#endif #endif
if (!Triangles.empty()) if (!Triangles.empty())
{ {
const u32 start = os::Timer::getRealTime(); const u32 start = os::Timer::getRealTime();
// create the triangle octtree // create the triangle octree
Root = new SOctTreeNode(); Root = new SOctreeNode();
Root->Triangles = Triangles; Root->Triangles = Triangles;
constructOctTree(Root); constructOctree(Root);
c8 tmp[256]; c8 tmp[256];
sprintf(tmp, "Needed %ums to create OctTreeTriangleSelector.(%d nodes, %u polys)", sprintf(tmp, "Needed %ums to create OctreeTriangleSelector.(%d nodes, %u polys)",
os::Timer::getRealTime() - start, NodeCount, Triangles.size()); os::Timer::getRealTime() - start, NodeCount, Triangles.size());
os::Printer::log(tmp, ELL_INFORMATION); os::Printer::log(tmp, ELL_INFORMATION);
} }
...@@ -40,13 +40,13 @@ COctTreeTriangleSelector::COctTreeTriangleSelector(const IMesh* mesh, ...@@ -40,13 +40,13 @@ COctTreeTriangleSelector::COctTreeTriangleSelector(const IMesh* mesh,
//! destructor //! destructor
COctTreeTriangleSelector::~COctTreeTriangleSelector() COctreeTriangleSelector::~COctreeTriangleSelector()
{ {
delete Root; delete Root;
} }
void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node) void COctreeTriangleSelector::constructOctree(SOctreeNode* node)
{ {
++NodeCount; ++NodeCount;
...@@ -75,7 +75,7 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node) ...@@ -75,7 +75,7 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node)
{ {
box.reset(middle); box.reset(middle);
box.addInternalPoint(edges[ch]); box.addInternalPoint(edges[ch]);
node->Child[ch] = new SOctTreeNode(); node->Child[ch] = new SOctreeNode();
for (s32 i=0; i<(s32)node->Triangles.size(); ++i) for (s32 i=0; i<(s32)node->Triangles.size(); ++i)
{ {
...@@ -102,13 +102,13 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node) ...@@ -102,13 +102,13 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node)
node->Child[ch] = 0; node->Child[ch] = 0;
} }
else else
constructOctTree(node->Child[ch]); constructOctree(node->Child[ch]);
} }
} }
//! Gets all triangles which lie within a specific bounding box. //! Gets all triangles which lie within a specific bounding box.
void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, void COctreeTriangleSelector::getTriangles(core::triangle3df* triangles,
s32 arraySize, s32& outTriangleCount, s32 arraySize, s32& outTriangleCount,
const core::aabbox3d<f32>& box, const core::aabbox3d<f32>& box,
const core::matrix4* transform) const const core::matrix4* transform) const
...@@ -138,15 +138,15 @@ void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, ...@@ -138,15 +138,15 @@ void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles,
s32 trianglesWritten = 0; s32 trianglesWritten = 0;
if (Root) if (Root)
getTrianglesFromOctTree(Root, trianglesWritten, getTrianglesFromOctree(Root, trianglesWritten,
arraySize, invbox, &mat, triangles); arraySize, invbox, &mat, triangles);
outTriangleCount = trianglesWritten; outTriangleCount = trianglesWritten;
} }
void COctTreeTriangleSelector::getTrianglesFromOctTree( void COctreeTriangleSelector::getTrianglesFromOctree(
SOctTreeNode* node, s32& trianglesWritten, SOctreeNode* node, s32& trianglesWritten,
s32 maximumSize, const core::aabbox3d<f32>& box, s32 maximumSize, const core::aabbox3d<f32>& box,
const core::matrix4* mat, core::triangle3df* triangles) const const core::matrix4* mat, core::triangle3df* triangles) const
{ {
...@@ -158,7 +158,7 @@ void COctTreeTriangleSelector::getTrianglesFromOctTree( ...@@ -158,7 +158,7 @@ void COctTreeTriangleSelector::getTrianglesFromOctTree(
cnt -= cnt + trianglesWritten - maximumSize; cnt -= cnt + trianglesWritten - maximumSize;
s32 i; s32 i;
for (i=0; i<cnt; ++i) for (i=0; i<cnt; ++i)
{ {
mat->transformVect(triangles[trianglesWritten].pointA, node->Triangles[i].pointA ); mat->transformVect(triangles[trianglesWritten].pointA, node->Triangles[i].pointA );
...@@ -169,14 +169,14 @@ void COctTreeTriangleSelector::getTrianglesFromOctTree( ...@@ -169,14 +169,14 @@ void COctTreeTriangleSelector::getTrianglesFromOctTree(
for (i=0; i<8; ++i) for (i=0; i<8; ++i)
if (node->Child[i]) if (node->Child[i])
getTrianglesFromOctTree(node->Child[i], trianglesWritten, getTrianglesFromOctree(node->Child[i], trianglesWritten,
maximumSize, box, mat, triangles); maximumSize, box, mat, triangles);
} }
//! Gets all triangles which have or may have contact with a 3d line. //! Gets all triangles which have or may have contact with a 3d line.
// new version: from user Piraaate // new version: from user Piraaate
void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, void COctreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::line3d<f32>& line, s32& outTriangleCount, const core::line3d<f32>& line,
const core::matrix4* transform) const const core::matrix4* transform) const
{ {
...@@ -185,7 +185,7 @@ void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 ar ...@@ -185,7 +185,7 @@ void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 ar
box.addInternalPoint(line.end); box.addInternalPoint(line.end);
// TODO: Could be optimized for line a little bit more. // TODO: Could be optimized for line a little bit more.
COctTreeTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, COctreeTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount,
box, transform); box, transform);
#else #else
...@@ -212,13 +212,13 @@ void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 ar ...@@ -212,13 +212,13 @@ void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 ar
s32 trianglesWritten = 0; s32 trianglesWritten = 0;
if (Root) if (Root)
getTrianglesFromOctTree(Root, trianglesWritten, arraySize, invline, &mat, triangles); getTrianglesFromOctree(Root, trianglesWritten, arraySize, invline, &mat, triangles);
outTriangleCount = trianglesWritten; outTriangleCount = trianglesWritten;
#endif #endif
} }
void COctTreeTriangleSelector::getTrianglesFromOctTree(SOctTreeNode* node, void COctreeTriangleSelector::getTrianglesFromOctree(SOctreeNode* node,
s32& trianglesWritten, s32 maximumSize, const core::line3d<f32>& line, s32& trianglesWritten, s32 maximumSize, const core::line3d<f32>& line,
const core::matrix4* transform, core::triangle3df* triangles) const const core::matrix4* transform, core::triangle3df* triangles) const
{ {
...@@ -253,7 +253,7 @@ void COctTreeTriangleSelector::getTrianglesFromOctTree(SOctTreeNode* node, ...@@ -253,7 +253,7 @@ void COctTreeTriangleSelector::getTrianglesFromOctTree(SOctTreeNode* node,
for (i=0; i<8; ++i) for (i=0; i<8; ++i)
if (node->Child[i]) if (node->Child[i])
getTrianglesFromOctTree(node->Child[i], trianglesWritten, getTrianglesFromOctree(node->Child[i], trianglesWritten,
maximumSize, line, transform, triangles); maximumSize, line, transform, triangles);
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_OCT_TREE_TRIANGLE_SELECTOR_H_INCLUDED__ #ifndef __C_OCTREE_TRIANGLE_SELECTOR_H_INCLUDED__
#define __C_OCT_TREE_TRIANGLE_SELECTOR_H_INCLUDED__ #define __C_OCTREE_TRIANGLE_SELECTOR_H_INCLUDED__
#include "CTriangleSelector.h" #include "CTriangleSelector.h"
...@@ -15,59 +15,59 @@ namespace scene ...@@ -15,59 +15,59 @@ namespace scene
class ISceneNode; class ISceneNode;
//! Stupid triangle selector without optimization //! Stupid triangle selector without optimization
class COctTreeTriangleSelector : public CTriangleSelector class COctreeTriangleSelector : public CTriangleSelector
{ {
public: public:
//! Constructs a selector based on a mesh //! Constructs a selector based on a mesh
COctTreeTriangleSelector(const IMesh* mesh, const ISceneNode* node, s32 minimalPolysPerNode); COctreeTriangleSelector(const IMesh* mesh, const ISceneNode* node, s32 minimalPolysPerNode);
virtual ~COctTreeTriangleSelector(); virtual ~COctreeTriangleSelector();
//! Gets all triangles which lie within a specific bounding box. //! Gets all triangles which lie within a specific bounding box.
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const; const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const;
//! Gets all triangles which have or may have contact with a 3d line. //! Gets all triangles which have or may have contact with a 3d line.
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::line3d<f32>& line, s32& outTriangleCount, const core::line3d<f32>& line,
const core::matrix4* transform=0) const; const core::matrix4* transform=0) const;
private: private:
struct SOctTreeNode struct SOctreeNode
{ {
SOctTreeNode() SOctreeNode()
{ {
for (u32 i=0; i!=8; ++i) for (u32 i=0; i!=8; ++i)
Child[i] = 0; Child[i] = 0;
} }
~SOctTreeNode() ~SOctreeNode()
{ {
for (u32 i=0; i!=8; ++i) for (u32 i=0; i!=8; ++i)
delete Child[i]; delete Child[i];
} }
core::array<core::triangle3df> Triangles; core::array<core::triangle3df> Triangles;
SOctTreeNode* Child[8]; SOctreeNode* Child[8];
core::aabbox3d<f32> Box; core::aabbox3d<f32> Box;
}; };
void constructOctTree(SOctTreeNode* node); void constructOctree(SOctreeNode* node);
void deleteEmptyNodes(SOctTreeNode* node); void deleteEmptyNodes(SOctreeNode* node);
void getTrianglesFromOctTree(SOctTreeNode* node, s32& trianglesWritten, void getTrianglesFromOctree(SOctreeNode* node, s32& trianglesWritten,
s32 maximumSize, const core::aabbox3d<f32>& box, s32 maximumSize, const core::aabbox3d<f32>& box,
const core::matrix4* transform, const core::matrix4* transform,
core::triangle3df* triangles) const; core::triangle3df* triangles) const;
void getTrianglesFromOctTree(SOctTreeNode* node, s32& trianglesWritten, void getTrianglesFromOctree(SOctreeNode* node, s32& trianglesWritten,
s32 maximumSize, const core::line3d<f32>& line, s32 maximumSize, const core::line3d<f32>& line,
const core::matrix4* transform, const core::matrix4* transform,
core::triangle3df* triangles) const; core::triangle3df* triangles) const;
SOctTreeNode* Root; SOctreeNode* Root;
s32 NodeCount; s32 NodeCount;
s32 MinimalPolysPerNode; s32 MinimalPolysPerNode;
}; };
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
#include "CCubeSceneNode.h" #include "CCubeSceneNode.h"
#include "CSphereSceneNode.h" #include "CSphereSceneNode.h"
#include "CAnimatedMeshSceneNode.h" #include "CAnimatedMeshSceneNode.h"
#include "COctTreeSceneNode.h" #include "COctreeSceneNode.h"
#include "CCameraSceneNode.h" #include "CCameraSceneNode.h"
#include "CLightSceneNode.h" #include "CLightSceneNode.h"
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
#include "CSceneCollisionManager.h" #include "CSceneCollisionManager.h"
#include "CTriangleSelector.h" #include "CTriangleSelector.h"
#include "COctTreeTriangleSelector.h" #include "COctreeTriangleSelector.h"
#include "CTriangleBBSelector.h" #include "CTriangleBBSelector.h"
#include "CMetaTriangleSelector.h" #include "CMetaTriangleSelector.h"
#include "CTerrainTriangleSelector.h" #include "CTerrainTriangleSelector.h"
...@@ -615,25 +615,25 @@ IAnimatedMeshSceneNode* CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh* m ...@@ -615,25 +615,25 @@ IAnimatedMeshSceneNode* CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh* m
} }
//! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering //! Adds a scene node for rendering using a octree to the scene graph. This a good method for rendering
//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much
//! faster then a bsp tree. //! faster then a bsp tree.
IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, IMeshSceneNode* CSceneManager::addOctreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent,
s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero)
{ {
if (!alsoAddIfMeshPointerZero && (!mesh || !mesh->getFrameCount())) if (!alsoAddIfMeshPointerZero && (!mesh || !mesh->getFrameCount()))
return 0; return 0;
return addOctTreeSceneNode(mesh ? mesh->getMesh(0) : 0, return addOctreeSceneNode(mesh ? mesh->getMesh(0) : 0,
parent, id, minimalPolysPerNode, parent, id, minimalPolysPerNode,
alsoAddIfMeshPointerZero); alsoAddIfMeshPointerZero);
} }
//! Adds a scene node for rendering using a octtree. This a good method for rendering //! Adds a scene node for rendering using a octree. This a good method for rendering
//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much
//! faster then a bsp tree. //! faster then a bsp tree.
IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent, IMeshSceneNode* CSceneManager::addOctreeSceneNode(IMesh* mesh, ISceneNode* parent,
s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero)
{ {
if (!alsoAddIfMeshPointerZero && !mesh) if (!alsoAddIfMeshPointerZero && !mesh)
...@@ -642,7 +642,7 @@ IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* pare ...@@ -642,7 +642,7 @@ IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* pare
if (!parent) if (!parent)
parent = this; parent = this;
COctTreeSceneNode* node = new COctTreeSceneNode(parent, this, id, minimalPolysPerNode); COctreeSceneNode* node = new COctreeSceneNode(parent, this, id, minimalPolysPerNode);
if (node) if (node)
{ {
...@@ -1749,14 +1749,14 @@ ITriangleSelector* CSceneManager::createTriangleSelectorFromBoundingBox(ISceneNo ...@@ -1749,14 +1749,14 @@ ITriangleSelector* CSceneManager::createTriangleSelectorFromBoundingBox(ISceneNo
//! Creates a simple ITriangleSelector, based on a mesh. //! Creates a simple ITriangleSelector, based on a mesh.
ITriangleSelector* CSceneManager::createOctTreeTriangleSelector(IMesh* mesh, ITriangleSelector* CSceneManager::createOctreeTriangleSelector(IMesh* mesh,
ISceneNode* node, ISceneNode* node,
s32 minimalPolysPerNode) s32 minimalPolysPerNode)
{ {
if (!mesh) if (!mesh)
return 0; return 0;
return new COctTreeTriangleSelector(mesh, node, minimalPolysPerNode); return new COctreeTriangleSelector(mesh, node, minimalPolysPerNode);
} }
......
...@@ -113,16 +113,16 @@ namespace scene ...@@ -113,16 +113,16 @@ namespace scene
//! draws all scene nodes //! draws all scene nodes
virtual void drawAll(); virtual void drawAll();
//! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering //! Adds a scene node for rendering using a octree to the scene graph. This a good method for rendering
//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much
//! faster then a bsp tree. //! faster then a bsp tree.
virtual IMeshSceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, virtual IMeshSceneNode* addOctreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false); s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false);
//! Adss a scene node for rendering using a octtree. This a good method for rendering //! Adss a scene node for rendering using a octree. This a good method for rendering
//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much
//! faster then a bsp tree. //! faster then a bsp tree.
virtual IMeshSceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, virtual IMeshSceneNode* addOctreeSceneNode(IMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false);
//! Adds a camera scene node to the tree and sets it as active camera. //! Adds a camera scene node to the tree and sets it as active camera.
...@@ -351,7 +351,7 @@ namespace scene ...@@ -351,7 +351,7 @@ namespace scene
virtual ITriangleSelector* createTriangleSelector(IAnimatedMeshSceneNode* node); virtual ITriangleSelector* createTriangleSelector(IAnimatedMeshSceneNode* node);
//! Creates a simple ITriangleSelector, based on a mesh. //! Creates a simple ITriangleSelector, based on a mesh.
virtual ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh, virtual ITriangleSelector* createOctreeTriangleSelector(IMesh* mesh,
ISceneNode* node, s32 minimalPolysPerNode); ISceneNode* node, s32 minimalPolysPerNode);
//! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box.
......
...@@ -783,10 +783,10 @@ ...@@ -783,10 +783,10 @@
<Unit filename="COCTLoader.h" /> <Unit filename="COCTLoader.h" />
<Unit filename="COSOperator.cpp" /> <Unit filename="COSOperator.cpp" />
<Unit filename="COSOperator.h" /> <Unit filename="COSOperator.h" />
<Unit filename="COctTreeSceneNode.cpp" /> <Unit filename="COctreeSceneNode.cpp" />
<Unit filename="COctTreeSceneNode.h" /> <Unit filename="COctreeSceneNode.h" />
<Unit filename="COctTreeTriangleSelector.cpp" /> <Unit filename="COctreeTriangleSelector.cpp" />
<Unit filename="COctTreeTriangleSelector.h" /> <Unit filename="COctreeTriangleSelector.h" />
<Unit filename="COgreMeshFileLoader.cpp" /> <Unit filename="COgreMeshFileLoader.cpp" />
<Unit filename="COgreMeshFileLoader.h" /> <Unit filename="COgreMeshFileLoader.h" />
<Unit filename="COpenGLDriver.cpp" /> <Unit filename="COpenGLDriver.cpp" />
...@@ -951,7 +951,7 @@ ...@@ -951,7 +951,7 @@
<Unit filename="Irrlicht.cpp" /> <Unit filename="Irrlicht.cpp" />
<Unit filename="MacOSX/CIrrDeviceMacOSX.h" /> <Unit filename="MacOSX/CIrrDeviceMacOSX.h" />
<Unit filename="MacOSX/CIrrDeviceMacOSX.mm" /> <Unit filename="MacOSX/CIrrDeviceMacOSX.mm" />
<Unit filename="OctTree.h" /> <Unit filename="Octree.h" />
<Unit filename="S2DVertex.h" /> <Unit filename="S2DVertex.h" />
<Unit filename="S4DVertex.h" /> <Unit filename="S4DVertex.h" />
<Unit filename="SoftwareDriver2_compile_config.h" /> <Unit filename="SoftwareDriver2_compile_config.h" />
......
...@@ -1477,7 +1477,7 @@ ...@@ -1477,7 +1477,7 @@
RelativePath="CSceneManager.h"> RelativePath="CSceneManager.h">
</File> </File>
<File <File
RelativePath="OctTree.h"> RelativePath="Octree.h">
</File> </File>
<Filter <Filter
Name="loaders"> Name="loaders">
...@@ -1683,10 +1683,10 @@ ...@@ -1683,10 +1683,10 @@
RelativePath=".\CMeshSceneNode.h"> RelativePath=".\CMeshSceneNode.h">
</File> </File>
<File <File
RelativePath=".\COctTreeSceneNode.cpp"> RelativePath=".\COctreeSceneNode.cpp">
</File> </File>
<File <File
RelativePath=".\COctTreeSceneNode.h"> RelativePath=".\COctreeSceneNode.h">
</File> </File>
<File <File
RelativePath=".\CQuake3ShaderSceneNode.cpp"> RelativePath=".\CQuake3ShaderSceneNode.cpp">
...@@ -1812,10 +1812,10 @@ ...@@ -1812,10 +1812,10 @@
RelativePath="CMetaTriangleSelector.h"> RelativePath="CMetaTriangleSelector.h">
</File> </File>
<File <File
RelativePath="COctTreeTriangleSelector.cpp"> RelativePath="COctreeTriangleSelector.cpp">
</File> </File>
<File <File
RelativePath="COctTreeTriangleSelector.h"> RelativePath="COctreeTriangleSelector.h">
</File> </File>
<File <File
RelativePath="CSceneCollisionManager.cpp"> RelativePath="CSceneCollisionManager.cpp">
......
...@@ -2354,11 +2354,11 @@ ...@@ -2354,11 +2354,11 @@
> >
</File> </File>
<File <File
RelativePath=".\COctTreeSceneNode.cpp" RelativePath=".\COctreeSceneNode.cpp"
> >
</File> </File>
<File <File
RelativePath=".\COctTreeSceneNode.h" RelativePath=".\COctreeSceneNode.h"
> >
</File> </File>
<File <File
...@@ -2534,11 +2534,11 @@ ...@@ -2534,11 +2534,11 @@
> >
</File> </File>
<File <File
RelativePath="COctTreeTriangleSelector.cpp" RelativePath="COctreeTriangleSelector.cpp"
> >
</File> </File>
<File <File
RelativePath="COctTreeTriangleSelector.h" RelativePath="COctreeTriangleSelector.h"
> >
</File> </File>
<File <File
...@@ -2574,7 +2574,7 @@ ...@@ -2574,7 +2574,7 @@
> >
</File> </File>
<File <File
RelativePath=".\OctTree.h" RelativePath=".\Octree.h"
> >
</File> </File>
</Filter> </Filter>
......
...@@ -1372,7 +1372,7 @@ ...@@ -1372,7 +1372,7 @@
> >
</File> </File>
<File <File
RelativePath="OctTree.h" RelativePath="Octree.h"
> >
</File> </File>
<Filter <Filter
...@@ -1647,11 +1647,11 @@ ...@@ -1647,11 +1647,11 @@
> >
</File> </File>
<File <File
RelativePath="COctTreeSceneNode.cpp" RelativePath="COctreeSceneNode.cpp"
> >
</File> </File>
<File <File
RelativePath="COctTreeSceneNode.h" RelativePath="COctreeSceneNode.h"
> >
</File> </File>
<File <File
...@@ -1847,11 +1847,11 @@ ...@@ -1847,11 +1847,11 @@
> >
</File> </File>
<File <File
RelativePath="COctTreeTriangleSelector.cpp" RelativePath="COctreeTriangleSelector.cpp"
> >
</File> </File>
<File <File
RelativePath="COctTreeTriangleSelector.h" RelativePath="COctreeTriangleSelector.h"
> >
</File> </File>
<File <File
......
...@@ -1726,7 +1726,7 @@ ...@@ -1726,7 +1726,7 @@
> >
</File> </File>
<File <File
RelativePath="OctTree.h" RelativePath="Octree.h"
> >
</File> </File>
<Filter <Filter
...@@ -2001,11 +2001,11 @@ ...@@ -2001,11 +2001,11 @@
> >
</File> </File>
<File <File
RelativePath="COctTreeSceneNode.cpp" RelativePath="COctreeSceneNode.cpp"
> >
</File> </File>
<File <File
RelativePath="COctTreeSceneNode.h" RelativePath="COctreeSceneNode.h"
> >
</File> </File>
<File <File
...@@ -2173,11 +2173,11 @@ ...@@ -2173,11 +2173,11 @@
> >
</File> </File>
<File <File
RelativePath="COctTreeTriangleSelector.cpp" RelativePath="COctreeTriangleSelector.cpp"
> >
</File> </File>
<File <File
RelativePath="COctTreeTriangleSelector.h" RelativePath="COctreeTriangleSelector.h"
> >
</File> </File>
<File <File
......
...@@ -749,10 +749,10 @@ ...@@ -749,10 +749,10 @@
RelativePath=".\CLightSceneNode.h"> RelativePath=".\CLightSceneNode.h">
</File> </File>
<File <File
RelativePath=".\COctTreeSceneNode.cpp"> RelativePath=".\COctreeSceneNode.cpp">
</File> </File>
<File <File
RelativePath=".\COctTreeSceneNode.h"> RelativePath=".\COctreeSceneNode.h">
</File> </File>
<File <File
RelativePath=".\CShadowVolumeSceneNode.cpp"> RelativePath=".\CShadowVolumeSceneNode.cpp">
...@@ -1105,10 +1105,10 @@ ...@@ -1105,10 +1105,10 @@
RelativePath=".\COCTLoader.h"> RelativePath=".\COCTLoader.h">
</File> </File>
<File <File
RelativePath=".\COctTreeTriangleSelector.cpp"> RelativePath=".\COctreeTriangleSelector.cpp">
</File> </File>
<File <File
RelativePath=".\COctTreeTriangleSelector.h"> RelativePath=".\COctreeTriangleSelector.h">
</File> </File>
<File <File
RelativePath=".\COgreMeshFileLoader.cpp"> RelativePath=".\COgreMeshFileLoader.cpp">
...@@ -1408,7 +1408,7 @@ ...@@ -1408,7 +1408,7 @@
RelativePath=".\IZBuffer.h"> RelativePath=".\IZBuffer.h">
</File> </File>
<File <File
RelativePath=".\OctTree.h"> RelativePath=".\Octree.h">
</File> </File>
<File <File
RelativePath=".\os.cpp"> RelativePath=".\os.cpp">
......
...@@ -28,7 +28,7 @@ IRRMESHOBJ = $(IRRMESHLOADER) $(IRRMESHWRITER) \ ...@@ -28,7 +28,7 @@ IRRMESHOBJ = $(IRRMESHLOADER) $(IRRMESHWRITER) \
CSkinnedMesh.o CBoneSceneNode.o CMeshSceneNode.o \ CSkinnedMesh.o CBoneSceneNode.o CMeshSceneNode.o \
CAnimatedMeshSceneNode.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o \ CAnimatedMeshSceneNode.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o \
CQ3LevelMesh.o CQuake3ShaderSceneNode.o CQ3LevelMesh.o CQuake3ShaderSceneNode.o
IRROBJ = CBillboardSceneNode.o CCameraSceneNode.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CMeshManipulator.o CMetaTriangleSelector.o COctTreeSceneNode.o COctTreeTriangleSelector.o CSceneCollisionManager.o CSceneManager.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CVolumeLightSceneNode.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o IRROBJ = CBillboardSceneNode.o CCameraSceneNode.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CMeshManipulator.o CMetaTriangleSelector.o COctreeSceneNode.o COctreeTriangleSelector.o CSceneCollisionManager.o CSceneManager.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CVolumeLightSceneNode.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o
IRRPARTICLEOBJ = CParticleAnimatedMeshSceneNodeEmitter.o CParticleBoxEmitter.o CParticleCylinderEmitter.o CParticleMeshEmitter.o CParticlePointEmitter.o CParticleRingEmitter.o CParticleSphereEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticleSystemSceneNode.o CParticleScaleAffector.o IRRPARTICLEOBJ = CParticleAnimatedMeshSceneNodeEmitter.o CParticleBoxEmitter.o CParticleCylinderEmitter.o CParticleMeshEmitter.o CParticlePointEmitter.o CParticleRingEmitter.o CParticleSphereEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticleSystemSceneNode.o CParticleScaleAffector.o
IRRANIMOBJ = CSceneNodeAnimatorCameraFPS.o CSceneNodeAnimatorCameraMaya.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o IRRANIMOBJ = CSceneNodeAnimatorCameraFPS.o CSceneNodeAnimatorCameraMaya.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o
IRRDRVROBJ = CNullDriver.o COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o IRRDRVROBJ = CNullDriver.o COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_OCT_TREE_H_INCLUDED__ #ifndef __C_OCTREE_H_INCLUDED__
#define __C_OCT_TREE_H_INCLUDED__ #define __C_OCTREE_H_INCLUDED__
#include "SViewFrustum.h" #include "SViewFrustum.h"
#include "S3DVertex.h" #include "S3DVertex.h"
...@@ -12,24 +12,24 @@ ...@@ -12,24 +12,24 @@
#include "CMeshBuffer.h" #include "CMeshBuffer.h"
/*! /*!
Flags for Octtree Flags for Octree
*/ */
#define OCTTREE_USE_HARDWARE // use meshbuffer for drawing, enables hardware acceleration #define OCTREE_USE_HARDWARE // use meshbuffer for drawing, enables hardware acceleration
#define OCTTREE_PARENTTEST // bypass full invisible/visible test #define OCTREE_PARENTTEST // bypass full invisible/visible test
#define OCTTREE_BOX_BASED // use bounding box or frustum for calculate polys #define OCTREE_BOX_BASED // use bounding box or frustum for calculate polys
namespace irr namespace irr
{ {
//! template octtree. //! template octree.
/** T must be a vertex type which has a member /** T must be a vertex type which has a member
called .Pos, which is a core::vertex3df position. */ called .Pos, which is a core::vertex3df position. */
template <class T> template <class T>
class OctTree class Octree
{ {
public: public:
#if defined (OCTTREE_USE_HARDWARE) #if defined (OCTREE_USE_HARDWARE)
struct SMeshChunk : public scene::CMeshBuffer<T> struct SMeshChunk : public scene::CMeshBuffer<T>
{ {
SMeshChunk () SMeshChunk ()
...@@ -69,7 +69,7 @@ public: ...@@ -69,7 +69,7 @@ public:
//! Constructor //! Constructor
OctTree(const core::array<SMeshChunk>& meshes, s32 minimalPolysPerNode=128) : Octree(const core::array<SMeshChunk>& meshes, s32 minimalPolysPerNode=128) :
IndexData(0), IndexDataCount(meshes.size()), NodeCount(0) IndexData(0), IndexDataCount(meshes.size()), NodeCount(0)
{ {
IndexData = new SIndexData[IndexDataCount]; IndexData = new SIndexData[IndexDataCount];
...@@ -92,10 +92,10 @@ public: ...@@ -92,10 +92,10 @@ public:
} }
// create tree // create tree
Root = new OctTreeNode(NodeCount, 0, meshes, indexChunks, minimalPolysPerNode); Root = new OctreeNode(NodeCount, 0, meshes, indexChunks, minimalPolysPerNode);
} }
//! returns all ids of polygons partially or fully enclosed //! returns all ids of polygons partially or fully enclosed
//! by this bounding box. //! by this bounding box.
void calculatePolys(const core::aabbox3d<f32>& box) void calculatePolys(const core::aabbox3d<f32>& box)
{ {
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
Root->getPolys(box, IndexData, 0); Root->getPolys(box, IndexData, 0);
} }
//! returns all ids of polygons partially or fully enclosed //! returns all ids of polygons partially or fully enclosed
//! by a view frustum. //! by a view frustum.
void calculatePolys(const scene::SViewFrustum& frustum) void calculatePolys(const scene::SViewFrustum& frustum)
{ {
...@@ -131,14 +131,14 @@ public: ...@@ -131,14 +131,14 @@ public:
} }
//! for debug purposes only, collects the bounding boxes of the tree //! for debug purposes only, collects the bounding boxes of the tree
void getBoundingBoxes(const core::aabbox3d<f32>& box, void getBoundingBoxes(const core::aabbox3d<f32>& box,
core::array< const core::aabbox3d<f32>* >&outBoxes) const core::array< const core::aabbox3d<f32>* >&outBoxes) const
{ {
Root->getBoundingBoxes(box, outBoxes); Root->getBoundingBoxes(box, outBoxes);
} }
//! destructor //! destructor
~OctTree() ~Octree()
{ {
for (u32 i=0; i<IndexDataCount; ++i) for (u32 i=0; i<IndexDataCount; ++i)
delete [] IndexData[i].Indices; delete [] IndexData[i].Indices;
...@@ -149,19 +149,19 @@ public: ...@@ -149,19 +149,19 @@ public:
private: private:
// private inner class // private inner class
class OctTreeNode class OctreeNode
{ {
public: public:
// constructor // constructor
OctTreeNode(u32& nodeCount, u32 currentdepth, OctreeNode(u32& nodeCount, u32 currentdepth,
const core::array<SMeshChunk>& allmeshdata, const core::array<SMeshChunk>& allmeshdata,
core::array<SIndexChunk>* indices, core::array<SIndexChunk>* indices,
s32 minimalPolysPerNode) : IndexData(0), s32 minimalPolysPerNode) : IndexData(0),
Depth(currentdepth+1) Depth(currentdepth+1)
{ {
++nodeCount; ++nodeCount;
u32 i; // new ISO for scoping problem with different compilers u32 i; // new ISO for scoping problem with different compilers
for (i=0; i!=8; ++i) for (i=0; i!=8; ++i)
...@@ -206,7 +206,7 @@ private: ...@@ -206,7 +206,7 @@ private:
core::vector3df middle = Box.getCenter(); core::vector3df middle = Box.getCenter();
core::vector3df edges[8]; core::vector3df edges[8];
Box.getEdges(edges); Box.getEdges(edges);
// calculate all children // calculate all children
core::aabbox3d<f32> box; core::aabbox3d<f32> box;
core::array<u16> keepIndices; core::array<u16> keepIndices;
...@@ -246,14 +246,14 @@ private: ...@@ -246,14 +246,14 @@ private:
keepIndices.push_back((*indices)[i].Indices[t+2]); keepIndices.push_back((*indices)[i].Indices[t+2]);
} }
} }
memcpy( (*indices)[i].Indices.pointer(), keepIndices.pointer(), keepIndices.size()*sizeof(u16)); memcpy( (*indices)[i].Indices.pointer(), keepIndices.pointer(), keepIndices.size()*sizeof(u16));
(*indices)[i].Indices.set_used(keepIndices.size()); (*indices)[i].Indices.set_used(keepIndices.size());
keepIndices.set_used(0); keepIndices.set_used(0);
} }
if (added) if (added)
Children[ch] = new OctTreeNode(nodeCount, Depth, Children[ch] = new OctreeNode(nodeCount, Depth,
allmeshdata, cindexChunks, minimalPolysPerNode); allmeshdata, cindexChunks, minimalPolysPerNode);
else else
delete cindexChunks; delete cindexChunks;
...@@ -264,7 +264,7 @@ private: ...@@ -264,7 +264,7 @@ private:
} }
// destructor // destructor
~OctTreeNode() ~OctreeNode()
{ {
delete IndexData; delete IndexData;
...@@ -272,11 +272,11 @@ private: ...@@ -272,11 +272,11 @@ private:
delete Children[i]; delete Children[i];
} }
// returns all ids of polygons partially or full enclosed // returns all ids of polygons partially or full enclosed
// by this bounding box. // by this bounding box.
void getPolys(const core::aabbox3d<f32>& box, SIndexData* idxdata, u32 parentTest ) const void getPolys(const core::aabbox3d<f32>& box, SIndexData* idxdata, u32 parentTest ) const
{ {
#if defined (OCTTREE_PARENTTEST ) #if defined (OCTREE_PARENTTEST )
// if not full inside // if not full inside
if ( parentTest != 2 ) if ( parentTest != 2 )
{ {
...@@ -293,14 +293,14 @@ private: ...@@ -293,14 +293,14 @@ private:
{ {
const u32 cnt = IndexData->size(); const u32 cnt = IndexData->size();
u32 i; // new ISO for scoping problem in some compilers u32 i; // new ISO for scoping problem in some compilers
for (i=0; i<cnt; ++i) for (i=0; i<cnt; ++i)
{ {
const s32 idxcnt = (*IndexData)[i].Indices.size(); const s32 idxcnt = (*IndexData)[i].Indices.size();
if (idxcnt) if (idxcnt)
{ {
memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize], memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize],
&(*IndexData)[i].Indices[0], idxcnt * sizeof(s16)); &(*IndexData)[i].Indices[0], idxcnt * sizeof(s16));
idxdata[i].CurrentSize += idxcnt; idxdata[i].CurrentSize += idxcnt;
} }
...@@ -312,14 +312,14 @@ private: ...@@ -312,14 +312,14 @@ private:
} }
} }
// returns all ids of polygons partially or full enclosed // returns all ids of polygons partially or full enclosed
// by the view frustum. // by the view frustum.
void getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata,u32 parentTest) const void getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata,u32 parentTest) const
{ {
u32 i; // new ISO for scoping problem in some compilers u32 i; // new ISO for scoping problem in some compilers
// if parent is fully inside, no further check for the children is needed // if parent is fully inside, no further check for the children is needed
#if defined (OCTTREE_PARENTTEST ) #if defined (OCTREE_PARENTTEST )
if ( parentTest != 2 ) if ( parentTest != 2 )
#endif #endif
{ {
...@@ -335,7 +335,7 @@ private: ...@@ -335,7 +335,7 @@ private:
if (frustum.planes[i].classifyPointRelation(edges[j]) != core::ISREL3D_FRONT) if (frustum.planes[i].classifyPointRelation(edges[j]) != core::ISREL3D_FRONT)
{ {
boxInFrustum += 1; boxInFrustum += 1;
#if !defined (OCTTREE_PARENTTEST ) #if !defined (OCTREE_PARENTTEST )
break; break;
#endif #endif
} }
...@@ -344,7 +344,7 @@ private: ...@@ -344,7 +344,7 @@ private:
if ( 0 == boxInFrustum) // all edges outside if ( 0 == boxInFrustum) // all edges outside
return; return;
#if defined (OCTTREE_PARENTTEST ) #if defined (OCTREE_PARENTTEST )
if ( 8 == boxInFrustum) // all edges in, all children in if ( 8 == boxInFrustum) // all edges in, all children in
parentTest = 2; parentTest = 2;
#endif #endif
...@@ -352,14 +352,14 @@ private: ...@@ -352,14 +352,14 @@ private:
} }
const u32 cnt = IndexData->size(); const u32 cnt = IndexData->size();
for (i=0; i!=cnt; ++i) for (i=0; i!=cnt; ++i)
{ {
s32 idxcnt = (*IndexData)[i].Indices.size(); s32 idxcnt = (*IndexData)[i].Indices.size();
if (idxcnt) if (idxcnt)
{ {
memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize], memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize],
&(*IndexData)[i].Indices[0], idxcnt * sizeof(s16)); &(*IndexData)[i].Indices[0], idxcnt * sizeof(s16));
idxdata[i].CurrentSize += idxcnt; idxdata[i].CurrentSize += idxcnt;
} }
...@@ -377,7 +377,7 @@ private: ...@@ -377,7 +377,7 @@ private:
if (Box.intersectsWithBox(box)) if (Box.intersectsWithBox(box))
{ {
outBoxes.push_back(&Box); outBoxes.push_back(&Box);
for (u32 i=0; i!=8; ++i) for (u32 i=0; i!=8; ++i)
if (Children[i]) if (Children[i])
Children[i]->getBoundingBoxes(box, outBoxes); Children[i]->getBoundingBoxes(box, outBoxes);
...@@ -388,11 +388,11 @@ private: ...@@ -388,11 +388,11 @@ private:
core::aabbox3df Box; core::aabbox3df Box;
core::array<SIndexChunk>* IndexData; core::array<SIndexChunk>* IndexData;
OctTreeNode* Children[8]; OctreeNode* Children[8];
u32 Depth; u32 Depth;
}; };
OctTreeNode* Root; OctreeNode* Root;
SIndexData* IndexData; SIndexData* IndexData;
u32 IndexDataCount; u32 IndexDataCount;
u32 NodeCount; u32 NodeCount;
......
...@@ -26,7 +26,7 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType) ...@@ -26,7 +26,7 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType)
if(added) if(added)
{ {
ISceneNode * node = smgr->addOctTreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024); ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
assert(node); assert(node);
if (node) if (node)
......
...@@ -46,7 +46,7 @@ static bool transformPlane(const vector3df & point, const vector3df & normal, ...@@ -46,7 +46,7 @@ static bool transformPlane(const vector3df & point, const vector3df & normal,
} }
static bool drawScaledOctTree(void) static bool drawScaledOctree(void)
{ {
bool result = false; bool result = false;
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32); IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
...@@ -61,7 +61,7 @@ static bool drawScaledOctTree(void) ...@@ -61,7 +61,7 @@ static bool drawScaledOctTree(void)
if(added) if(added)
{ {
ISceneNode * node = smgr->addOctTreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024); ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
assert(node); assert(node);
if (node) if (node)
...@@ -228,7 +228,7 @@ bool planeMatrix(void) ...@@ -228,7 +228,7 @@ bool planeMatrix(void)
success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f), -1.768f)); success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f), -1.768f));
success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f), 1.768f)); success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f), 1.768f));
success &= drawScaledOctTree(); success &= drawScaledOctree();
return success; return success;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment