- 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
master
nadro 2015-09-24 22:44:32 +00:00
parent cacfc0a8b0
commit 02b49eea1b
26 changed files with 247 additions and 166 deletions

View File

@ -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.
*/
#include <irrlicht.h>
#include "exampleHelper.h"
/*
In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if
@ -152,6 +153,11 @@ int main()
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
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.
We only have to get the Mesh from the Scene Manager with getMesh() and add
@ -164,7 +170,7 @@ int main()
other supported file format. By the way, that cool Quake 2 model
called sydney was modelled by Brian Collins.
*/
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "sydney.md2");
if (!mesh)
{
device->drop();
@ -184,7 +190,7 @@ int main()
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
node->setMaterialTexture( 0, driver->getTexture(mediaPath + "sydney.bmp") );
}
/*

View File

@ -13,7 +13,8 @@ and an additional file to be able to ask the user for a driver type using the
console.
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
#include "exampleHelper.h"
/*
As already written in the HelloWorld example, in the Irrlicht Engine everything
@ -47,32 +48,12 @@ int main()
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
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
video::E_DRIVER_TYPE driverType;
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;
}
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device and exit if creation failed
@ -97,7 +78,7 @@ int main()
we are able to read from the files in that archive as if they are
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

View File

@ -19,6 +19,7 @@ and tell the linker to link with the .lib file.
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -87,6 +88,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
const io::path mediaPath = getExampleMediaPath();
/*
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
@ -98,7 +101,7 @@ int main()
if (node)
{
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);
}
@ -115,7 +118,7 @@ int main()
if (n)
{
n->setMaterialTexture(0, driver->getTexture("../../media/t351sml.jpg"));
n->setMaterialTexture(0, driver->getTexture(mediaPath + "t351sml.jpg"));
n->setMaterialFlag(video::EMF_LIGHTING, false);
scene::ISceneNodeAnimator* anim =
smgr->createFlyCircleAnimator(core::vector3df(0,0,30), 20.0f);
@ -131,7 +134,7 @@ int main()
a b3d model, which uses a 'fly straight' animator to run between to points.
*/
scene::IAnimatedMeshSceneNode* anms =
smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"));
smgr->addAnimatedMeshSceneNode(smgr->getMesh(mediaPath + "ninja.b3d"));
if (anms)
{
@ -164,7 +167,7 @@ int main()
anms->setScale(core::vector3df(2.f,2.f,2.f));
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()
Add a colorful irrlicht logo
*/
device->getGUIEnvironment()->addImage(
driver->getTexture("../../media/irrlichtlogoalpha2.tga"),
driver->getTexture(mediaPath + "irrlichtlogoalpha2.tga"),
core::position2d<s32>(10,20));
gui::IGUIStaticText* diagnostics = device->getGUIEnvironment()->addStaticText(

View File

@ -12,6 +12,7 @@ and a pointer to a listbox.
*/
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -209,6 +210,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
/*
To make the font a little bit nicer, we load an external font
and set it as the new default font in the skin.
@ -217,7 +220,7 @@ int main()
*/
IGUISkin* skin = env->getSkin();
IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
IGUIFont* font = env->getFont(mediaPath + "fonthaettenschweiler.bmp");
if (font)
skin->setFont(font);
@ -275,7 +278,7 @@ int main()
/*
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));

View File

@ -11,6 +11,7 @@ and tell the linker to link with the .lib file.
*/
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -41,6 +42,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver();
const io::path mediaPath = getExampleMediaPath();
/*
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
@ -54,7 +57,7 @@ int main()
e.g. all black pixels transparent. Please note that
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));
/*
@ -66,7 +69,7 @@ int main()
*/
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
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> imp2(387,15,423,78);

View File

@ -12,6 +12,7 @@ following code starts up the engine and loads the level, as per tutorial 2.
*/
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -53,7 +54,9 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver();
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::IMeshSceneNode* q3node = 0;
@ -153,7 +156,7 @@ int main()
// Add the billboard.
scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
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_ZBUFFER, false);
bill->setSize(core::dimension2d<f32>(20.0f, 20.0f));
@ -167,13 +170,13 @@ int main()
video::SMaterial material;
// 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);
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->setMD2Animation(scene::EMAT_POINT);
node->setAnimationSpeed(20.f);
material.setTexture(0, driver->getTexture("../../media/faerie2.bmp"));
material.setTexture(0, driver->getTexture(mediaPath + "faerie2.bmp"));
material.Lighting = true;
material.NormalizeNormals = true;
node->getMaterial(0) = material;
@ -185,7 +188,7 @@ int main()
selector->drop(); // We're done with this selector, so drop it now.
// 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);
node->setScale(core::vector3df(10));
node->setPosition(core::vector3df(-75,-66,-80));
@ -199,7 +202,7 @@ int main()
selector->drop();
// 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);
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.
@ -211,7 +214,7 @@ int main()
// 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);
node->setPosition(core::vector3df(-90,-25,20));
node->setScale(core::vector3df(0.8f));

View File

@ -15,6 +15,7 @@ runs slow on your hardware.
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -53,6 +54,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver();
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
with Anim8or and exported into the 3ds format because the Irrlicht
@ -67,14 +70,14 @@ int main()
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);
scene::ISceneNode* node = 0;
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);
/*
@ -97,8 +100,8 @@ int main()
node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
node->setPosition(core::vector3df(0,7,0));
node->setMaterialTexture(0, driver->getTexture("../../media/stones.jpg"));
node->setMaterialTexture(1, driver->getTexture("../../media/water.jpg"));
node->setMaterialTexture(0, driver->getTexture(mediaPath + "stones.jpg"));
node->setMaterialTexture(1, driver->getTexture(mediaPath + "water.jpg"));
node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
@ -123,7 +126,7 @@ int main()
node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(50, 50));
node->setMaterialFlag(video::EMF_LIGHTING, false);
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.
@ -189,7 +192,7 @@ int main()
ps->setScale(core::vector3df(2,2,2));
ps->setMaterialFlag(video::EMF_LIGHTING, 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);
}
@ -214,8 +217,8 @@ int main()
core::array<video::ITexture*> textures;
for (s32 g=7; g > 0; --g)
{
core::stringc tmp;
tmp = "../../media/portal";
core::stringc tmp(mediaPath);
tmp += "portal";
tmp += g;
tmp += ".bmp";
video::ITexture* t = driver->getTexture( tmp.c_str() );
@ -250,7 +253,7 @@ int main()
// add animated character
mesh = smgr->getMesh("../../media/dwarf.x");
mesh = smgr->getMesh(mediaPath + "dwarf.x");
scene::IAnimatedMeshSceneNode* anode = 0;
anode = smgr->addAnimatedMeshSceneNode(mesh);

View File

@ -15,6 +15,7 @@ tutorial, we use a lot stuff from the gui namespace.
*/
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
using namespace gui;
@ -755,7 +756,7 @@ int main(int argc, char* argv[])
video::SColorf(1.0f,1.0f,1.0f),2000);
smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
// 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

View File

@ -15,6 +15,7 @@ nearly all other tutorials:
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -183,6 +184,8 @@ int main()
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
/*
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
@ -203,26 +206,26 @@ int main()
case video::EDT_DIRECT3D9:
if (UseHighLevelShaders)
{
psFileName = "../../media/d3d9.hlsl";
psFileName = mediaPath + "d3d9.hlsl";
vsFileName = psFileName; // both shaders are in the same file
}
else
{
psFileName = "../../media/d3d9.psh";
vsFileName = "../../media/d3d9.vsh";
psFileName = mediaPath + "d3d9.psh";
vsFileName = mediaPath + "d3d9.vsh";
}
break;
case video::EDT_OPENGL:
if (UseHighLevelShaders)
{
psFileName = "../../media/opengl.frag";
vsFileName = "../../media/opengl.vert";
psFileName = mediaPath + "opengl.frag";
vsFileName = mediaPath + "opengl.vert";
}
else
{
psFileName = "../../media/opengl.psh";
vsFileName = "../../media/opengl.vsh";
psFileName = mediaPath + "opengl.psh";
vsFileName = mediaPath + "opengl.vsh";
}
break;
}
@ -335,7 +338,7 @@ int main()
scene::ISceneNode* node = smgr->addCubeSceneNode(50);
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->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType1);
@ -356,7 +359,7 @@ int main()
node = smgr->addCubeSceneNode(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_BLEND_OPERATION, true);
node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);
@ -378,7 +381,7 @@ int main()
node = smgr->addCubeSceneNode(50);
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);
smgr->addTextSceneNode(gui->getBuiltInFont(), L"NO SHADER",
video::SColor(255,255,255,255), node);
@ -394,12 +397,12 @@ int main()
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
driver->getTexture(mediaPath + "irrlicht2_up.jpg"),
driver->getTexture(mediaPath + "irrlicht2_dn.jpg"),
driver->getTexture(mediaPath + "irrlicht2_lf.jpg"),
driver->getTexture(mediaPath + "irrlicht2_rt.jpg"),
driver->getTexture(mediaPath + "irrlicht2_ft.jpg"),
driver->getTexture(mediaPath + "irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);

View File

@ -10,6 +10,7 @@ nearly all other tutorials.
*/
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -38,7 +39,7 @@ public:
// set a nicer font
gui::IGUISkin* skin = env->getSkin();
gui::IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
gui::IGUIFont* font = env->getFont(getExampleMediaPath() + "fonthaettenschweiler.bmp");
if (font)
skin->setFont(font);
@ -198,8 +199,10 @@ int main()
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
const io::path mediaPath = getExampleMediaPath();
// add irrlicht logo
env->addImage(driver->getTexture("../../media/irrlichtlogo3.png"),
env->addImage(driver->getTexture(mediaPath + "irrlichtlogo3.png"),
core::position2d<s32>(10,10));
// add camera
@ -228,7 +231,7 @@ int main()
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* earth = 0;
@ -256,14 +259,14 @@ int main()
*/
video::ITexture* normalMap =
driver->getTexture("../../media/rockwall_height.bmp");
driver->getTexture(mediaPath + "rockwall_height.bmp");
if (normalMap)
driver->makeNormalMapTexture(normalMap, 9.0f);
/*
// The Normal Map and the displacement map/height map in the alpha channel
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
@ -283,7 +286,7 @@ int main()
room = smgr->addMeshSceneNode(tangentMesh);
room->setMaterialTexture(0,
driver->getTexture("../../media/rockwall.jpg"));
driver->getTexture(mediaPath + "rockwall.jpg"));
room->setMaterialTexture(1, normalMap);
// Stones don't glitter..
@ -311,7 +314,7 @@ int main()
// add earth sphere
scene::IAnimatedMesh* earthMesh = smgr->getMesh("../../media/earth.x");
scene::IAnimatedMesh* earthMesh = smgr->getMesh(mediaPath + "earth.x");
if (earthMesh)
{
//perform various task with the mesh manipulator
@ -334,7 +337,7 @@ int main()
earth->setPosition(core::vector3df(-70,130,45));
// 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)
{
driver->makeNormalMapTexture(earthNormalMap, 20.0f);
@ -381,7 +384,7 @@ int main()
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
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
@ -412,7 +415,7 @@ int main()
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
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
scene::IParticleSystemSceneNode* ps =
@ -439,7 +442,7 @@ int main()
// adjust some material settings
ps->setMaterialFlag(video::EMF_LIGHTING, 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);
MyEventReceiver receiver(room, earth, env, driver);

View File

@ -16,6 +16,7 @@ toggles between solid and detail mapped material.
*/
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -118,12 +119,14 @@ int main()
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
const io::path mediaPath = getExampleMediaPath();
// add irrlicht logo
env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"),
env->addImage(driver->getTexture(mediaPath + "irrlichtlogo2.png"),
core::position2d<s32>(10,10));
//set other font
env->getSkin()->setFont(env->getFont("../../media/fontlucida.png"));
env->getSkin()->setFont(env->getFont(mediaPath + "fontlucida.png"));
// add some help text
env->addStaticText(
@ -160,7 +163,7 @@ int main()
// add terrain scene node
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"../../media/terrain-heightmap.bmp",
mediaPath + "terrain-heightmap.bmp",
0, // parent node
-1, // node id
core::vector3df(0.f, 0.f, 0.f), // position
@ -175,9 +178,9 @@ int main()
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0,
driver->getTexture("../../media/terrain-texture.jpg"));
driver->getTexture(mediaPath + "terrain-texture.jpg"));
terrain->setMaterialTexture(1,
driver->getTexture("../../media/detailmap3.jpg"));
driver->getTexture(mediaPath + "detailmap3.jpg"));
terrain->setMaterialType(video::EMT_DETAIL_MAP);
@ -226,13 +229,13 @@ int main()
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
scene::ISceneNode* skybox=smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
scene::ISceneNode* skydome=smgr->addSkyDomeSceneNode(driver->getTexture("../../media/skydome.jpg"),16,8,0.95f,2.0f);
driver->getTexture(mediaPath + "irrlicht2_up.jpg"),
driver->getTexture(mediaPath + "irrlicht2_dn.jpg"),
driver->getTexture(mediaPath + "irrlicht2_lf.jpg"),
driver->getTexture(mediaPath + "irrlicht2_rt.jpg"),
driver->getTexture(mediaPath + "irrlicht2_ft.jpg"),
driver->getTexture(mediaPath + "irrlicht2_bk.jpg"));
scene::ISceneNode* skydome=smgr->addSkyDomeSceneNode(driver->getTexture(mediaPath + "skydome.jpg"),16,8,0.95f,2.0f);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);

View File

@ -10,6 +10,7 @@ for the rendering driver, create the Irrlicht Device:
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -36,6 +37,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
/*
Now, we load an animated mesh to be displayed. As in most examples,
@ -48,12 +51,12 @@ int main()
// load and display animated fairy mesh
scene::IAnimatedMeshSceneNode* fairy = smgr->addAnimatedMeshSceneNode(
smgr->getMesh("../../media/faerie.md2"));
smgr->getMesh(mediaPath + "faerie.md2"));
if (fairy)
{
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->getMaterial(0).Shininess = 20.0f; // set size of specular highlights
fairy->setPosition(core::vector3df(-10,0,-100));
@ -132,7 +135,7 @@ int main()
{
// create problem text
gui::IGUISkin* skin = env->getSkin();
gui::IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
gui::IGUIFont* font = env->getFont(mediaPath + "fonthaettenschweiler.bmp");
if (font)
skin->setFont(font);

View File

@ -16,6 +16,7 @@ windows book for details.
#include <windows.h> // this example only runs with windows
#include <iostream>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -174,18 +175,20 @@ int main()
scene::ISceneNode* cube = smgr->addCubeSceneNode(20);
cube->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
cube->setMaterialTexture(1, driver->getTexture("../../media/water.jpg"));
const io::path mediaPath = getExampleMediaPath();
cube->setMaterialTexture(0, driver->getTexture(mediaPath + "wall.bmp"));
cube->setMaterialTexture(1, driver->getTexture(mediaPath + "water.jpg"));
cube->setMaterialFlag( video::EMF_LIGHTING, false );
cube->setMaterialType( video::EMT_REFLECTION_2_LAYER );
smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
driver->getTexture(mediaPath + "irrlicht2_up.jpg"),
driver->getTexture(mediaPath + "irrlicht2_dn.jpg"),
driver->getTexture(mediaPath + "irrlicht2_lf.jpg"),
driver->getTexture(mediaPath + "irrlicht2_rt.jpg"),
driver->getTexture(mediaPath + "irrlicht2_ft.jpg"),
driver->getTexture(mediaPath + "irrlicht2_bk.jpg"));
// 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));

View File

@ -12,6 +12,7 @@ Lets start: Create an Irrlicht device and setup the window.
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -61,7 +62,7 @@ int main(int argc, char** argv)
if (argc>1)
smgr->loadScene(argv[1]);
else
smgr->loadScene("../../media/example.irr");
smgr->loadScene(getExampleMediaPath() + "example.irr");
/*
Now we'll create a camera, and give it a collision response animator

View File

@ -10,6 +10,7 @@ to ask the user for a driver type using the console.
*/
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
/*
define which Quake3 Level should be loaded
@ -32,7 +33,7 @@ to ask the user for a driver type using the console.
#ifdef IRRLICHT_QUAKE3_ARENA
#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"
#endif
@ -144,8 +145,10 @@ int IRRCALLCONV main(int argc, char* argv[])
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
//! 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
@ -211,7 +214,7 @@ int IRRCALLCONV main(int argc, char* argv[])
const scene::IMesh * const additional_mesh = mesh->getMesh(quake3::E_Q3_MESH_ITEMS);
#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;
#endif

View File

@ -12,6 +12,7 @@ nothing to say about it)
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
@ -93,15 +94,17 @@ int main()
ISceneManager *smgr = device->getSceneManager();
IVideoDriver *driver = device->getVideoDriver();
const io::path mediaPath = getExampleMediaPath();
//Load model
IAnimatedMesh *model = smgr->getMesh("../../media/sydney.md2");
IAnimatedMesh *model = smgr->getMesh(mediaPath + "sydney.md2");
if (!model)
return 1;
IAnimatedMeshSceneNode *model_node = smgr->addAnimatedMeshSceneNode(model);
//Load texture
if (model_node)
{
ITexture *texture = driver->getTexture("../../media/sydney.bmp");
ITexture *texture = driver->getTexture(mediaPath + "sydney.bmp");
model_node->setMaterialTexture(0,texture);
model_node->setMD2Animation(scene::EMAT_RUN);
//Disable lighting (we've got no light)
@ -109,7 +112,7 @@ int main()
}
//Load map
device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3");
device->getFileSystem()->addFileArchive(mediaPath + "map-20kdm2.pk3");
IAnimatedMesh *map = smgr->getMesh("20kdm2.bsp");
if (map)
{

View File

@ -8,6 +8,7 @@ node callbacks, are left out for simplicity of the example.
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
using namespace core;
@ -290,11 +291,13 @@ int main(int argumentCount, char * argumentValues[])
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
const io::path mediaPath = getExampleMediaPath();
gui::IGUISkin* skin = guienv->getSkin();
if (skin)
{
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)
skin->setFont(font);
}
@ -325,21 +328,21 @@ Add several "zones". You could use this technique to light individual rooms, fo
scene::IBillboardSceneNode * billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(0, -14, 30));
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);
smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(1, 0, 0), lightRadius);
billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(-21, -14, -21));
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);
smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(0, 1, 0), lightRadius);
billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(21, -14, -21));
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);
smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(0, 0, 1), lightRadius);

View File

@ -19,8 +19,9 @@ ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe
Copyright 2006-2011 Burningwater, Thomas Alten
*/
#include "driverChoice.h"
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
#include "q3factory.h"
#include "sound.h"
@ -107,14 +108,16 @@ void GameData::setDefault ()
CurrentMapName = "";
CurrentArchiveList.clear ();
const io::path mediaPath = getExampleMediaPath();
// Explorer Media directory
CurrentArchiveList.push_back ( StartupDir + "../../media/" );
CurrentArchiveList.push_back ( StartupDir + mediaPath );
// Add the original quake3 files before you load your custom map
// Most mods are using the original shaders, models&items&weapons
CurrentArchiveList.push_back("/q/baseq3/");
CurrentArchiveList.push_back(StartupDir + "../../media/map-20kdm2.pk3");
CurrentArchiveList.push_back(StartupDir + mediaPath + "map-20kdm2.pk3");
}
/*

View File

@ -14,6 +14,7 @@ You can move the camera while left-mouse button is clicked.
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
#include "main.h"
using namespace irr;
@ -674,7 +675,7 @@ bool CApp::init(int argc, char *argv[])
// set a nicer font
gui::IGUISkin* skin = guiEnv->getSkin();
gui::IGUIFont* font = guiEnv->getFont("../../media/fonthaettenschweiler.bmp");
gui::IGUIFont* font = guiEnv->getFont(getExampleMediaPath() + "fonthaettenschweiler.bmp");
if (font)
skin->setFont(font);

View File

@ -6,6 +6,7 @@ It can also be used for experiments with the mouse in general.
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
using namespace core;
@ -472,13 +473,15 @@ int main()
SpriteBankIcons = env->addEmptySpriteBank(io::path("cursor_icons"));
context.SpriteBox->setSpriteBank(SpriteBankIcons);
const io::path mediaPath = getExampleMediaPath();
// create one animated icon from several files
array< io::path > files;
files.push_back( io::path("../../media/icon_crosshairs16x16bw1.png") );
files.push_back( io::path("../../media/icon_crosshairs16x16bw2.png") );
files.push_back( io::path("../../media/icon_crosshairs16x16bw3.png") );
files.push_back( io::path("../../media/icon_crosshairs16x16bw3.png") );
files.push_back( io::path("../../media/icon_crosshairs16x16bw2.png") );
files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw1.png") );
files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw2.png") );
files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw3.png") );
files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw3.png") );
files.push_back( io::path(mediaPath + "icon_crosshairs16x16bw2.png") );
SCursorSprite spriteBw; // the sprite + some additional information needed for cursors
spriteBw.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, files, 200 );
spriteBw.SpriteBank = SpriteBankIcons;
@ -493,7 +496,7 @@ int main()
iconRects.push_back( rect<s32>(0,16, 16, 32) );
iconRects.push_back( rect<s32>(16,0, 32, 16) );
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.SpriteBank = SpriteBankIcons;
context.addIcon(L"crosshair_colored", spriteCol);
@ -503,15 +506,15 @@ int main()
SCursorSprite spriteNonAnimated(SpriteBankIcons, 0, position2d<s32>(7,7));
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);
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);
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);

View File

@ -10,6 +10,7 @@ can easily be integrated into own apps.
*/
#include <irrlicht.h>
#include "exampleHelper.h"
using namespace irr;
using namespace core;
@ -429,7 +430,7 @@ int main()
// Try to load config.
// 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
app.Settings = new SettingManager("../../media/settings.xml");
app.Settings = new SettingManager(getExampleMediaPath() + "settings.xml");
if ( !app.Settings->load() )
{
// ...

View File

@ -42,6 +42,7 @@ of the objects and camera.
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
using namespace irr;
@ -102,6 +103,8 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver();
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));
/*
@ -111,7 +114,7 @@ int main()
if (node)
{
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);
}
@ -124,7 +127,7 @@ int main()
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_BACK_FACE_CULLING, true);
}

View File

@ -53,6 +53,7 @@ collecting profiling information is disabled by default for speed reasons.
#include <irrlicht.h>
#include "driverChoice.h"
#include "exampleHelper.h"
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
@ -233,7 +234,7 @@ public:
*/
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)
{
scene::IMesh * mesh = aniMesh->getMesh (0);
@ -336,10 +337,12 @@ int main()
IGUIEnvironment* env = device->getGUIEnvironment();
scene::ISceneManager* smgr = device->getSceneManager();
const io::path mediaPath = getExampleMediaPath();
/*
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);
device->setEventReceiver(&receiver);
@ -373,7 +376,7 @@ int main()
/*
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)
receiver.GuiProfiler->setOverrideFont(font);

View File

@ -2,6 +2,7 @@
// This file is not documented.
#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)
: fullscreen(f), music(m), shadows(s), additive(a), vsync(v), aa(fsaa),
@ -59,14 +60,16 @@ void CDemo::run()
if (!device)
return;
const io::path mediaPath = getExampleMediaPath();
if (device->getFileSystem()->existFile("irrlicht.dat"))
device->getFileSystem()->addFileArchive("irrlicht.dat");
else
device->getFileSystem()->addFileArchive("../../media/irrlicht.dat");
device->getFileSystem()->addFileArchive(mediaPath + "irrlicht.dat");
if (device->getFileSystem()->existFile("map-20kdm2.pk3"))
device->getFileSystem()->addFileArchive("map-20kdm2.pk3");
else
device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3");
device->getFileSystem()->addFileArchive(mediaPath + "map-20kdm2.pk3");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
@ -405,16 +408,18 @@ void CDemo::loadSceneData()
}
}
const io::path mediaPath = getExampleMediaPath();
// load sydney model and create 2 instances
scene::IAnimatedMesh* mesh = 0;
mesh = sm->getMesh("../../media/sydney.md2");
mesh = sm->getMesh(mediaPath + "sydney.md2");
if (mesh)
{
model1 = sm->addAnimatedMeshSceneNode(mesh);
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->setScale(core::vector3df(2,2,2));
model1->setMD2Animation(scene::EMAT_STAND);
@ -430,7 +435,7 @@ void CDemo::loadSceneData()
model2->setPosition(core::vector3df(180,15,-60));
model2->setScale(core::vector3df(2,2,2));
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_NORMALIZE_NORMALS, true);
model2->addShadowVolumeSceneNode();
@ -442,12 +447,12 @@ void CDemo::loadSceneData()
// create sky box
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
skyboxNode = sm->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
driver->getTexture(mediaPath + "irrlicht2_up.jpg"),
driver->getTexture(mediaPath + "irrlicht2_dn.jpg"),
driver->getTexture(mediaPath + "irrlicht2_lf.jpg"),
driver->getTexture(mediaPath + "irrlicht2_rt.jpg"),
driver->getTexture(mediaPath + "irrlicht2_ft.jpg"),
driver->getTexture(mediaPath + "irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
// create walk-between-portals animation
@ -469,7 +474,7 @@ void CDemo::loadSceneData()
core::array<video::ITexture*> textures;
for (s32 g=1; g<8; ++g)
{
core::stringc tmp("../../media/portal");
core::stringc tmp(mediaPath + "portal");
tmp += g;
tmp += ".bmp";
video::ITexture* t = driver->getTexture( tmp );
@ -487,7 +492,7 @@ void CDemo::loadSceneData()
bill = sm->addBillboardSceneNode(0, core::dimension2d<f32>(100,100),
waypoint[r]+ core::vector3df(0,20,0));
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->addAnimator(anim);
}
@ -510,7 +515,7 @@ void CDemo::loadSceneData()
bill = device->getSceneManager()->addBillboardSceneNode(
light, core::dimension2d<f32>(40,40));
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);
// create meta triangle selector with all triangles selectors in it.
@ -539,7 +544,7 @@ void CDemo::loadSceneData()
campFire->setMaterialFlag(video::EMF_LIGHTING, 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);
// load music
@ -570,8 +575,10 @@ void CDemo::createLoadingScreen()
inOutFader = device->getGUIEnvironment()->addInOutFader();
inOutFader->setColor(backColor, video::SColor ( 0, 230, 230, 230 ));
const io::path mediaPath = getExampleMediaPath();
// 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));
// loading text
@ -588,7 +595,7 @@ void CDemo::createLoadingScreen()
// load bigger font
device->getGUIEnvironment()->getSkin()->setFont(
device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp"));
device->getGUIEnvironment()->getFont(mediaPath + "fonthaettenschweiler.bmp"));
// set new font color
@ -649,7 +656,7 @@ void CDemo::shoot()
core::dimension2d<f32>(25,25), start);
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);
f32 length = (f32)(end - start).getLength();
@ -716,7 +723,7 @@ void CDemo::createParticleImpacts()
pas->setMaterialFlag(video::EMF_LIGHTING, 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);
scene::ISceneNodeAnimator* anim = sm->createDeleteAnimator(2000);
@ -759,9 +766,11 @@ void CDemo::startIrrKlang()
if (!irrKlang)
return;
const io::path mediaPath = getExampleMediaPath();
// 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 )
snd = irrKlang->play2D("IrrlichtTheme.ogg", true, false, true);
@ -773,8 +782,8 @@ void CDemo::startIrrKlang()
// preload both sound effects
ballSound = irrKlang->getSoundSource("../../media/ball.wav");
impactSound = irrKlang->getSoundSource("../../media/impact.wav");
ballSound = irrKlang->getSoundSource(mediaPath + "ball.wav");
impactSound = irrKlang->getSoundSource(mediaPath + "impact.wav");
}
#endif
@ -791,12 +800,14 @@ void CDemo::startSound()
if (Mix_OpenAudio(22050, AUDIO_S16, 2, 128))
return;
stream = Mix_LoadMUS("../../media/IrrlichtTheme.ogg");
const io::path mediaPath = getExampleMediaPath();
stream = Mix_LoadMUS(mediaPath + "IrrlichtTheme.ogg");
if (stream)
Mix_PlayMusic(stream, -1);
ballSound = Mix_LoadWAV("../../media/ball.wav");
impactSound = Mix_LoadWAV("../../media/impact.wav");
ballSound = Mix_LoadWAV(mediaPath + "ball.wav");
impactSound = Mix_LoadWAV(mediaPath + "impact.wav");
}
void CDemo::playSound(Mix_Chunk *sample)

View File

@ -2,6 +2,7 @@
// This file is not documented.
#include "CMainMenu.h"
#include "exampleHelper.h"
@ -24,10 +25,12 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
MenuDevice = createDevice(driverType,
core::dimension2d<u32>(512, 384), 16, false, false, false, this);
const io::path mediaPath = getExampleMediaPath();
if (MenuDevice->getFileSystem()->existFile("irrlicht.dat"))
MenuDevice->getFileSystem()->addFileArchive("irrlicht.dat");
else
MenuDevice->getFileSystem()->addFileArchive("../../media/irrlicht.dat");
MenuDevice->getFileSystem()->addFileArchive(mediaPath + "irrlicht.dat");
video::IVideoDriver* driver = MenuDevice->getVideoDriver();
scene::ISceneManager* smgr = MenuDevice->getSceneManager();
@ -43,7 +46,7 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
newskin->drop();
// load font
gui::IGUIFont* font = guienv->getFont("../../media/fonthaettenschweiler.bmp");
gui::IGUIFont* font = guienv->getFont(mediaPath + "fonthaettenschweiler.bmp");
if (font)
guienv->getSkin()->setFont(font);
@ -102,12 +105,12 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
// 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);
if (modelNode)
{
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->getMaterial(0).Shininess = 50.f;
modelNode->getMaterial(0).NormalizeNormals = true;
@ -168,7 +171,7 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
{
bill->setMaterialFlag(video::EMF_LIGHTING, false);
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
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,
{
bill->setMaterialFlag(video::EMF_LIGHTING, false);
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
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,
bool oldMipMapState = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
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));
video::ITexture* irrlichtBack = driver->getTexture("../../media/demoback.jpg");
video::ITexture* irrlichtBack = driver->getTexture(mediaPath + "demoback.jpg");
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState);

25
include/exampleHelper.h Executable file
View File

@ -0,0 +1,25 @@
// 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