Code: Select all
#include <irrlicht.h>
#include <iostream>
#include "game_manager.h"
using namespace std;
int main()
{
game_manager g_manager;
g_manager.CreateDevice();
g_manager.getirrDevice();
g_manager.getirrGUIEnvironment();
g_manager.getirrSceneManager();
g_manager.Init();
scene::IAnimatedMesh* q3levelmesh =g_manager.irrSceneManager->getMesh("20kdm2.bsp");
scene::ISceneNode* q3node = 0;
if (q3levelmesh)
q3node = g_manager.irrSceneManager->addOctTreeSceneNode(q3levelmesh->getMesh(0));
scene::ITriangleSelector* selector = 0;
if (q3node)
{
q3node->setPosition(core::vector3df(-1370,-130,-1400));
selector = g_manager.irrSceneManager->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector);
selector->drop();
}
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;
scene::ISceneNode* lightnode = 0;
lightnode = g_manager.irrSceneManager->addLightSceneNode(0,core::vector3df(10,15,0),video::SColorf(1,1,1,255),100.0f);
scene::ICameraSceneNode* camera = g_manager.irrSceneManager->addCameraSceneNodeFPS(0,100.0,500.0,-1,keyMap,8,false);
camera->setPosition(core::vector3df(-0,-0,-0));
g_manager.irrDevice->setResizeAble(true);
scene::IAnimatedMesh* weapon = g_manager.irrSceneManager->getMesh("gfx/uzi.3ds");
scene::IAnimatedMeshSceneNode* weaponnode = g_manager.irrSceneManager->addAnimatedMeshSceneNode(weapon,camera);
weaponnode->setMaterialFlag(video::EMF_LIGHTING, false);
weaponnode->setPosition(core::vector3df(50,-30,85));
weaponnode->setScale(core::vector3df(5,5,5));
g_manager.irrSceneManager->addSkyBoxSceneNode(
g_manager.irrVideoDriver->getTexture("gfx/nemesis_up.jpg"),0,
g_manager.irrVideoDriver->getTexture("gfx/nemesis_lf.jpg"),
g_manager.irrVideoDriver->getTexture("gfx/nemesis_rt.jpg"),
g_manager.irrVideoDriver->getTexture("gfx/nemesis_ft.jpg"),
g_manager.irrVideoDriver->getTexture("gfx/nemesis_bk.jpg"));
g_manager.irrVideoDriver->draw2DImage(g_manager.irrVideoDriver->getTexture("gfx/healthmeter.bmp"), core::position2d<s32>(468,350));
int lastFPS = -1;
int lastpoly = -1;
while(g_manager.irrDevice->run())
if (g_manager.irrDevice->isWindowActive())
{
g_manager.irrVideoDriver->beginScene(true, true,video::SColor(100,100,100,100));
g_manager.irrSceneManager->drawAll();
g_manager.irrVideoDriver->endScene();
int fps = g_manager.irrVideoDriver->getFPS();
int polydrawn = g_manager.irrVideoDriver->getPrimitiveCountDrawn();
if (lastFPS != fps)
{
core::stringw str = L"GAME DEMO - Irrlicht Engine [";
str += g_manager.irrVideoDriver->getName();
str += "] FPS:";
str += fps;
str += L"Polygon count";
str += polydrawn;
g_manager.irrDevice->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
g_manager.irrDevice->drop();
return 0;
}