Commit 02b49eea authored by nadro's avatar nadro

- Added exampleHelper and updated all examples. This is a base patch for...

- Added exampleHelper and updated all examples. This is a base patch for upcoming patches related to iOS and OSX.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5143 dfc29bdd-3216-0410-991c-e03cc46cb475
parent cacfc0a8
...@@ -43,6 +43,7 @@ After we have set up the IDE, the compiler will know where to find the Irrlicht ...@@ -43,6 +43,7 @@ After we have set up the IDE, the compiler will know where to find the Irrlicht
Engine header files so we can include it now in our code. Engine header files so we can include it now in our code.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "exampleHelper.h"
/* /*
In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if
...@@ -152,6 +153,11 @@ int main() ...@@ -152,6 +153,11 @@ int main()
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true); rect<s32>(10,10,260,22), true);
/*
Get a media path dedicated for your platform.
*/
const io::path mediaPath = getExampleMediaPath();
/* /*
To show something interesting, we load a Quake 2 model and display it. To show something interesting, we load a Quake 2 model and display it.
We only have to get the Mesh from the Scene Manager with getMesh() and add We only have to get the Mesh from the Scene Manager with getMesh() and add
...@@ -164,7 +170,7 @@ int main() ...@@ -164,7 +170,7 @@ int main()
other supported file format. By the way, that cool Quake 2 model other supported file format. By the way, that cool Quake 2 model
called sydney was modelled by Brian Collins. called sydney was modelled by Brian Collins.
*/ */
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2"); IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "sydney.md2");
if (!mesh) if (!mesh)
{ {
device->drop(); device->drop();
...@@ -184,7 +190,7 @@ int main() ...@@ -184,7 +190,7 @@ int main()
{ {
node->setMaterialFlag(EMF_LIGHTING, false); node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND); node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") ); node->setMaterialTexture( 0, driver->getTexture(mediaPath + "sydney.bmp") );
} }
/* /*
......
...@@ -13,7 +13,8 @@ and an additional file to be able to ask the user for a driver type using the ...@@ -13,7 +13,8 @@ and an additional file to be able to ask the user for a driver type using the
console. console.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include <iostream> #include "driverChoice.h"
#include "exampleHelper.h"
/* /*
As already written in the HelloWorld example, in the Irrlicht Engine everything As already written in the HelloWorld example, in the Irrlicht Engine everything
...@@ -47,32 +48,12 @@ int main() ...@@ -47,32 +48,12 @@ int main()
which video driver to use. The Software device might be which video driver to use. The Software device might be
too slow to draw a huge Quake 3 map, but just for the fun of it, we make too slow to draw a huge Quake 3 map, but just for the fun of it, we make
this decision possible, too. this decision possible, too.
Instead of copying this whole code into your app, you can simply include
driverChoice.h from Irrlicht's include directory. The function
driverChoiceConsole does exactly the same.
*/ */
// ask user for driver // ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
video::E_DRIVER_TYPE driverType; if (driverType==video::EDT_COUNT)
return 1;
printf("Please select the driver you want for this example:\n"\
" (a) OpenGL 1.5\n (b) Direct3D 9.0c\n"\
" (c) Burning's Software Renderer\n (d) Software Renderer\n"\
" (e) NullDevice\n (otherKey) exit\n\n");
char i;
std::cin >> i;
switch(i)
{
case 'a': driverType = video::EDT_OPENGL; break;
case 'b': driverType = video::EDT_DIRECT3D9;break;
case 'c': driverType = video::EDT_BURNINGSVIDEO;break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_NULL; break;
default: return 1;
}
// create device and exit if creation failed // create device and exit if creation failed
...@@ -97,7 +78,7 @@ int main() ...@@ -97,7 +78,7 @@ int main()
we are able to read from the files in that archive as if they are we are able to read from the files in that archive as if they are
directly stored on the disk. directly stored on the disk.
*/ */
device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3"); device->getFileSystem()->addFileArchive(getExampleMediaPath() + "map-20kdm2.pk3");
/* /*
Now we can load the mesh by calling Now we can load the mesh by calling
......
...@@ -19,6 +19,7 @@ and tell the linker to link with the .lib file. ...@@ -19,6 +19,7 @@ and tell the linker to link with the .lib file.
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -87,6 +88,8 @@ int main() ...@@ -87,6 +88,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
const io::path mediaPath = getExampleMediaPath();
/* /*
Create the node which will be moved with the WSAD keys. We create a Create the node which will be moved with the WSAD keys. We create a
sphere node, which is a built-in geometry primitive. We place the node sphere node, which is a built-in geometry primitive. We place the node
...@@ -98,7 +101,7 @@ int main() ...@@ -98,7 +101,7 @@ int main()
if (node) if (node)
{ {
node->setPosition(core::vector3df(0,0,30)); node->setPosition(core::vector3df(0,0,30));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp")); node->setMaterialTexture(0, driver->getTexture(mediaPath + "wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMaterialFlag(video::EMF_LIGHTING, false);
} }
...@@ -115,7 +118,7 @@ int main() ...@@ -115,7 +118,7 @@ int main()
if (n) if (n)
{ {
n->setMaterialTexture(0, driver->getTexture("../../media/t351sml.jpg")); n->setMaterialTexture(0, driver->getTexture(mediaPath + "t351sml.jpg"));
n->setMaterialFlag(video::EMF_LIGHTING, false); n->setMaterialFlag(video::EMF_LIGHTING, false);
scene::ISceneNodeAnimator* anim = scene::ISceneNodeAnimator* anim =
smgr->createFlyCircleAnimator(core::vector3df(0,0,30), 20.0f); smgr->createFlyCircleAnimator(core::vector3df(0,0,30), 20.0f);
...@@ -131,7 +134,7 @@ int main() ...@@ -131,7 +134,7 @@ int main()
a b3d model, which uses a 'fly straight' animator to run between to points. a b3d model, which uses a 'fly straight' animator to run between to points.
*/ */
scene::IAnimatedMeshSceneNode* anms = scene::IAnimatedMeshSceneNode* anms =
smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d")); smgr->addAnimatedMeshSceneNode(smgr->getMesh(mediaPath + "ninja.b3d"));
if (anms) if (anms)
{ {
...@@ -164,7 +167,7 @@ int main() ...@@ -164,7 +167,7 @@ int main()
anms->setScale(core::vector3df(2.f,2.f,2.f)); anms->setScale(core::vector3df(2.f,2.f,2.f));
anms->setRotation(core::vector3df(0,-90,0)); anms->setRotation(core::vector3df(0,-90,0));
// anms->setMaterialTexture(0, driver->getTexture("../../media/sydney.bmp")); // anms->setMaterialTexture(0, driver->getTexture(mediaPath + "sydney.bmp"));
} }
...@@ -180,7 +183,7 @@ int main() ...@@ -180,7 +183,7 @@ int main()
Add a colorful irrlicht logo Add a colorful irrlicht logo
*/ */
device->getGUIEnvironment()->addImage( device->getGUIEnvironment()->addImage(
driver->getTexture("../../media/irrlichtlogoalpha2.tga"), driver->getTexture(mediaPath + "irrlichtlogoalpha2.tga"),
core::position2d<s32>(10,20)); core::position2d<s32>(10,20));
gui::IGUIStaticText* diagnostics = device->getGUIEnvironment()->addStaticText( gui::IGUIStaticText* diagnostics = device->getGUIEnvironment()->addStaticText(
......
...@@ -12,6 +12,7 @@ and a pointer to a listbox. ...@@ -12,6 +12,7 @@ and a pointer to a listbox.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -209,6 +210,8 @@ int main() ...@@ -209,6 +210,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment(); IGUIEnvironment* env = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
/* /*
To make the font a little bit nicer, we load an external font To make the font a little bit nicer, we load an external font
and set it as the new default font in the skin. and set it as the new default font in the skin.
...@@ -217,7 +220,7 @@ int main() ...@@ -217,7 +220,7 @@ int main()
*/ */
IGUISkin* skin = env->getSkin(); IGUISkin* skin = env->getSkin();
IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp"); IGUIFont* font = env->getFont(mediaPath + "fonthaettenschweiler.bmp");
if (font) if (font)
skin->setFont(font); skin->setFont(font);
...@@ -275,7 +278,7 @@ int main() ...@@ -275,7 +278,7 @@ int main()
/* /*
And at last, we create a nice Irrlicht Engine logo in the top left corner. And at last, we create a nice Irrlicht Engine logo in the top left corner.
*/ */
env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"), env->addImage(driver->getTexture(mediaPath + "irrlichtlogo2.png"),
position2d<int>(10,10)); position2d<int>(10,10));
......
...@@ -11,6 +11,7 @@ and tell the linker to link with the .lib file. ...@@ -11,6 +11,7 @@ and tell the linker to link with the .lib file.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -41,6 +42,8 @@ int main() ...@@ -41,6 +42,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
const io::path mediaPath = getExampleMediaPath();
/* /*
All 2d graphics in this example are put together into one texture, All 2d graphics in this example are put together into one texture,
2ddemo.png. Because we want to draw colorkey based sprites, we need to 2ddemo.png. Because we want to draw colorkey based sprites, we need to
...@@ -54,7 +57,7 @@ int main() ...@@ -54,7 +57,7 @@ int main()
e.g. all black pixels transparent. Please note that e.g. all black pixels transparent. Please note that
makeColorKeyTexture just creates an alpha channel based on the color. makeColorKeyTexture just creates an alpha channel based on the color.
*/ */
video::ITexture* images = driver->getTexture("../../media/2ddemo.png"); video::ITexture* images = driver->getTexture(mediaPath + "2ddemo.png");
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0)); driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
/* /*
...@@ -66,7 +69,7 @@ int main() ...@@ -66,7 +69,7 @@ int main()
*/ */
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont(); gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
gui::IGUIFont* font2 = gui::IGUIFont* font2 =
device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp"); device->getGUIEnvironment()->getFont(mediaPath + "fonthaettenschweiler.bmp");
core::rect<s32> imp1(349,15,385,78); core::rect<s32> imp1(349,15,385,78);
core::rect<s32> imp2(387,15,423,78); core::rect<s32> imp2(387,15,423,78);
......
...@@ -12,6 +12,7 @@ following code starts up the engine and loads the level, as per tutorial 2. ...@@ -12,6 +12,7 @@ following code starts up the engine and loads the level, as per tutorial 2.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -53,7 +54,9 @@ int main() ...@@ -53,7 +54,9 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3"); const io::path mediaPath = getExampleMediaPath();
device->getFileSystem()->addFileArchive(mediaPath + "map-20kdm2.pk3");
scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp"); scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
scene::IMeshSceneNode* q3node = 0; scene::IMeshSceneNode* q3node = 0;
...@@ -153,7 +156,7 @@ int main() ...@@ -153,7 +156,7 @@ int main()
// Add the billboard. // Add the billboard.
scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode(); scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR ); bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
bill->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp")); bill->setMaterialTexture(0, driver->getTexture(mediaPath + "particle.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false); bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialFlag(video::EMF_ZBUFFER, false); bill->setMaterialFlag(video::EMF_ZBUFFER, false);
bill->setSize(core::dimension2d<f32>(20.0f, 20.0f)); bill->setSize(core::dimension2d<f32>(20.0f, 20.0f));
...@@ -167,13 +170,13 @@ int main() ...@@ -167,13 +170,13 @@ int main()
video::SMaterial material; video::SMaterial material;
// Add an MD2 node, which uses vertex-based animation. // Add an MD2 node, which uses vertex-based animation.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/faerie.md2"), node = smgr->addAnimatedMeshSceneNode(smgr->getMesh(mediaPath + "faerie.md2"),
0, IDFlag_IsPickable | IDFlag_IsHighlightable); 0, IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setPosition(core::vector3df(-90,-15,-140)); // Put its feet on the floor. node->setPosition(core::vector3df(-90,-15,-140)); // Put its feet on the floor.
node->setScale(core::vector3df(1.6f)); // Make it appear realistically scaled node->setScale(core::vector3df(1.6f)); // Make it appear realistically scaled
node->setMD2Animation(scene::EMAT_POINT); node->setMD2Animation(scene::EMAT_POINT);
node->setAnimationSpeed(20.f); node->setAnimationSpeed(20.f);
material.setTexture(0, driver->getTexture("../../media/faerie2.bmp")); material.setTexture(0, driver->getTexture(mediaPath + "faerie2.bmp"));
material.Lighting = true; material.Lighting = true;
material.NormalizeNormals = true; material.NormalizeNormals = true;
node->getMaterial(0) = material; node->getMaterial(0) = material;
...@@ -185,7 +188,7 @@ int main() ...@@ -185,7 +188,7 @@ int main()
selector->drop(); // We're done with this selector, so drop it now. selector->drop(); // We're done with this selector, so drop it now.
// And this B3D file uses skinned skeletal animation. // And this B3D file uses skinned skeletal animation.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"), node = smgr->addAnimatedMeshSceneNode(smgr->getMesh(mediaPath + "ninja.b3d"),
0, IDFlag_IsPickable | IDFlag_IsHighlightable); 0, IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setScale(core::vector3df(10)); node->setScale(core::vector3df(10));
node->setPosition(core::vector3df(-75,-66,-80)); node->setPosition(core::vector3df(-75,-66,-80));
...@@ -199,7 +202,7 @@ int main() ...@@ -199,7 +202,7 @@ int main()
selector->drop(); selector->drop();
// This X files uses skeletal animation, but without skinning. // This X files uses skeletal animation, but without skinning.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/dwarf.x"), node = smgr->addAnimatedMeshSceneNode(smgr->getMesh(mediaPath + "dwarf.x"),
0, IDFlag_IsPickable | IDFlag_IsHighlightable); 0, IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setPosition(core::vector3df(-70,-66,-30)); // Put its feet on the floor. node->setPosition(core::vector3df(-70,-66,-30)); // Put its feet on the floor.
node->setRotation(core::vector3df(0,-90,0)); // And turn it towards the camera. node->setRotation(core::vector3df(0,-90,0)); // And turn it towards the camera.
...@@ -211,7 +214,7 @@ int main() ...@@ -211,7 +214,7 @@ int main()
// And this mdl file uses skinned skeletal animation. // And this mdl file uses skinned skeletal animation.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/yodan.mdl"), node = smgr->addAnimatedMeshSceneNode(smgr->getMesh(mediaPath + "yodan.mdl"),
0, IDFlag_IsPickable | IDFlag_IsHighlightable); 0, IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setPosition(core::vector3df(-90,-25,20)); node->setPosition(core::vector3df(-90,-25,20));
node->setScale(core::vector3df(0.8f)); node->setScale(core::vector3df(0.8f));
......
...@@ -15,6 +15,7 @@ runs slow on your hardware. ...@@ -15,6 +15,7 @@ runs slow on your hardware.
#include <irrlicht.h> #include <irrlicht.h>
#include <iostream> #include <iostream>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -53,6 +54,8 @@ int main() ...@@ -53,6 +54,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
const io::path mediaPath = getExampleMediaPath();
/* /*
For our environment, we load a .3ds file. It is a small room I modelled For our environment, we load a .3ds file. It is a small room I modelled
with Anim8or and exported into the 3ds format because the Irrlicht with Anim8or and exported into the 3ds format because the Irrlicht
...@@ -67,14 +70,14 @@ int main() ...@@ -67,14 +70,14 @@ int main()
off too with this code. off too with this code.
*/ */
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/room.3ds"); scene::IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "room.3ds");
smgr->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.004f); smgr->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.004f);
scene::ISceneNode* node = 0; scene::ISceneNode* node = 0;
node = smgr->addAnimatedMeshSceneNode(mesh); node = smgr->addAnimatedMeshSceneNode(mesh);
node->setMaterialTexture(0, driver->getTexture("../../media/wall.jpg")); node->setMaterialTexture(0, driver->getTexture(mediaPath + "wall.jpg"));
node->getMaterial(0).SpecularColor.set(0,0,0,0); node->getMaterial(0).SpecularColor.set(0,0,0,0);
/* /*
...@@ -97,8 +100,8 @@ int main() ...@@ -97,8 +100,8 @@ int main()
node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f); node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
node->setPosition(core::vector3df(0,7,0)); node->setPosition(core::vector3df(0,7,0));
node->setMaterialTexture(0, driver->getTexture("../../media/stones.jpg")); node->setMaterialTexture(0, driver->getTexture(mediaPath + "stones.jpg"));
node->setMaterialTexture(1, driver->getTexture("../../media/water.jpg")); node->setMaterialTexture(1, driver->getTexture(mediaPath + "water.jpg"));
node->setMaterialType(video::EMT_REFLECTION_2_LAYER); node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
...@@ -123,7 +126,7 @@ int main() ...@@ -123,7 +126,7 @@ int main()
node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(50, 50)); node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(50, 50));
node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
node->setMaterialTexture(0, driver->getTexture("../../media/particlewhite.bmp")); node->setMaterialTexture(0, driver->getTexture(mediaPath + "particlewhite.bmp"));
/* /*
The next special effect is a lot more interesting: A particle system. The next special effect is a lot more interesting: A particle system.
...@@ -189,7 +192,7 @@ int main() ...@@ -189,7 +192,7 @@ int main()
ps->setScale(core::vector3df(2,2,2)); ps->setScale(core::vector3df(2,2,2));
ps->setMaterialFlag(video::EMF_LIGHTING, false); ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
ps->setMaterialTexture(0, driver->getTexture("../../media/fire.bmp")); ps->setMaterialTexture(0, driver->getTexture(mediaPath + "fire.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); ps->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
} }
...@@ -214,8 +217,8 @@ int main() ...@@ -214,8 +217,8 @@ int main()
core::array<video::ITexture*> textures; core::array<video::ITexture*> textures;
for (s32 g=7; g > 0; --g) for (s32 g=7; g > 0; --g)
{ {
core::stringc tmp; core::stringc tmp(mediaPath);
tmp = "../../media/portal"; tmp += "portal";
tmp += g; tmp += g;
tmp += ".bmp"; tmp += ".bmp";
video::ITexture* t = driver->getTexture( tmp.c_str() ); video::ITexture* t = driver->getTexture( tmp.c_str() );
...@@ -250,7 +253,7 @@ int main() ...@@ -250,7 +253,7 @@ int main()
// add animated character // add animated character
mesh = smgr->getMesh("../../media/dwarf.x"); mesh = smgr->getMesh(mediaPath + "dwarf.x");
scene::IAnimatedMeshSceneNode* anode = 0; scene::IAnimatedMeshSceneNode* anode = 0;
anode = smgr->addAnimatedMeshSceneNode(mesh); anode = smgr->addAnimatedMeshSceneNode(mesh);
......
...@@ -15,6 +15,7 @@ tutorial, we use a lot stuff from the gui namespace. ...@@ -15,6 +15,7 @@ tutorial, we use a lot stuff from the gui namespace.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
using namespace gui; using namespace gui;
...@@ -755,7 +756,7 @@ int main(int argc, char* argv[]) ...@@ -755,7 +756,7 @@ int main(int argc, char* argv[])
video::SColorf(1.0f,1.0f,1.0f),2000); video::SColorf(1.0f,1.0f,1.0f),2000);
smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f)); smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
// add our media directory as "search path" // add our media directory as "search path"
Device->getFileSystem()->addFileArchive("../../media/"); Device->getFileSystem()->addFileArchive(getExampleMediaPath());
/* /*
The next step is to read the configuration file. It is stored in the xml The next step is to read the configuration file. It is stored in the xml
......
...@@ -15,6 +15,7 @@ nearly all other tutorials: ...@@ -15,6 +15,7 @@ nearly all other tutorials:
#include <irrlicht.h> #include <irrlicht.h>
#include <iostream> #include <iostream>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -183,6 +184,8 @@ int main() ...@@ -183,6 +184,8 @@ int main()
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* gui = device->getGUIEnvironment(); gui::IGUIEnvironment* gui = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
/* /*
Now for the more interesting parts. If we are using Direct3D, we want Now for the more interesting parts. If we are using Direct3D, we want
to load vertex and pixel shader programs, if we have OpenGL, we want to to load vertex and pixel shader programs, if we have OpenGL, we want to
...@@ -203,26 +206,26 @@ int main() ...@@ -203,26 +206,26 @@ int main()
case video::EDT_DIRECT3D9: case video::EDT_DIRECT3D9:
if (UseHighLevelShaders) if (UseHighLevelShaders)
{ {
psFileName = "../../media/d3d9.hlsl"; psFileName = mediaPath + "d3d9.hlsl";
vsFileName = psFileName; // both shaders are in the same file vsFileName = psFileName; // both shaders are in the same file
} }
else else
{ {
psFileName = "../../media/d3d9.psh"; psFileName = mediaPath + "d3d9.psh";
vsFileName = "../../media/d3d9.vsh"; vsFileName = mediaPath + "d3d9.vsh";
} }
break; break;
case video::EDT_OPENGL: case video::EDT_OPENGL:
if (UseHighLevelShaders) if (UseHighLevelShaders)
{ {
psFileName = "../../media/opengl.frag"; psFileName = mediaPath + "opengl.frag";
vsFileName = "../../media/opengl.vert"; vsFileName = mediaPath + "opengl.vert";
} }
else else
{ {
psFileName = "../../media/opengl.psh"; psFileName = mediaPath + "opengl.psh";
vsFileName = "../../media/opengl.vsh"; vsFileName = mediaPath + "opengl.vsh";
} }
break; break;
} }
...@@ -335,7 +338,7 @@ int main() ...@@ -335,7 +338,7 @@ int main()
scene::ISceneNode* node = smgr->addCubeSceneNode(50); scene::ISceneNode* node = smgr->addCubeSceneNode(50);
node->setPosition(core::vector3df(0,0,0)); node->setPosition(core::vector3df(0,0,0));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp")); node->setMaterialTexture(0, driver->getTexture(mediaPath + "wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType1); node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType1);
...@@ -356,7 +359,7 @@ int main() ...@@ -356,7 +359,7 @@ int main()
node = smgr->addCubeSceneNode(50); node = smgr->addCubeSceneNode(50);
node->setPosition(core::vector3df(0,-10,50)); node->setPosition(core::vector3df(0,-10,50));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp")); node->setMaterialTexture(0, driver->getTexture(mediaPath + "wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialFlag(video::EMF_BLEND_OPERATION, true); node->setMaterialFlag(video::EMF_BLEND_OPERATION, true);
node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2); node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);
...@@ -378,7 +381,7 @@ int main() ...@@ -378,7 +381,7 @@ int main()
node = smgr->addCubeSceneNode(50); node = smgr->addCubeSceneNode(50);
node->setPosition(core::vector3df(0,50,25)); node->setPosition(core::vector3df(0,50,25));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp")); node->setMaterialTexture(0, driver->getTexture(mediaPath + "wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->addTextSceneNode(gui->getBuiltInFont(), L"NO SHADER", smgr->addTextSceneNode(gui->getBuiltInFont(), L"NO SHADER",
video::SColor(255,255,255,255), node); video::SColor(255,255,255,255), node);
...@@ -394,12 +397,12 @@ int main() ...@@ -394,12 +397,12 @@ int main()
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode( smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"), driver->getTexture(mediaPath + "irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"), driver->getTexture(mediaPath + "irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"), driver->getTexture(mediaPath + "irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"), driver->getTexture(mediaPath + "irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"), driver->getTexture(mediaPath + "irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg")); driver->getTexture(mediaPath + "irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true); driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
......
...@@ -10,6 +10,7 @@ nearly all other tutorials. ...@@ -10,6 +10,7 @@ nearly all other tutorials.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -38,7 +39,7 @@ public: ...@@ -38,7 +39,7 @@ public:
// set a nicer font // set a nicer font
gui::IGUISkin* skin = env->getSkin(); gui::IGUISkin* skin = env->getSkin();
gui::IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp"); gui::IGUIFont* font = env->getFont(getExampleMediaPath() + "fonthaettenschweiler.bmp");
if (font) if (font)
skin->setFont(font); skin->setFont(font);
...@@ -198,8 +199,10 @@ int main() ...@@ -198,8 +199,10 @@ int main()
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
const io::path mediaPath = getExampleMediaPath();
// add irrlicht logo // add irrlicht logo
env->addImage(driver->getTexture("../../media/irrlichtlogo3.png"), env->addImage(driver->getTexture(mediaPath + "irrlichtlogo3.png"),
core::position2d<s32>(10,10)); core::position2d<s32>(10,10));
// add camera // add camera
...@@ -228,7 +231,7 @@ int main() ...@@ -228,7 +231,7 @@ int main()
IMeshManipulator::makePlanarTextureMapping() method. IMeshManipulator::makePlanarTextureMapping() method.
*/ */
scene::IAnimatedMesh* roomMesh = smgr->getMesh("../../media/room.3ds"); scene::IAnimatedMesh* roomMesh = smgr->getMesh(mediaPath + "room.3ds");
scene::ISceneNode* room = 0; scene::ISceneNode* room = 0;
scene::ISceneNode* earth = 0; scene::ISceneNode* earth = 0;
...@@ -256,14 +259,14 @@ int main() ...@@ -256,14 +259,14 @@ int main()
*/ */
video::ITexture* normalMap = video::ITexture* normalMap =
driver->getTexture("../../media/rockwall_height.bmp"); driver->getTexture(mediaPath + "rockwall_height.bmp");
if (normalMap) if (normalMap)
driver->makeNormalMapTexture(normalMap, 9.0f); driver->makeNormalMapTexture(normalMap, 9.0f);
/* /*
// The Normal Map and the displacement map/height map in the alpha channel // The Normal Map and the displacement map/height map in the alpha channel
video::ITexture* normalMap = video::ITexture* normalMap =
driver->getTexture("../../media/rockwall_NRM.tga"); driver->getTexture(mediaPath + "rockwall_NRM.tga");
*/ */
/* /*
But just setting color and normal map is not everything. The But just setting color and normal map is not everything. The
...@@ -283,7 +286,7 @@ int main() ...@@ -283,7 +286,7 @@ int main()
room = smgr->addMeshSceneNode(tangentMesh); room = smgr->addMeshSceneNode(tangentMesh);
room->setMaterialTexture(0, room->setMaterialTexture(0,
driver->getTexture("../../media/rockwall.jpg")); driver->getTexture(mediaPath + "rockwall.jpg"));
room->setMaterialTexture(1, normalMap); room->setMaterialTexture(1, normalMap);
// Stones don't glitter.. // Stones don't glitter..
...@@ -311,7 +314,7 @@ int main() ...@@ -311,7 +314,7 @@ int main()
// add earth sphere // add earth sphere
scene::IAnimatedMesh* earthMesh = smgr->getMesh("../../media/earth.x"); scene::IAnimatedMesh* earthMesh = smgr->getMesh(mediaPath + "earth.x");
if (earthMesh) if (earthMesh)
{ {
//perform various task with the mesh manipulator //perform various task with the mesh manipulator
...@@ -334,7 +337,7 @@ int main() ...@@ -334,7 +337,7 @@ int main()
earth->setPosition(core::vector3df(-70,130,45)); earth->setPosition(core::vector3df(-70,130,45));
// load heightmap, create normal map from it and set it // load heightmap, create normal map from it and set it
video::ITexture* earthNormalMap = driver->getTexture("../../media/earthbump.jpg"); video::ITexture* earthNormalMap = driver->getTexture(mediaPath + "earthbump.jpg");
if (earthNormalMap) if (earthNormalMap)
{ {
driver->makeNormalMapTexture(earthNormalMap, 20.0f); driver->makeNormalMapTexture(earthNormalMap, 20.0f);
...@@ -381,7 +384,7 @@ int main() ...@@ -381,7 +384,7 @@ int main()
bill->setMaterialFlag(video::EMF_LIGHTING, false); bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("../../media/particlegreen.jpg")); bill->setMaterialTexture(0, driver->getTexture(mediaPath + "particlegreen.jpg"));
/* /*
Now the same again, with the second light. The difference is that we Now the same again, with the second light. The difference is that we
...@@ -412,7 +415,7 @@ int main() ...@@ -412,7 +415,7 @@ int main()
bill->setMaterialFlag(video::EMF_LIGHTING, false); bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("../../media/particlered.bmp")); bill->setMaterialTexture(0, driver->getTexture(mediaPath + "particlered.bmp"));
// add particle system // add particle system
scene::IParticleSystemSceneNode* ps = scene::IParticleSystemSceneNode* ps =
...@@ -439,7 +442,7 @@ int main() ...@@ -439,7 +442,7 @@ int main()
// adjust some material settings // adjust some material settings
ps->setMaterialFlag(video::EMF_LIGHTING, false); ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
ps->setMaterialTexture(0, driver->getTexture("../../media/fireball.bmp")); ps->setMaterialTexture(0, driver->getTexture(mediaPath + "fireball.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); ps->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
MyEventReceiver receiver(room, earth, env, driver); MyEventReceiver receiver(room, earth, env, driver);
......
...@@ -16,6 +16,7 @@ toggles between solid and detail mapped material. ...@@ -16,6 +16,7 @@ toggles between solid and detail mapped material.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -118,12 +119,14 @@ int main() ...@@ -118,12 +119,14 @@ int main()
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
const io::path mediaPath = getExampleMediaPath();
// add irrlicht logo // add irrlicht logo
env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"), env->addImage(driver->getTexture(mediaPath + "irrlichtlogo2.png"),
core::position2d<s32>(10,10)); core::position2d<s32>(10,10));
//set other font //set other font
env->getSkin()->setFont(env->getFont("../../media/fontlucida.png")); env->getSkin()->setFont(env->getFont(mediaPath + "fontlucida.png"));
// add some help text // add some help text
env->addStaticText( env->addStaticText(
...@@ -160,7 +163,7 @@ int main() ...@@ -160,7 +163,7 @@ int main()
// add terrain scene node // add terrain scene node
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode( scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"../../media/terrain-heightmap.bmp", mediaPath + "terrain-heightmap.bmp",
0, // parent node 0, // parent node
-1, // node id -1, // node id
core::vector3df(0.f, 0.f, 0.f), // position core::vector3df(0.f, 0.f, 0.f), // position
...@@ -175,9 +178,9 @@ int main() ...@@ -175,9 +178,9 @@ int main()
terrain->setMaterialFlag(video::EMF_LIGHTING, false); terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, terrain->setMaterialTexture(0,
driver->getTexture("../../media/terrain-texture.jpg")); driver->getTexture(mediaPath + "terrain-texture.jpg"));
terrain->setMaterialTexture(1, terrain->setMaterialTexture(1,
driver->getTexture("../../media/detailmap3.jpg")); driver->getTexture(mediaPath + "detailmap3.jpg"));
terrain->setMaterialType(video::EMT_DETAIL_MAP); terrain->setMaterialType(video::EMT_DETAIL_MAP);
...@@ -226,13 +229,13 @@ int main() ...@@ -226,13 +229,13 @@ int main()
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
scene::ISceneNode* skybox=smgr->addSkyBoxSceneNode( scene::ISceneNode* skybox=smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"), driver->getTexture(mediaPath + "irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"), driver->getTexture(mediaPath + "irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"), driver->getTexture(mediaPath + "irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"), driver->getTexture(mediaPath + "irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"), driver->getTexture(mediaPath + "irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg")); driver->getTexture(mediaPath + "irrlicht2_bk.jpg"));
scene::ISceneNode* skydome=smgr->addSkyDomeSceneNode(driver->getTexture("../../media/skydome.jpg"),16,8,0.95f,2.0f); scene::ISceneNode* skydome=smgr->addSkyDomeSceneNode(driver->getTexture(mediaPath + "skydome.jpg"),16,8,0.95f,2.0f);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true); driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
......
...@@ -10,6 +10,7 @@ for the rendering driver, create the Irrlicht Device: ...@@ -10,6 +10,7 @@ for the rendering driver, create the Irrlicht Device:
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -37,6 +38,8 @@ int main() ...@@ -37,6 +38,8 @@ int main()
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment(); gui::IGUIEnvironment* env = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
/* /*
Now, we load an animated mesh to be displayed. As in most examples, Now, we load an animated mesh to be displayed. As in most examples,
we'll take the fairy md2 model. The difference here: We set the we'll take the fairy md2 model. The difference here: We set the
...@@ -48,12 +51,12 @@ int main() ...@@ -48,12 +51,12 @@ int main()
// load and display animated fairy mesh // load and display animated fairy mesh
scene::IAnimatedMeshSceneNode* fairy = smgr->addAnimatedMeshSceneNode( scene::IAnimatedMeshSceneNode* fairy = smgr->addAnimatedMeshSceneNode(
smgr->getMesh("../../media/faerie.md2")); smgr->getMesh(mediaPath + "faerie.md2"));
if (fairy) if (fairy)
{ {
fairy->setMaterialTexture(0, fairy->setMaterialTexture(0,
driver->getTexture("../../media/faerie2.bmp")); // set diffuse texture driver->getTexture(mediaPath + "faerie2.bmp")); // set diffuse texture
fairy->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting fairy->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting
fairy->getMaterial(0).Shininess = 20.0f; // set size of specular highlights fairy->getMaterial(0).Shininess = 20.0f; // set size of specular highlights
fairy->setPosition(core::vector3df(-10,0,-100)); fairy->setPosition(core::vector3df(-10,0,-100));
...@@ -132,7 +135,7 @@ int main() ...@@ -132,7 +135,7 @@ int main()
{ {
// create problem text // create problem text
gui::IGUISkin* skin = env->getSkin(); gui::IGUISkin* skin = env->getSkin();
gui::IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp"); gui::IGUIFont* font = env->getFont(mediaPath + "fonthaettenschweiler.bmp");
if (font) if (font)
skin->setFont(font); skin->setFont(font);
......
...@@ -16,6 +16,7 @@ windows book for details. ...@@ -16,6 +16,7 @@ windows book for details.
#include <windows.h> // this example only runs with windows #include <windows.h> // this example only runs with windows
#include <iostream> #include <iostream>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -174,18 +175,20 @@ int main() ...@@ -174,18 +175,20 @@ int main()
scene::ISceneNode* cube = smgr->addCubeSceneNode(20); scene::ISceneNode* cube = smgr->addCubeSceneNode(20);
cube->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp")); const io::path mediaPath = getExampleMediaPath();
cube->setMaterialTexture(1, driver->getTexture("../../media/water.jpg"));
cube->setMaterialTexture(0, driver->getTexture(mediaPath + "wall.bmp"));
cube->setMaterialTexture(1, driver->getTexture(mediaPath + "water.jpg"));
cube->setMaterialFlag( video::EMF_LIGHTING, false ); cube->setMaterialFlag( video::EMF_LIGHTING, false );
cube->setMaterialType( video::EMT_REFLECTION_2_LAYER ); cube->setMaterialType( video::EMT_REFLECTION_2_LAYER );
smgr->addSkyBoxSceneNode( smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"), driver->getTexture(mediaPath + "irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"), driver->getTexture(mediaPath + "irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"), driver->getTexture(mediaPath + "irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"), driver->getTexture(mediaPath + "irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"), driver->getTexture(mediaPath + "irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg")); driver->getTexture(mediaPath + "irrlicht2_bk.jpg"));
// This shows that we can render to multiple windows within one application // This shows that we can render to multiple windows within one application
device->getGUIEnvironment()->addStaticText(core::stringw("Second screen render").c_str(),core::recti(0,0,200,200)); device->getGUIEnvironment()->addStaticText(core::stringw("Second screen render").c_str(),core::recti(0,0,200,200));
......
...@@ -12,6 +12,7 @@ Lets start: Create an Irrlicht device and setup the window. ...@@ -12,6 +12,7 @@ Lets start: Create an Irrlicht device and setup the window.
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -61,7 +62,7 @@ int main(int argc, char** argv) ...@@ -61,7 +62,7 @@ int main(int argc, char** argv)
if (argc>1) if (argc>1)
smgr->loadScene(argv[1]); smgr->loadScene(argv[1]);
else else
smgr->loadScene("../../media/example.irr"); smgr->loadScene(getExampleMediaPath() + "example.irr");
/* /*
Now we'll create a camera, and give it a collision response animator Now we'll create a camera, and give it a collision response animator
......
...@@ -10,6 +10,7 @@ to ask the user for a driver type using the console. ...@@ -10,6 +10,7 @@ to ask the user for a driver type using the console.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
/* /*
define which Quake3 Level should be loaded define which Quake3 Level should be loaded
...@@ -32,7 +33,7 @@ to ask the user for a driver type using the console. ...@@ -32,7 +33,7 @@ to ask the user for a driver type using the console.
#ifdef IRRLICHT_QUAKE3_ARENA #ifdef IRRLICHT_QUAKE3_ARENA
#define QUAKE3_STORAGE_FORMAT addFileArchive #define QUAKE3_STORAGE_FORMAT addFileArchive
#define QUAKE3_STORAGE_1 "../../media/map-20kdm2.pk3" #define QUAKE3_STORAGE_1 getExampleMediaPath() + "map-20kdm2.pk3"
#define QUAKE3_MAP_NAME "maps/20kdm2.bsp" #define QUAKE3_MAP_NAME "maps/20kdm2.bsp"
#endif #endif
...@@ -144,8 +145,10 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -144,8 +145,10 @@ int IRRCALLCONV main(int argc, char* argv[])
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* gui = device->getGUIEnvironment(); gui::IGUIEnvironment* gui = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
//! add our private media directory to the file system //! add our private media directory to the file system
device->getFileSystem()->addFileArchive("../../media/"); device->getFileSystem()->addFileArchive(mediaPath);
/* /*
To display the Quake 3 map, we first need to load it. Quake 3 maps To display the Quake 3 map, we first need to load it. Quake 3 maps
...@@ -211,7 +214,7 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -211,7 +214,7 @@ int IRRCALLCONV main(int argc, char* argv[])
const scene::IMesh * const additional_mesh = mesh->getMesh(quake3::E_Q3_MESH_ITEMS); const scene::IMesh * const additional_mesh = mesh->getMesh(quake3::E_Q3_MESH_ITEMS);
#ifdef SHOW_SHADER_NAME #ifdef SHOW_SHADER_NAME
gui::IGUIFont *font = device->getGUIEnvironment()->getFont("../../media/fontlucida.png"); gui::IGUIFont *font = device->getGUIEnvironment()->getFont(mediaPath + "fontlucida.png");
u32 count = 0; u32 count = 0;
#endif #endif
......
...@@ -12,6 +12,7 @@ nothing to say about it) ...@@ -12,6 +12,7 @@ nothing to say about it)
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "Irrlicht.lib")
...@@ -93,15 +94,17 @@ int main() ...@@ -93,15 +94,17 @@ int main()
ISceneManager *smgr = device->getSceneManager(); ISceneManager *smgr = device->getSceneManager();
IVideoDriver *driver = device->getVideoDriver(); IVideoDriver *driver = device->getVideoDriver();
const io::path mediaPath = getExampleMediaPath();
//Load model //Load model
IAnimatedMesh *model = smgr->getMesh("../../media/sydney.md2"); IAnimatedMesh *model = smgr->getMesh(mediaPath + "sydney.md2");
if (!model) if (!model)
return 1; return 1;
IAnimatedMeshSceneNode *model_node = smgr->addAnimatedMeshSceneNode(model); IAnimatedMeshSceneNode *model_node = smgr->addAnimatedMeshSceneNode(model);
//Load texture //Load texture
if (model_node) if (model_node)
{ {
ITexture *texture = driver->getTexture("../../media/sydney.bmp"); ITexture *texture = driver->getTexture(mediaPath + "sydney.bmp");
model_node->setMaterialTexture(0,texture); model_node->setMaterialTexture(0,texture);
model_node->setMD2Animation(scene::EMAT_RUN); model_node->setMD2Animation(scene::EMAT_RUN);
//Disable lighting (we've got no light) //Disable lighting (we've got no light)
...@@ -109,7 +112,7 @@ int main() ...@@ -109,7 +112,7 @@ int main()
} }
//Load map //Load map
device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3"); device->getFileSystem()->addFileArchive(mediaPath + "map-20kdm2.pk3");
IAnimatedMesh *map = smgr->getMesh("20kdm2.bsp"); IAnimatedMesh *map = smgr->getMesh("20kdm2.bsp");
if (map) if (map)
{ {
......
...@@ -8,6 +8,7 @@ node callbacks, are left out for simplicity of the example. ...@@ -8,6 +8,7 @@ node callbacks, are left out for simplicity of the example.
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -290,11 +291,13 @@ int main(int argumentCount, char * argumentValues[]) ...@@ -290,11 +291,13 @@ int main(int argumentCount, char * argumentValues[])
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* guienv = device->getGUIEnvironment(); gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
gui::IGUISkin* skin = guienv->getSkin(); gui::IGUISkin* skin = guienv->getSkin();
if (skin) if (skin)
{ {
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255)); skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
gui::IGUIFont* font = guienv->getFont("../../media/fontlucida.png"); gui::IGUIFont* font = guienv->getFont(mediaPath + "fontlucida.png");
if(font) if(font)
skin->setFont(font); skin->setFont(font);
} }
...@@ -325,21 +328,21 @@ Add several "zones". You could use this technique to light individual rooms, fo ...@@ -325,21 +328,21 @@ Add several "zones". You could use this technique to light individual rooms, fo
scene::IBillboardSceneNode * billboard = smgr->addBillboardSceneNode(node); scene::IBillboardSceneNode * billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(0, -14, 30)); billboard->setPosition(vector3df(0, -14, 30));
billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR ); billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
billboard->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp")); billboard->setMaterialTexture(0, driver->getTexture(mediaPath + "particle.bmp"));
billboard->setMaterialFlag(video::EMF_LIGHTING, false); billboard->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(1, 0, 0), lightRadius); smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(1, 0, 0), lightRadius);
billboard = smgr->addBillboardSceneNode(node); billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(-21, -14, -21)); billboard->setPosition(vector3df(-21, -14, -21));
billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR ); billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
billboard->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp")); billboard->setMaterialTexture(0, driver->getTexture(mediaPath + "particle.bmp"));
billboard->setMaterialFlag(video::EMF_LIGHTING, false); billboard->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(0, 1, 0), lightRadius); smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(0, 1, 0), lightRadius);
billboard = smgr->addBillboardSceneNode(node); billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(21, -14, -21)); billboard->setPosition(vector3df(21, -14, -21));
billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR ); billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
billboard->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp")); billboard->setMaterialTexture(0, driver->getTexture(mediaPath + "particle.bmp"));
billboard->setMaterialFlag(video::EMF_LIGHTING, false); billboard->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(0, 0, 1), lightRadius); smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(0, 0, 1), lightRadius);
......
...@@ -19,8 +19,9 @@ ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe ...@@ -19,8 +19,9 @@ ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe
Copyright 2006-2011 Burningwater, Thomas Alten Copyright 2006-2011 Burningwater, Thomas Alten
*/ */
#include "driverChoice.h"
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
#include "q3factory.h" #include "q3factory.h"
#include "sound.h" #include "sound.h"
...@@ -107,14 +108,16 @@ void GameData::setDefault () ...@@ -107,14 +108,16 @@ void GameData::setDefault ()
CurrentMapName = ""; CurrentMapName = "";
CurrentArchiveList.clear (); CurrentArchiveList.clear ();
const io::path mediaPath = getExampleMediaPath();
// Explorer Media directory // Explorer Media directory
CurrentArchiveList.push_back ( StartupDir + "../../media/" ); CurrentArchiveList.push_back ( StartupDir + mediaPath );
// Add the original quake3 files before you load your custom map // Add the original quake3 files before you load your custom map
// Most mods are using the original shaders, models&items&weapons // Most mods are using the original shaders, models&items&weapons
CurrentArchiveList.push_back("/q/baseq3/"); CurrentArchiveList.push_back("/q/baseq3/");
CurrentArchiveList.push_back(StartupDir + "../../media/map-20kdm2.pk3"); CurrentArchiveList.push_back(StartupDir + mediaPath + "map-20kdm2.pk3");
} }
/* /*
......
...@@ -14,6 +14,7 @@ You can move the camera while left-mouse button is clicked. ...@@ -14,6 +14,7 @@ You can move the camera while left-mouse button is clicked.
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
#include "main.h" #include "main.h"
using namespace irr; using namespace irr;
...@@ -674,7 +675,7 @@ bool CApp::init(int argc, char *argv[]) ...@@ -674,7 +675,7 @@ bool CApp::init(int argc, char *argv[])
// set a nicer font // set a nicer font
gui::IGUISkin* skin = guiEnv->getSkin(); gui::IGUISkin* skin = guiEnv->getSkin();
gui::IGUIFont* font = guiEnv->getFont("../../media/fonthaettenschweiler.bmp"); gui::IGUIFont* font = guiEnv->getFont(getExampleMediaPath() + "fonthaettenschweiler.bmp");
if (font) if (font)
skin->setFont(font); skin->setFont(font);
......
...@@ -6,6 +6,7 @@ It can also be used for experiments with the mouse in general. ...@@ -6,6 +6,7 @@ It can also be used for experiments with the mouse in general.
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -472,13 +473,15 @@ int main() ...@@ -472,13 +473,15 @@ int main()
SpriteBankIcons = env->addEmptySpriteBank(io::path("cursor_icons")); SpriteBankIcons = env->addEmptySpriteBank(io::path("cursor_icons"));
context.SpriteBox->setSpriteBank(SpriteBankIcons); context.SpriteBox->setSpriteBank(SpriteBankIcons);
const io::path mediaPath = getExampleMediaPath();
// create one animated icon from several files // create one animated icon from several files
array< io::path > files; array< io::path > files;
files.push_back( io::path("../../media/icon_crosshairs16x16bw1.png") ); files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw1.png") );
files.push_back( io::path("../../media/icon_crosshairs16x16bw2.png") ); files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw2.png") );
files.push_back( io::path("../../media/icon_crosshairs16x16bw3.png") ); files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw3.png") );
files.push_back( io::path("../../media/icon_crosshairs16x16bw3.png") ); files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw3.png") );
files.push_back( io::path("../../media/icon_crosshairs16x16bw2.png") ); files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw2.png") );
SCursorSprite spriteBw; // the sprite + some additional information needed for cursors SCursorSprite spriteBw; // the sprite + some additional information needed for cursors
spriteBw.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, files, 200 ); spriteBw.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, files, 200 );
spriteBw.SpriteBank = SpriteBankIcons; spriteBw.SpriteBank = SpriteBankIcons;
...@@ -493,7 +496,7 @@ int main() ...@@ -493,7 +496,7 @@ int main()
iconRects.push_back( rect<s32>(0,16, 16, 32) ); iconRects.push_back( rect<s32>(0,16, 16, 32) );
iconRects.push_back( rect<s32>(16,0, 32, 16) ); iconRects.push_back( rect<s32>(16,0, 32, 16) );
SCursorSprite spriteCol; // the sprite + some additional information needed for cursors SCursorSprite spriteCol; // the sprite + some additional information needed for cursors
spriteCol.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, io::path("../../media/icon_crosshairs16x16col.png"), iconRects, 200 ); spriteCol.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, io::path(mediaPath + "icon_crosshairs16x16col.png"), iconRects, 200 );
spriteCol.HotSpot = position2d<s32>(7,7); spriteCol.HotSpot = position2d<s32>(7,7);
spriteCol.SpriteBank = SpriteBankIcons; spriteCol.SpriteBank = SpriteBankIcons;
context.addIcon(L"crosshair_colored", spriteCol); context.addIcon(L"crosshair_colored", spriteCol);
...@@ -503,15 +506,15 @@ int main() ...@@ -503,15 +506,15 @@ int main()
SCursorSprite spriteNonAnimated(SpriteBankIcons, 0, position2d<s32>(7,7)); SCursorSprite spriteNonAnimated(SpriteBankIcons, 0, position2d<s32>(7,7));
rectIcon = rect<s32>(0,0, 16, 16); rectIcon = rect<s32>(0,0, 16, 16);
spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path("../../media/icon_crosshairs16x16col.png"), rectIcon ); spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path(mediaPath + "icon_crosshairs16x16col.png"), rectIcon );
context.addIcon(L"crosshair_col1", spriteNonAnimated, false); context.addIcon(L"crosshair_col1", spriteNonAnimated, false);
rectIcon = rect<s32>(16,0, 32, 16); rectIcon = rect<s32>(16,0, 32, 16);
spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path("../../media/icon_crosshairs16x16col.png"), rectIcon ); spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path(mediaPath + "icon_crosshairs16x16col.png"), rectIcon );
context.addIcon(L"crosshair_col2", spriteNonAnimated, false); context.addIcon(L"crosshair_col2", spriteNonAnimated, false);
rectIcon = rect<s32>(0,16, 16, 32); rectIcon = rect<s32>(0,16, 16, 32);
spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path("../../media/icon_crosshairs16x16col.png"), rectIcon ); spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path(mediaPath + "icon_crosshairs16x16col.png"), rectIcon );
context.addIcon(L"crosshair_col3", spriteNonAnimated, false); context.addIcon(L"crosshair_col3", spriteNonAnimated, false);
......
...@@ -10,6 +10,7 @@ can easily be integrated into own apps. ...@@ -10,6 +10,7 @@ can easily be integrated into own apps.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include "exampleHelper.h"
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -429,7 +430,7 @@ int main() ...@@ -429,7 +430,7 @@ int main()
// Try to load config. // Try to load config.
// I leave it as an exercise of the reader to store the configuration in the local application data folder, // I leave it as an exercise of the reader to store the configuration in the local application data folder,
// the only logical place to store config data for games. For all other operating systems I redirect to your manuals // the only logical place to store config data for games. For all other operating systems I redirect to your manuals
app.Settings = new SettingManager("../../media/settings.xml"); app.Settings = new SettingManager(getExampleMediaPath() + "settings.xml");
if ( !app.Settings->load() ) if ( !app.Settings->load() )
{ {
// ... // ...
......
...@@ -42,6 +42,7 @@ of the objects and camera. ...@@ -42,6 +42,7 @@ of the objects and camera.
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr; using namespace irr;
...@@ -102,6 +103,8 @@ int main() ...@@ -102,6 +103,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
const io::path mediaPath = getExampleMediaPath();
smgr->getGUIEnvironment()->addStaticText(L"Press Space to hide occluder.", core::recti(10,10, 200,50)); smgr->getGUIEnvironment()->addStaticText(L"Press Space to hide occluder.", core::recti(10,10, 200,50));
/* /*
...@@ -111,7 +114,7 @@ int main() ...@@ -111,7 +114,7 @@ int main()
if (node) if (node)
{ {
node->setPosition(core::vector3df(0,0,60)); node->setPosition(core::vector3df(0,0,60));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp")); node->setMaterialTexture(0, driver->getTexture(mediaPath + "wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMaterialFlag(video::EMF_LIGHTING, false);
} }
...@@ -124,7 +127,7 @@ int main() ...@@ -124,7 +127,7 @@ int main()
if (plane) if (plane)
{ {
plane->setMaterialTexture(0, driver->getTexture("../../media/t351sml.jpg")); plane->setMaterialTexture(0, driver->getTexture(mediaPath + "t351sml.jpg"));
plane->setMaterialFlag(video::EMF_LIGHTING, false); plane->setMaterialFlag(video::EMF_LIGHTING, false);
plane->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true); plane->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true);
} }
......
...@@ -53,6 +53,7 @@ collecting profiling information is disabled by default for speed reasons. ...@@ -53,6 +53,7 @@ collecting profiling information is disabled by default for speed reasons.
#include <irrlicht.h> #include <irrlicht.h>
#include "driverChoice.h" #include "driverChoice.h"
#include "exampleHelper.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "Irrlicht.lib")
...@@ -233,7 +234,7 @@ public: ...@@ -233,7 +234,7 @@ public:
*/ */
MY_PROFILE(CProfileScope p(L"dwarfes", L"grp switch scene");) MY_PROFILE(CProfileScope p(L"dwarfes", L"grp switch scene");)
scene::IAnimatedMesh* aniMesh = SceneManager->getMesh( "../../media/dwarf.x" ); scene::IAnimatedMesh* aniMesh = SceneManager->getMesh( getExampleMediaPath() + "dwarf.x" );
if (aniMesh) if (aniMesh)
{ {
scene::IMesh * mesh = aniMesh->getMesh (0); scene::IMesh * mesh = aniMesh->getMesh (0);
...@@ -336,10 +337,12 @@ int main() ...@@ -336,10 +337,12 @@ int main()
IGUIEnvironment* env = device->getGUIEnvironment(); IGUIEnvironment* env = device->getGUIEnvironment();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
const io::path mediaPath = getExampleMediaPath();
/* /*
A map we use for one of our test-scenes. A map we use for one of our test-scenes.
*/ */
device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3"); device->getFileSystem()->addFileArchive(mediaPath + "map-20kdm2.pk3");
MyEventReceiver receiver(smgr); MyEventReceiver receiver(smgr);
device->setEventReceiver(&receiver); device->setEventReceiver(&receiver);
...@@ -373,7 +376,7 @@ int main() ...@@ -373,7 +376,7 @@ int main()
/* /*
Get a monospaced font - it's nicer when working with rows of numbers. Get a monospaced font - it's nicer when working with rows of numbers.
*/ */
IGUIFont* font = env->getFont("../../media/fontcourier.bmp"); IGUIFont* font = env->getFont(mediaPath + "fontcourier.bmp");
if (font) if (font)
receiver.GuiProfiler->setOverrideFont(font); receiver.GuiProfiler->setOverrideFont(font);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// This file is not documented. // This file is not documented.
#include "CDemo.h" #include "CDemo.h"
#include "exampleHelper.h"
CDemo::CDemo(bool f, bool m, bool s, bool a, bool v, bool fsaa, video::E_DRIVER_TYPE d) CDemo::CDemo(bool f, bool m, bool s, bool a, bool v, bool fsaa, video::E_DRIVER_TYPE d)
: fullscreen(f), music(m), shadows(s), additive(a), vsync(v), aa(fsaa), : fullscreen(f), music(m), shadows(s), additive(a), vsync(v), aa(fsaa),
...@@ -59,14 +60,16 @@ void CDemo::run() ...@@ -59,14 +60,16 @@ void CDemo::run()
if (!device) if (!device)
return; return;
const io::path mediaPath = getExampleMediaPath();
if (device->getFileSystem()->existFile("irrlicht.dat")) if (device->getFileSystem()->existFile("irrlicht.dat"))
device->getFileSystem()->addFileArchive("irrlicht.dat"); device->getFileSystem()->addFileArchive("irrlicht.dat");
else else
device->getFileSystem()->addFileArchive("../../media/irrlicht.dat"); device->getFileSystem()->addFileArchive(mediaPath + "irrlicht.dat");
if (device->getFileSystem()->existFile("map-20kdm2.pk3")) if (device->getFileSystem()->existFile("map-20kdm2.pk3"))
device->getFileSystem()->addFileArchive("map-20kdm2.pk3"); device->getFileSystem()->addFileArchive("map-20kdm2.pk3");
else else
device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3"); device->getFileSystem()->addFileArchive(mediaPath + "map-20kdm2.pk3");
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
...@@ -405,16 +408,18 @@ void CDemo::loadSceneData() ...@@ -405,16 +408,18 @@ void CDemo::loadSceneData()
} }
} }
const io::path mediaPath = getExampleMediaPath();
// load sydney model and create 2 instances // load sydney model and create 2 instances
scene::IAnimatedMesh* mesh = 0; scene::IAnimatedMesh* mesh = 0;
mesh = sm->getMesh("../../media/sydney.md2"); mesh = sm->getMesh(mediaPath + "sydney.md2");
if (mesh) if (mesh)
{ {
model1 = sm->addAnimatedMeshSceneNode(mesh); model1 = sm->addAnimatedMeshSceneNode(mesh);
if (model1) if (model1)
{ {
model1->setMaterialTexture(0, driver->getTexture("../../media/spheremap.jpg")); model1->setMaterialTexture(0, driver->getTexture(mediaPath + "spheremap.jpg"));
model1->setPosition(core::vector3df(100,40,-80)); model1->setPosition(core::vector3df(100,40,-80));
model1->setScale(core::vector3df(2,2,2)); model1->setScale(core::vector3df(2,2,2));
model1->setMD2Animation(scene::EMAT_STAND); model1->setMD2Animation(scene::EMAT_STAND);
...@@ -430,7 +435,7 @@ void CDemo::loadSceneData() ...@@ -430,7 +435,7 @@ void CDemo::loadSceneData()
model2->setPosition(core::vector3df(180,15,-60)); model2->setPosition(core::vector3df(180,15,-60));
model2->setScale(core::vector3df(2,2,2)); model2->setScale(core::vector3df(2,2,2));
model2->setMD2Animation(scene::EMAT_RUN); model2->setMD2Animation(scene::EMAT_RUN);
model2->setMaterialTexture(0, device->getVideoDriver()->getTexture("../../media/sydney.bmp")); model2->setMaterialTexture(0, device->getVideoDriver()->getTexture(mediaPath + "sydney.bmp"));
model2->setMaterialFlag(video::EMF_LIGHTING, true); model2->setMaterialFlag(video::EMF_LIGHTING, true);
model2->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true); model2->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
model2->addShadowVolumeSceneNode(); model2->addShadowVolumeSceneNode();
...@@ -442,12 +447,12 @@ void CDemo::loadSceneData() ...@@ -442,12 +447,12 @@ void CDemo::loadSceneData()
// create sky box // create sky box
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
skyboxNode = sm->addSkyBoxSceneNode( skyboxNode = sm->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"), driver->getTexture(mediaPath + "irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"), driver->getTexture(mediaPath + "irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"), driver->getTexture(mediaPath + "irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"), driver->getTexture(mediaPath + "irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"), driver->getTexture(mediaPath + "irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg")); driver->getTexture(mediaPath + "irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true); driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
// create walk-between-portals animation // create walk-between-portals animation
...@@ -469,7 +474,7 @@ void CDemo::loadSceneData() ...@@ -469,7 +474,7 @@ void CDemo::loadSceneData()
core::array<video::ITexture*> textures; core::array<video::ITexture*> textures;
for (s32 g=1; g<8; ++g) for (s32 g=1; g<8; ++g)
{ {
core::stringc tmp("../../media/portal"); core::stringc tmp(mediaPath + "portal");
tmp += g; tmp += g;
tmp += ".bmp"; tmp += ".bmp";
video::ITexture* t = driver->getTexture( tmp ); video::ITexture* t = driver->getTexture( tmp );
...@@ -487,7 +492,7 @@ void CDemo::loadSceneData() ...@@ -487,7 +492,7 @@ void CDemo::loadSceneData()
bill = sm->addBillboardSceneNode(0, core::dimension2d<f32>(100,100), bill = sm->addBillboardSceneNode(0, core::dimension2d<f32>(100,100),
waypoint[r]+ core::vector3df(0,20,0)); waypoint[r]+ core::vector3df(0,20,0));
bill->setMaterialFlag(video::EMF_LIGHTING, false); bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialTexture(0, driver->getTexture("../../media/portal1.bmp")); bill->setMaterialTexture(0, driver->getTexture(mediaPath + "portal1.bmp"));
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->addAnimator(anim); bill->addAnimator(anim);
} }
...@@ -510,7 +515,7 @@ void CDemo::loadSceneData() ...@@ -510,7 +515,7 @@ void CDemo::loadSceneData()
bill = device->getSceneManager()->addBillboardSceneNode( bill = device->getSceneManager()->addBillboardSceneNode(
light, core::dimension2d<f32>(40,40)); light, core::dimension2d<f32>(40,40));
bill->setMaterialFlag(video::EMF_LIGHTING, false); bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialTexture(0, driver->getTexture("../../media/particlewhite.bmp")); bill->setMaterialTexture(0, driver->getTexture(mediaPath + "particlewhite.bmp"));
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
// create meta triangle selector with all triangles selectors in it. // create meta triangle selector with all triangles selectors in it.
...@@ -539,7 +544,7 @@ void CDemo::loadSceneData() ...@@ -539,7 +544,7 @@ void CDemo::loadSceneData()
campFire->setMaterialFlag(video::EMF_LIGHTING, false); campFire->setMaterialFlag(video::EMF_LIGHTING, false);
campFire->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); campFire->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
campFire->setMaterialTexture(0, driver->getTexture("../../media/fireball.bmp")); campFire->setMaterialTexture(0, driver->getTexture(mediaPath + "fireball.bmp"));
campFire->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); campFire->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
// load music // load music
...@@ -570,8 +575,10 @@ void CDemo::createLoadingScreen() ...@@ -570,8 +575,10 @@ void CDemo::createLoadingScreen()
inOutFader = device->getGUIEnvironment()->addInOutFader(); inOutFader = device->getGUIEnvironment()->addInOutFader();
inOutFader->setColor(backColor, video::SColor ( 0, 230, 230, 230 )); inOutFader->setColor(backColor, video::SColor ( 0, 230, 230, 230 ));
const io::path mediaPath = getExampleMediaPath();
// irrlicht logo // irrlicht logo
device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("../../media/irrlichtlogo2.png"), device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture(mediaPath + "irrlichtlogo2.png"),
core::position2d<s32>(5,5)); core::position2d<s32>(5,5));
// loading text // loading text
...@@ -588,7 +595,7 @@ void CDemo::createLoadingScreen() ...@@ -588,7 +595,7 @@ void CDemo::createLoadingScreen()
// load bigger font // load bigger font
device->getGUIEnvironment()->getSkin()->setFont( device->getGUIEnvironment()->getSkin()->setFont(
device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp")); device->getGUIEnvironment()->getFont(mediaPath + "fonthaettenschweiler.bmp"));
// set new font color // set new font color
...@@ -649,7 +656,7 @@ void CDemo::shoot() ...@@ -649,7 +656,7 @@ void CDemo::shoot()
core::dimension2d<f32>(25,25), start); core::dimension2d<f32>(25,25), start);
node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, device->getVideoDriver()->getTexture("../../media/fireball.bmp")); node->setMaterialTexture(0, device->getVideoDriver()->getTexture(getExampleMediaPath() + "fireball.bmp"));
node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
f32 length = (f32)(end - start).getLength(); f32 length = (f32)(end - start).getLength();
...@@ -716,7 +723,7 @@ void CDemo::createParticleImpacts() ...@@ -716,7 +723,7 @@ void CDemo::createParticleImpacts()
pas->setMaterialFlag(video::EMF_LIGHTING, false); pas->setMaterialFlag(video::EMF_LIGHTING, false);
pas->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); pas->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
pas->setMaterialTexture(0, device->getVideoDriver()->getTexture("../../media/smoke.bmp")); pas->setMaterialTexture(0, device->getVideoDriver()->getTexture(getExampleMediaPath() + "smoke.bmp"));
pas->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); pas->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
scene::ISceneNodeAnimator* anim = sm->createDeleteAnimator(2000); scene::ISceneNodeAnimator* anim = sm->createDeleteAnimator(2000);
...@@ -759,9 +766,11 @@ void CDemo::startIrrKlang() ...@@ -759,9 +766,11 @@ void CDemo::startIrrKlang()
if (!irrKlang) if (!irrKlang)
return; return;
const io::path mediaPath = getExampleMediaPath();
// play music // play music
irrklang::ISound* snd = irrKlang->play2D("../../media/IrrlichtTheme.ogg", true, false, true); irrklang::ISound* snd = irrKlang->play2D(mediaPath + "IrrlichtTheme.ogg", true, false, true);
if ( !snd ) if ( !snd )
snd = irrKlang->play2D("IrrlichtTheme.ogg", true, false, true); snd = irrKlang->play2D("IrrlichtTheme.ogg", true, false, true);
...@@ -773,8 +782,8 @@ void CDemo::startIrrKlang() ...@@ -773,8 +782,8 @@ void CDemo::startIrrKlang()
// preload both sound effects // preload both sound effects
ballSound = irrKlang->getSoundSource("../../media/ball.wav"); ballSound = irrKlang->getSoundSource(mediaPath + "ball.wav");
impactSound = irrKlang->getSoundSource("../../media/impact.wav"); impactSound = irrKlang->getSoundSource(mediaPath + "impact.wav");
} }
#endif #endif
...@@ -791,12 +800,14 @@ void CDemo::startSound() ...@@ -791,12 +800,14 @@ void CDemo::startSound()
if (Mix_OpenAudio(22050, AUDIO_S16, 2, 128)) if (Mix_OpenAudio(22050, AUDIO_S16, 2, 128))
return; return;
stream = Mix_LoadMUS("../../media/IrrlichtTheme.ogg"); const io::path mediaPath = getExampleMediaPath();
stream = Mix_LoadMUS(mediaPath + "IrrlichtTheme.ogg");
if (stream) if (stream)
Mix_PlayMusic(stream, -1); Mix_PlayMusic(stream, -1);
ballSound = Mix_LoadWAV("../../media/ball.wav"); ballSound = Mix_LoadWAV(mediaPath + "ball.wav");
impactSound = Mix_LoadWAV("../../media/impact.wav"); impactSound = Mix_LoadWAV(mediaPath + "impact.wav");
} }
void CDemo::playSound(Mix_Chunk *sample) void CDemo::playSound(Mix_Chunk *sample)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// This file is not documented. // This file is not documented.
#include "CMainMenu.h" #include "CMainMenu.h"
#include "exampleHelper.h"
...@@ -24,10 +25,12 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows, ...@@ -24,10 +25,12 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
MenuDevice = createDevice(driverType, MenuDevice = createDevice(driverType,
core::dimension2d<u32>(512, 384), 16, false, false, false, this); core::dimension2d<u32>(512, 384), 16, false, false, false, this);
const io::path mediaPath = getExampleMediaPath();
if (MenuDevice->getFileSystem()->existFile("irrlicht.dat")) if (MenuDevice->getFileSystem()->existFile("irrlicht.dat"))
MenuDevice->getFileSystem()->addFileArchive("irrlicht.dat"); MenuDevice->getFileSystem()->addFileArchive("irrlicht.dat");
else else
MenuDevice->getFileSystem()->addFileArchive("../../media/irrlicht.dat"); MenuDevice->getFileSystem()->addFileArchive(mediaPath + "irrlicht.dat");
video::IVideoDriver* driver = MenuDevice->getVideoDriver(); video::IVideoDriver* driver = MenuDevice->getVideoDriver();
scene::ISceneManager* smgr = MenuDevice->getSceneManager(); scene::ISceneManager* smgr = MenuDevice->getSceneManager();
...@@ -43,7 +46,7 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows, ...@@ -43,7 +46,7 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
newskin->drop(); newskin->drop();
// load font // load font
gui::IGUIFont* font = guienv->getFont("../../media/fonthaettenschweiler.bmp"); gui::IGUIFont* font = guienv->getFont(mediaPath + "fonthaettenschweiler.bmp");
if (font) if (font)
guienv->getSkin()->setFont(font); guienv->getSkin()->setFont(font);
...@@ -102,12 +105,12 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows, ...@@ -102,12 +105,12 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
// add md2 model // add md2 model
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2"); scene::IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "faerie.md2");
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh); scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
if (modelNode) if (modelNode)
{ {
modelNode->setPosition( core::vector3df(0.f, 0.f, -5.f) ); modelNode->setPosition( core::vector3df(0.f, 0.f, -5.f) );
modelNode->setMaterialTexture(0, driver->getTexture("../../media/faerie2.bmp")); modelNode->setMaterialTexture(0, driver->getTexture(mediaPath + "faerie2.bmp"));
modelNode->setMaterialFlag(video::EMF_LIGHTING, true); modelNode->setMaterialFlag(video::EMF_LIGHTING, true);
modelNode->getMaterial(0).Shininess = 50.f; modelNode->getMaterial(0).Shininess = 50.f;
modelNode->getMaterial(0).NormalizeNormals = true; modelNode->getMaterial(0).NormalizeNormals = true;
...@@ -168,7 +171,7 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows, ...@@ -168,7 +171,7 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
{ {
bill->setMaterialFlag(video::EMF_LIGHTING, false); bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("../../media/particlered.bmp")); bill->setMaterialTexture(0, driver->getTexture(mediaPath + "particlered.bmp"));
} }
// add fly circle animator to the light // add fly circle animator to the light
anim = smgr->createFlyCircleAnimator(core::vector3df(0.f,0.f,-5.f),20.f, anim = smgr->createFlyCircleAnimator(core::vector3df(0.f,0.f,-5.f),20.f,
...@@ -186,7 +189,7 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows, ...@@ -186,7 +189,7 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
{ {
bill->setMaterialFlag(video::EMF_LIGHTING, false); bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("../../media/portal1.bmp")); bill->setMaterialTexture(0, driver->getTexture(mediaPath + "portal1.bmp"));
} }
// add fly circle animator to the light // add fly circle animator to the light
anim = smgr->createFlyCircleAnimator(core::vector3df(0.f,0.f,-5.f),20.f, anim = smgr->createFlyCircleAnimator(core::vector3df(0.f,0.f,-5.f),20.f,
...@@ -209,10 +212,10 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows, ...@@ -209,10 +212,10 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
bool oldMipMapState = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); bool oldMipMapState = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
guienv->addImage(driver->getTexture("../../media/irrlichtlogo3.png"), guienv->addImage(driver->getTexture(mediaPath + "irrlichtlogo3.png"),
core::position2d<s32>(5,5)); core::position2d<s32>(5,5));
video::ITexture* irrlichtBack = driver->getTexture("../../media/demoback.jpg"); video::ITexture* irrlichtBack = driver->getTexture(mediaPath + "demoback.jpg");
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState);
......
// Copyright (C) 2015 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __EXAMPLE_HELPER_H_INCLUDED__
#define __EXAMPLE_HELPER_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "path.h"
namespace irr
{
static io::path getExampleMediaPath()
{
#if defined (_IRR_IPHONE_PLATFORM_) || defined (_IRR_ANDROID_PLATFORM_) || defined (_IRR_OSX_PLATFORM_)
return io::path("media/");
#else
return io::path("../../media/");
#endif
}
} // end namespace irr
#endif
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