Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
int main()
{
IrrlichtDevice *device =
createDevice(video::EDT_OPENGL, core::dimension2d<u32>(1280, 720));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
//device->getFileSystem()->addFileArchive("data/maps/map-20kdm2.pk3");
scene::IAnimatedMesh* mesh = smgr->getMesh("data/maps/wl/map.x");
scene::ISceneNode* node = 0;
if (mesh)
//node = smgr->addOctreeSceneNode(mesh->getMesh(0), 0, -1, 1024);
node = smgr->addMeshSceneNode(mesh->getMesh(0));
//if (node)
// node->setposition(core::vector3df(-1300, -144, -1249));
//! Key map added to allow multiple keys for actions such as
//! movement. ie Arrow keys & W,S,A,D.
SKeyMap keyMap[8];
keyMap[0].Action = EKA_MOVE_FORWARD;
keyMap[0].KeyCode = KEY_UP;
keyMap[1].Action = EKA_MOVE_FORWARD;
keyMap[1].KeyCode = KEY_KEY_W;
keyMap[2].Action = EKA_MOVE_BACKWARD;
keyMap[2].KeyCode = KEY_DOWN;
keyMap[3].Action = EKA_MOVE_BACKWARD;
keyMap[3].KeyCode = KEY_KEY_S;
keyMap[4].Action = EKA_STRAFE_LEFT;
keyMap[4].KeyCode = KEY_LEFT;
keyMap[5].Action = EKA_STRAFE_LEFT;
keyMap[5].KeyCode = KEY_KEY_A;
keyMap[6].Action = EKA_STRAFE_RIGHT;
keyMap[6].KeyCode = KEY_RIGHT;
keyMap[7].Action = EKA_STRAFE_RIGHT;
keyMap[7].KeyCode = KEY_KEY_D;
smgr->addCameraSceneNodeFPS(0, 100.0f, 0.5f, -1, keyMap, 8);
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
while (device->run())
{
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255, 200, 200, 200));
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
else
device->yield();
}
device->drop();
return 0;
}