#include <irrlicht.h>
#include <iostream>
using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
void main()
{
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) Direct3D 8.1\n"\
" (d) Burning's Software Renderer\n (e) Software Renderer\n"\
" (f) 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_DIRECT3D8;break;
case 'd': driverType = video::EDT_BURNINGSVIDEO;break;
case 'e': driverType = video::EDT_SOFTWARE; break;
case 'f': driverType = video::EDT_NULL; break;
default: return;
}
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(640, 480));
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
for (int i = -8; i < 8; i++)
{
for (int j = -8; j < 8; j++)
{
scene::IMeshSceneNode* n = smgr->addSphereSceneNode(10.0f);
n->setPosition(core::vector3df(i * 20.0f, j * 20.0f, 0));
}
}
scene::ILightSceneNode* lightNode = smgr->addLightSceneNode();
scene::ISceneNodeAnimator* lightAnimator = smgr->createFlyStraightAnimator(
core::vector3df(), // startPoint
core::vector3df(0, 0, -200.0f), // endPoint
2000, // timeForWay
true, // loop
true); // pingpong
lightNode->addAnimator(lightAnimator);
lightAnimator->drop();
smgr->addSphereSceneNode(2.0f, 10, lightNode)->setMaterialFlag(video::EMF_LIGHTING, false); // we add this to see the light source
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(-100, 0, -200));
while(device->run())
{
driver->beginScene(true, true, video::SColor(255, 0, 0, 64)); // we make a bit blue background to see all black objects
smgr->drawAll();
driver->endScene();
}
device->drop();
}
Users browsing this forum: No registered users and 1 guest