Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
//Create Irrlicht, the driver, the scene manager, and triangle selectors
IrrlichtDevice *device =
createDevice(EDT_DIRECT3D9, dimension2d<s32>(512, 384), 32,
false, false, false, 0);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IMetaTriangleSelector* metaSelector;
ITriangleSelector* selector = 0;
// Create the meta selector
metaSelector = smgr->createMetaTriangleSelector();
//Hide the mouse
device->getCursorControl()->setVisible(false);
//The walls, ground
IAnimatedMesh* box = smgr->getMesh("../Amphitheatrum Flavium/media/Coliseum.b3d");
ISceneNode* node1 = 0;
if (box)
node1 = smgr->addOctTreeSceneNode(box->getMesh(0),0,-1,256,true);
if (node1)
{ // Create a Octree triangle selector
selector = smgr->createOctTreeTriangleSelector(box->getMesh(0), node1, 256);
node1->setTriangleSelector(selector);
// Then add it to the metaselector
metaSelector->addTriangleSelector(selector);
selector->drop();
}
//Skybox
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode(
driver->getTexture("../Amphitheatrum Flavium/media/irrlicht2_up.jpg"),
driver->getTexture("../Amphitheatrum Flavium/media/irrlicht2_dn.jpg"),
driver->getTexture("../Amphitheatrum Flavium/media/irrlicht2_lf.jpg"),
driver->getTexture("../Amphitheatrum Flavium/media/irrlicht2_rt.jpg"),
driver->getTexture("../Amphitheatrum Flavium/media/irrlicht2_ft.jpg"),
driver->getTexture("../Amphitheatrum Flavium/media/irrlicht2_bk.jpg"));
//The camera
ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,100.0f,2000.0f);
camera->setPosition(vector3df(0,50,0));
camera->setTarget(vector3df(2397*2,343*2,2700*2));
camera->setFarValue(20000.0f);
//Create response animator for the camera
ISceneNodeAnimatorCollisionResponse* animator;
animator = smgr->createCollisionResponseAnimator(
metaSelector, camera,
vector3df(10,45,10),
vector3df(0,0,0),
vector3df(0,24,0));
camera->addAnimator(animator);
animator->drop();
metaSelector->drop();
while(device->run())
{
driver->beginScene(true, true, SColor(0, 200, 200, 200));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}