void CIrrWindow::irrUpdate() { // draw document IVideoDriver* driver = m_driver; ISceneManager* smgr = m_smgr; // tick device m_device->getTimer()->tick(); // update particle m_particleObject->updateObject(); // draw 3d scene driver->beginScene( true, true, 0, getIView()->getVideoData() ); // draw all scene smgr->drawAll(); int fps = driver->getFPS(); core::stringw text(L"fps: "); text += fps; text += L" frame/second"; irr::gui::IGUIFont* font = smgr->getGUIEnvironment()->getBuiltInFont(); font->draw( text.c_str(), core::recti( 10, 10, 200, 20), video::SColor(255, 255,0,0) ); // end scene driver->endScene(); }
int main(int argc, char** argv) { IrrlichtDevice *device=createDevice(EDT_OPENGL,dimension2d<s32>(1024,600),16,false,false,false,0); device->setWindowCaption(L"FollowPathAnimator"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); smgr->loadScene("data/irrOdeMarble_level_.xml"); ICameraSceneNode *pCam=smgr->addCameraSceneNode(NULL,vector3df(0.0f,0.0f,0.0f),vector3df(1.0f,0.0f,0.0f)); CFollowPathAnimator *myAnimator=new CFollowPathAnimator(device,"pathToFollow",120,500); pCam->addAnimator(myAnimator); myAnimator->setCamParameter(pCam); while(device->run()) { driver->beginScene(true, true, SColor(0,200,200,200)); smgr->drawAll(); guienv->drawAll(); driver->endScene(); } device->drop(); return 0; }
static bool runTestWithDriver(E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(640, 480)); if (!device) return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); // Draw a cube to check that the pixels' alpha is working. ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60)); cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp")); cube->setMaterialFlag(video::EMF_LIGHTING, false); (void)smgr->addCameraSceneNode(); driver->beginScene(true, true, SColor(255,100,101,140)); smgr->drawAll(); // Test for offscreen values as well as onscreen. for(s32 x = -10; x < 650; ++x) { s32 y = 480 * x / 640; driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0)); y = 480 - y; driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255)); } driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.jpg"); device->drop(); return result; }
// drawDocument // draw documen by frame void CDocument::drawDocument() { // draw document IVideoDriver* driver = getIView()->getDriver(); ISceneManager* smgr = getIView()->getSceneMgr(); // draw 3d scene driver->beginScene( true, true, SColor(255,30,30,30), getIView()->getVideoData() ); // draw all scene smgr->drawAll(); // controller draw imp CControllerManager::getInstance()->getCurrentController()->render(); int fps = driver->getFPS(); core::stringw text(L"fps: "); text += fps; text += L" frame/second \n"; int primitiveDraw = driver->getPrimitiveCountDrawn(); text += L"primitive: "; text += primitiveDraw; irr::gui::IGUIFont* font = smgr->getGUIEnvironment()->getBuiltInFont(); font->draw( text.c_str(), core::recti( 10, 10, 200, 20), video::SColor(255, 255,0,0) ); // end scene driver->endScene(); }
/** Tests the Burning Video driver */ bool burningsVideo(void) { IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2di(160,120), 32); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); smgr->addCubeSceneNode(10.f, 0, -1, core::vector3df(0.f, 0.f, 20.f)); smgr->addCameraSceneNode(); // Test that ambient lighting works when there are no other lights in the scene smgr->setAmbientLight(video::SColorf(.7f, .1f, .1f, 1.f)); bool result = false; device->run(); if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80))) { smgr->drawAll(); driver->endScene(); result = takeScreenshotAndCompareAgainstReference(driver, "-ambient-lighting.png", 100); } device->drop(); return result; }
int main() { IrrlichtDevice* irrDevice = createDevice(EDT_OPENGL,dimension2d<s32>(800,600),32,false,false,false,0); IVideoDriver* irrVideo = irrDevice->getVideoDriver(); ISceneManager* irrSceneMgr = irrDevice->getSceneManager(); TMovie* movie = new TMovie(irrDevice->getTimer()); movie->LoadMovie("Mymovie.avi"); irrVideo->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); u32 w = movie->getMovieWidth(); u32 h = movie->getMovieHeight(); ITexture* movTxtr = irrVideo->addTexture(dimension2d<s32>(w<513?512:1024,h<513?512:1024),"imovie"); irrSceneMgr->addCameraSceneNode(0, vector3df(0,0,-20), vector3df(0,0,0)); CSampleSceneNode* myNode = new CSampleSceneNode(irrSceneMgr->getRootSceneNode(), irrSceneMgr, 666); myNode->setMaterialTexture( 0, movTxtr); myNode->drop(); ISceneNodeAnimator* anim = irrSceneMgr->createRotationAnimator(vector3df(0,0.1f,0)); myNode->addAnimator(anim); anim->drop(); while(irrDevice->run()) { irrVideo->beginScene(true, true, SColor(0,200,200,200)); if (movie->NextMovieFrame()) movie->DrawMovie(0,0,movTxtr); irrSceneMgr->drawAll(); irrVideo->endScene(); } irrDevice->drop(); return 0; }
int main() { IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(800, 600)); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); smgr->addCameraSceneNode(0, vector3df(0,10,-10), vector3df(0,5,0)); IAnimatedMesh* mesh = smgr->getMesh("ninja.b3d"); IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh); node->setMaterialFlag(EMF_LIGHTING, false); node->setMaterialTexture( 0, driver->getTexture("nskinrd.jpg") ); node->setRotation(vector3df(0,180,0)); // let ninja be in front to us node->setJointMode(EJUOR_CONTROL); // tell irrlicht that you want to control joint positions IBoneSceneNode* bone = node->getJointNode("Joint10"); // create IBoneSceneNode and select the desired bone while(device->run()) { bone->setRotation(bone->getRotation() + vector3df(1,0,0)); // rotate bone driver->beginScene(); smgr->drawAll(); driver->endScene(); } device->drop(); return 0; }
void Menu::Show() { using namespace gui; using namespace scene; // draw overlay menu IrrlichtDevice* device = Device::Instance().IrrlichtDevice(); gui::IGUIEnvironment* guiEnvironment = device->getGUIEnvironment(); // change event receiver irr::IEventReceiver* eventReceiverBackup = device->getEventReceiver(); device->setEventReceiver(this); guiEnvironment->addButton(core::recti(10,10,100,30), 0, GUI_ID_CONTINUE, L"Continue"); guiEnvironment->addButton(core::recti(10,40,100,60), 0, GUI_ID_EXIT, L"Exit"); video::IVideoDriver* driver = Device::Instance().Driver(); ISceneManager* sceneManager = Device::Instance().SceneManager(); isShowing_ = true; do { driver->beginScene(true, true, video::SColor(255,0,0,0)); sceneManager->drawAll(); guiEnvironment->drawAll(); driver->endScene(); }while(device->run() && isShowing_); // return event receiver device->setEventReceiver(eventReceiverBackup); }
int main() { IDevice* device = createDevice(EDT_DIRECT3D11, 800, 600); IVideoDriver* driver = device->getVideoDriver(); IResourceGroupManager* resourceGroupManager = driver->getResourceGroupManager(); resourceGroupManager->init("Resources.cfg"); IInputDriver* input = device->getInputDriver(); ISceneManager* smgr = setupScene(device); driver->setDeferredShading(true); ITimer* timer = device->getTimer(); timer->reset(); const f32 color[] = { 0, 0, 0, 1.0f }; while (device->run()) { float dt = timer->tick(); if (input->keyDown(GVK_ESCAPE)) break; smgr->update(dt); driver->beginScene(true, true, color); smgr->drawAll(); driver->endScene(); } smgr->destroy(); device->drop(); return 0; }
int main(int argc, char** argv) { IrrlichtDevice* device = createDevice(video::EDT_OPENGL, dimension2d<u32>(800, 600), 16, false, false, false, 0); if (!device) { return 1; } device->setWindowCaption(L"boxes"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IMeshSceneNode* cube = smgr->addCubeSceneNode(); smgr->addCameraSceneNode(0); while (device->run()) { driver->beginScene(); smgr->drawAll(); driver->endScene(); } return 0; }
int main() { IDevice* device = createDevice(EDT_DIRECT3D11, 800, 600); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->createSceneManager(); ITimer* timer = device->getTimer(); timer->reset(); // test XMFLOAT4 plane(0, 1.0f, 0, 0); XMFLOAT3 p(1.0f, 3.0f, -2.0f); XMFLOAT3 p2 = math::ComputeMirrorPointAboutPlane(plane, p); std::cout << p2.x << "," << p2.y << "," << p2.z << std::endl; const f32 color[] = { 0, 1.0f, 0, 1.0f }; while (device->run()) { driver->beginScene(true, true, color); float dt = timer->tick(); smgr->update(dt); smgr->drawAll(); driver->endScene(); } smgr->destroy(); device->drop(); return 0; }
int main() { // we'll use the OGL driver IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2du(640, 480), 16, false, false, false, 0); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); // load sydney IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2"); // squash her! CSquashingMeshSceneNode* node = new CSquashingMeshSceneNode( mesh->getMesh(0), 0, smgr, 0 ); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setPosition( vector3df(0,0,50)); node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") ); } smgr->addCameraSceneNodeFPS(); int lastFPS = -1; while(device->run()) { driver->beginScene(true, true, SColor(255,100,101,140)); node->render(); node->OnPostRender(device->getTimer()->getTime()); smgr->drawAll(); guienv->drawAll(); driver->endScene(); int fps = driver->getFPS(); if (lastFPS != fps) { core::stringw str = L"Irrlicht Mesh Deformation Contest ["; str += driver->getName(); str += "] FPS:"; str += fps; device->setWindowCaption(str.c_str()); lastFPS = fps; } } device->drop(); return 0; }
bool testTransparentVertexAlphaMore(E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice(driverType, dimension2d<u32>(160, 120)); if (!device) return true; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); if (driver->getColorFormat() != video::ECF_A8R8G8B8) { device->closeDevice(); device->run(); device->drop(); return true; } logTestString("Testing driver %ls\n", driver->getName()); IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2"); IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); IMeshSceneNode* cube = smgr->addCubeSceneNode(10.0f,0,-1,vector3df(-5,3,-15)); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setFrameLoop(0, 310); node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") ); } if (cube) { cube->getMaterial(0).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA; cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp")); cube->setMaterialFlag(EMF_LIGHTING, false); smgr->getMeshManipulator()->setVertexColorAlpha(cube->getMesh(),128); } // second cube without texture cube = smgr->addCubeSceneNode(10.0f,0,-1,vector3df(5,3,-15)); if (cube) { cube->getMaterial(0).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA; cube->setMaterialFlag(EMF_LIGHTING, false); smgr->getMeshManipulator()->setVertexColorAlpha(cube->getMesh(),128); } smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); driver->beginScene(true, true, SColor(0,200,200,200)); smgr->drawAll(); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentVertexAlphaChannelMore.png", 99.18f); device->closeDevice(); device->run(); device->drop(); return result; }
/** The result should be as follows: We have three times the same image, a billboard with a cube and the text in front. They are replicated three times, one centered in the screen without viewport, one in the upper left (qurter screen) and one on the right (half screen). The latter is stretched due to the changed aspect ratio. The two viewport scenes get the texture drawn over the center as well, using draw2dimage. This should mark the proper image position with the top left corner of the texture. Finally, each scene has a checkbox drawn at the left side, vertically centered. This will show whether GUI elements adhere to viewports as well. */ static bool viewPortText(E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32); if (!device) return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); IGUIEnvironment* env = smgr->getGUIEnvironment(); stabilizeScreenBackground(driver); env->addCheckBox(true, core::recti(10,60,28,82)); logTestString("Testing driver %ls\n", driver->getName()); IBillboardSceneNode * bnode = smgr->addBillboardSceneNode(0,dimension2d<f32>(32,32),core::vector3df(0,0,10)); bnode->setMaterialFlag(video::EMF_LIGHTING, false); bnode->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); bnode->setMaterialTexture(0, driver->getTexture("../media/fire.bmp")); smgr->addTextSceneNode(device->getGUIEnvironment()->getBuiltInFont(), L"TEST", video::SColor(255,255,255,255), 0); smgr->addCubeSceneNode(); smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140)); smgr->drawAll(); env->drawAll(); driver->setViewPort(rect<s32>(0,0,160/2,120/2)); smgr->drawAll(); env->drawAll(); driver->draw2DImage(driver->getTexture("../media/fire.bmp"), core::vector2di(160/2,120/2)); driver->setViewPort(rect<s32>(160/2,0,160,120)); smgr->drawAll(); env->drawAll(); driver->draw2DImage(driver->getTexture("../media/fire.bmp"), core::vector2di(160/2,120/2)); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-viewPortText.png", 98.71f); device->closeDevice(); device->run(); device->drop(); return result; }
int main() { int rows = 10, colums = 10; printf("Number of stack rows: "); cin >> rows; printf("\nNumber of stack colums: "); cin >> colums; CReceiver receiver; IrrlichtDevice *device = createDevice(EDT_DIRECT3D9, dimension2d<u32>(640, 480), 16, false, false, false, &receiver); IVideoDriver *driver = device->getVideoDriver(); ISceneManager *smgr = device->getSceneManager(); IGUIEnvironment *guienv = device->getGUIEnvironment(); device->setWindowCaption(L"HelloWorld"); irrBulletWorld * world = createIrrBulletWorld(device, true, true); world->setDebugMode(EPDM_DrawAabb | EPDM_DrawContactPoints); world->setGravity(core::vector3df(0, -10, 0)); createWorld(rows, colums, device, world); scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(); camera->setPosition(core::vector3df(50, 15, 200)); u32 then = device->getTimer()->getTime(); while (device->run()) { const u32 now = device->getTimer()->getTime(); const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // в секундах then = now; if (receiver.isMouseDown(EMIE_RMOUSE_PRESSED_DOWN)) { core::vector3df pos(camera->getPosition().X, camera->getPosition().Y, camera->getPosition().Z); scene::ISceneNode *Node = smgr->addCubeSceneNode(); Node->setScale(core::vector3df(0.2, 0.2, 0.2)); Node->setPosition(pos); Node->setMaterialFlag(video::EMF_LIGHTING, false); Node->setMaterialTexture(0, driver->getTexture("../rockwall.jpg")); ICollisionShape *shape = new IBoxShape(Node, 1, true); IRigidBody *body = world->addRigidBody(shape); body->setDamping(0.2, 0.2); body->setFriction(0.4f); body->setGravity(core::vector3df(0, -10, 0)); core::vector3df rot = camera->getRotation(); core::matrix4 mat; mat.setRotationDegrees(rot); core::vector3df forwardDir(core::vector3df(mat[8], mat[9], mat[10]) * 120); body->setLinearVelocity(forwardDir); } driver->beginScene(true, true, video::SColor(255, 100, 101, 140)); world->stepSimulation(frameDeltaTime, 120); world->debugDrawWorld(true); world->debugDrawProperties(true); smgr->drawAll(); guienv->drawAll(); driver->endScene(); if (world) delete world; device->drop(); return 0; } }
/** Verify that two skinned animated mesh scene nodes can use different frames of the skinned mesh */ bool b3dAnimation(void) { // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions. IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, dimension2d<s32>(160, 120), 32); assert(device); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); IAnimatedMesh* mesh = smgr->getMesh("../media/ninja.b3d"); IAnimatedMeshSceneNode* node1; IAnimatedMeshSceneNode* node2; assert(mesh); bool result = false; if(mesh) { node1 = smgr->addAnimatedMeshSceneNode(mesh); assert(node1); if(node1) { node1->setPosition(vector3df(-3, -3, 10)); node1->setMaterialFlag(EMF_LIGHTING, false); node1->setAnimationSpeed(0.f); } node2 = smgr->addAnimatedMeshSceneNode(mesh); assert(node2); if(node2) { node2->setPosition(vector3df(3, -3, 10)); node2->setMaterialFlag(EMF_LIGHTING, false); node2->setAnimationSpeed(0.f); node2->setCurrentFrame(62.f); } (void)smgr->addCameraSceneNode(); // Just jump to the last frame since that's all we're interested in. device->run(); driver->beginScene(true, true, SColor(255, 255, 255, 0)); smgr->drawAll(); driver->endScene(); result = takeScreenshotAndCompareAgainstReference(driver, "-b3dAnimation.png"); } device->drop(); return result; }
int main() { SDeviceContextSettings settings; settings.MultiSamplingCount = 4; settings.MultiSamplingQuality = 32; IApplication* device = createDevice(EDT_DIRECT3D11, 800, 600, EWS_NONE, true, settings); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->createSceneManager(); IMeshManager* meshManager = driver->getMeshManager(); IResourceGroupManager* resourceGroupManager = driver->getResourceGroupManager(); resourceGroupManager->init("Resources.cfg"); //resourceGroupManager->loadResourceGroup("General"); XMFLOAT3 vertices[4]; vertices[0] = XMFLOAT3(-10.0f, 0.0f, 10.0f); vertices[1] = XMFLOAT3(10.0f, 0.0f, 10.0f); vertices[2] = XMFLOAT3(-10.0f, 0.0f, -10.0f); vertices[3] = XMFLOAT3(10.0f, 0.0f, -10.0f); ISimpleMesh* mesh = meshManager->createSimpleMesh("pointlist", EVF_POSITION, vertices, NULL, 4, sizeof(XMFLOAT3), 0, math::SAxisAlignedBox(), false); IMeshNode* meshNode = smgr->addMeshNode(mesh, nullptr, nullptr); meshNode->setMaterialName("test/ts_material"); meshNode->setNeedCulling(false); ICameraNode* camera = smgr->addFpsCameraNode(1, nullptr, XMFLOAT3(0, 1.0f, -4.0f), XMFLOAT3(0, 1.0f, 0.0f)); char caption[200]; ITimer* timer = device->getTimer(); timer->reset(); while (device->run()) { const float clearColor[] = { 0.0f, 0.0f, 0.0f, 1.0f }; driver->beginScene(true, true, clearColor); float dt = timer->tick() * 0.001f; updateCamera(camera, dt); smgr->update(dt); smgr->drawAll(); driver->endScene(); sprintf(caption, "FPS:%f", getFps(dt)); device->setWindowCaption(caption); } device->drop(); return 0; }
//! Tests lightmaps under all drivers that support them static bool runTestWithDriver(E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32); if (!device) return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); logTestString("Testing driver %ls\n", driver->getName()); if (driver->getDriverAttributes().getAttributeAsInt("MaxTextures")<2) { device->closeDevice(); device->run(); device->drop(); return true; } stabilizeScreenBackground(driver); bool result = true; bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3"); assert_log(added); if(added) { ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024); assert_log(node); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setPosition(core::vector3df(-1300,-820,-1249)); node->setScale(core::vector3df(1, 5, 1)); (void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30)); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,255,255,0)); smgr->drawAll(); driver->endScene(); result = takeScreenshotAndCompareAgainstReference(driver, "-lightmaps.png", 96); } } device->closeDevice(); device->run(); device->drop(); return result; }
static bool loadScene(void) { IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2du(160,120), 32); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); // load scene from example, with correct relative path device->getFileSystem()->changeWorkingDirectoryTo("results"); smgr->loadScene("../../media/example.irr"); smgr->addCameraSceneNode(0, core::vector3df(0,0,-50)); device->getFileSystem()->changeWorkingDirectoryTo(".."); bool result = false; device->run(); device->getTimer()->setTime(666); // scene has animations and current scene seems to be saved at that time ... really - best result with just that number :-) if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80))) { smgr->drawAll(); driver->endScene(); // we need to be very sloppy, because the animators will produce a different // start depending on the actual loading time. 97% seems to be safe, as removing // an object produces values around 95% result = takeScreenshotAndCompareAgainstReference(driver, "-loadScene.png", 97.4f); if (!result) logTestString("Rendering the loaded scene failed.\n"); } ISceneNode* node = smgr->getSceneNodeFromId(128); if (!node) result=false; else if (result) // only check if scene was correctly loaded { result &= (node->getChildren().size()==0); if (!result) logTestString("Node has an illegal child node.\n"); device->getSceneManager()->loadScene("results/scene2.irr", 0, node); result &= (node->getChildren().size()!=0); if (!result) logTestString("Loading second scene as child failed.\n"); } device->closeDevice(); device->run(); device->drop(); return result; }
int main() { IrrlichtDevice *device = createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16, false, false, false, 0); if (!device) return 1; device->setWindowCaption(L"Have a go here: Chapter 3"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IAnimatedMesh* mesh = smgr->getMesh("/home/fuyajun/Documents/irrlicht-1.7.2/media/sydney.md2"); if (!mesh) { device->drop(); return 1; } IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); MyAnimationEndCallback animEndCallback; //连续动画 if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setMD2Animation(scene::EMAT_STAND); node->setMaterialTexture( 0, driver->getTexture("/home/fuyajun/Documents/irrlicht-1.7.2/media/sydney.bmp") ); node->setLoopMode(false); node->setAnimationEndCallback(&animEndCallback); } smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); while(device->run()) { driver->beginScene(true, true, SColor(255,100,101,140)); smgr->drawAll(); driver->endScene(); } device->drop(); return 0; }
/** Test the behaviour of makeColorKeyTexture() using both 16 bit (software) and 32 bit (Burning) textures, with the new behaviour and the legacy behaviour. */ static bool doTestWith(E_DRIVER_TYPE driverType, bool zeroTexels) { IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); // Draw a cube background so that we can check that the keying is working. ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60)); cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp")); cube->setMaterialFlag(video::EMF_LIGHTING, false); ITexture * Texture = device->getVideoDriver()->getTexture("../media/portal2.bmp"); device->getVideoDriver()->makeColorKeyTexture(Texture, position2d<s32>(64,64), zeroTexels); device->getVideoDriver()->makeColorKeyTexture(Texture, position2d<s32>(64,64), zeroTexels); (void)smgr->addCameraSceneNode(); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140)); smgr->drawAll(); driver->draw2DImage(Texture, position2di(40, 40), rect<s32>(0, 0, Texture->getSize().Width, Texture->getSize().Height), 0, SColor(255,255,255,255), true); driver->endScene(); char screenshotName[256]; (void)snprintf_irr(screenshotName, 256, "-makeColorKeyTexture-%s.png", zeroTexels? "old" : "new"); bool result = takeScreenshotAndCompareAgainstReference(driver, screenshotName); device->closeDevice(); device->run(); device->drop(); return result; }
/** * Irrlicht描画処理 * @param destRect 描画先領域 * @param srcRect 描画元領域 * @param destDC 描画先DC * @return 描画された */ bool IrrlichtBase::show(irr::core::rect<irr::s32> *destRect, irr::core::rect<irr::s32> *srcRect, HDC destDC) { if (device) { // 時間を進める XXX tick を外部から与えられないか? device->getTimer()->tick(); IVideoDriver *driver = device->getVideoDriver(); // 描画開始 if (driver && driver->beginScene(true, true, irr::video::SColor(0,0,0,0))) { if ((eventMask & EMASK_BEFORE_SCENE)) { sendTJSEvent(L"onBeforeScene"); } /// シーンマネージャの描画 ISceneManager *smgr = device->getSceneManager(); if (smgr) { smgr->drawAll(); } if ((eventMask & EMASK_AFTER_SCENE)) { sendTJSEvent(L"onAfterScene"); } // 固有処理 update(driver); if ((eventMask & EMASK_BEFORE_GUI)) { sendTJSEvent(L"onBeforeGUI"); } // GUIの描画 IGUIEnvironment *gui = device->getGUIEnvironment(); if (gui) { gui->drawAll(); } if ((eventMask & EMASK_AFTER_GUI)) { sendTJSEvent(L"onAfterGUI"); } // 描画完了 driver->endScene(0, srcRect, destRect, destDC); return true; } } return false; };
/* Ohjelman aloituspiste */ int main( int argc, char* argv[]) { //Alustetaan irrlicht device = createDevice(EDT_BURNINGSVIDEO, dimension2d<u32>(1024, 768), 16, false, false, false, 0); //ikkunan otsikko device->setWindowCaption(L"Dungeon."); //videoajuri ja scenemanager IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); //lisätään kamera smgr->addCameraSceneNode(0, vector3df(10,30,-5), vector3df(0,0,0)); //tilekartta Tile map = Tile(smgr); //lisätään valoa ILightSceneNode* light1 = smgr->addLightSceneNode(0, core::vector3df(0,5,0), video::SColorf(0.5f, 1.0f, 0.5f, 0.0f), 800.0f); /* Luodaan uusi gridi ja alustetaan se */ Generator grid; grid.initialize(); grid.generateDungeon(); cout << "Luolasto alustettu" << endl; //pääsilmukka pyörii niin kauan kun ikkuna on auki while(device->run()) { //aloitetaan scenen piirtäminen ja täytetään ruutu valitulla värillä if(driver->beginScene(true, true, SColor(255,100,101,140))) { //piirretään objektit smgr->drawAll(); //Lopetetaan scenen käsittely tältä kierrokselta driver->endScene(); } else { std::cout << "Could not begin scene." << std::endl; } } //heitetään pois kaikki mitä on ladattu device->drop(); return 0; }
int main() { IrrlichtDevice *device = createDevice( video::EDT_BURNINGSVIDEO, dimension2d<u32>(640, 480), 16, false, false, false, 0); if (!device) return 1; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); // Add Light to the Scene ILightSceneNode *light = smgr->addLightSceneNode( 0, vector3df() ); light->getLightData().AmbientColor = SColorf( 0.2f, 0.2f, 0.2f ); light->getLightData().SpecularColor = SColorf( 1.0f, 1.0f, 1.0f ); light->getLightData().DiffuseColor = SColorf( 0.8f, 0.8f, 0.8f ); light->setLightType( ELT_DIRECTIONAL ); light->setRotation( vector3df( 45.0f, 45.0f, 0.0f )); smgr->setAmbientLight( SColorf( 0.2f, 0.2f, 0.2f )); // scene::IMeshSceneNode* node = smgr->addCubeSceneNode(20); // if (node){ // node->setMaterialFlag(EMF_LIGHTING, false); // smgr->getMeshManipulator()->setVertexColors(node->getMesh(),SColor(250,250,0,0)); // node->setPosition(core::vector3df(0,0,0) ); // node->setVisible(false); // } smgr->addCameraSceneNode(0, vector3df(0,0,-50), vector3df(0,0,0)); while(device->run()) { core::aabbox3df box; box.MinEdge.set(vector3df(-100,-100,-100)); box.MaxEdge.set(vector3df(100,100,100)); driver->beginScene(true, true, SColor(250, 100, 150, 150)); smgr->drawAll(); guienv->drawAll(); criaGizmosBicos(driver); // criaRegiaAnalise(box, driver); driver->endScene(); } device->drop(); return 0; }
/** Tests the offset capability of the fly circle animator */ bool flyCircleAnimator(void) { IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2du(160,120), 32); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); const f32 offsetDegrees[] = { 0.f, 45.f, 135.f, 270.f }; for(u32 i = 0; i < sizeof(offsetDegrees) / sizeof(offsetDegrees[0]); ++i) { IBillboardSceneNode * node = smgr->addBillboardSceneNode(); // Have the animator rotate around the Z axis plane, rather than the default Y axis ISceneNodeAnimator * animator = smgr->createFlyCircleAnimator( vector3df(0, 0, 0), 30.f, 0.001f, vector3df(0, 0, 1), (offsetDegrees[i] / 360.f)); if(!node || !animator) return false; node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR ); node->setMaterialTexture(0, driver->getTexture("../media/particle.bmp")); node->setMaterialFlag(video::EMF_LIGHTING, false); node->addAnimator(animator); animator->drop(); } (void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50), vector3df(0, 0, 0)); bool result = false; // Don't do device->run() since I need the time to remain at 0. if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80))) { smgr->drawAll(); driver->endScene(); result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png", 100); } device->closeDevice(); device->run(); device->drop(); return result; }
//! Tests the basic functionality of the software device. bool softwareDevice(void) { IrrlichtDevice *device = createDevice(video::EDT_SOFTWARE, dimension2d<u32>(160, 120), 32); if (!device) return false; video::IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); // Test a particular rotation that highlighted a clipping issue from matrix::transformPlane() video::S3DVertex vertices[3]; vertices[0] = video::S3DVertex(10,0,-10, 1,0,0, video::SColor(255,255,0,255), 1, 1); vertices[1] = video::S3DVertex(0,20,0, 0,1,1, video::SColor(255,255,255,0), 1, 0); vertices[2] = video::S3DVertex(-10,0,-10, 0,0,1, video::SColor(255,0,255,0), 0, 0); video::SMaterial material; material.Lighting = false; material.Wireframe = false; const u16 indices[] = { 1,0,2, }; matrix4 transform(matrix4::EM4CONST_IDENTITY); vector3df rotations(290, 0, 290); // <-- This rotation used to clip the triangle incorrectly transform.setRotationDegrees(rotations); (void)smgr->addCameraSceneNode(0, core::vector3df(0,0,-40), core::vector3df(0,0,0)); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,255,255,0)); smgr->drawAll(); driver->setMaterial(material); driver->setTransform(video::ETS_WORLD, transform); driver->drawIndexedTriangleList(&vertices[0], 3, &indices[0], 1); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-softwareDevice-rotatedClip.png"); device->closeDevice(); device->run(); device->drop(); return result; }
int main() { eventReceiver receiver; IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(1366, 768), 16,true, false, false,&receiver); device->setWindowCaption(L"(WhizGeek || Mclightning).com"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); scene::ICameraSceneNode* kam= smgr->addCameraSceneNode(NULL,vector3df(0,0,200),vector3df(0,0,0)); //kam->setPosition(vector3df(0,0,200)); ISceneNode* kutu=smgr->addCubeSceneNode(50,0,2,vector3df(50,0,0)); ISceneNode* kutu2=smgr->addCubeSceneNode(50,0,2,vector3df(-50,0,0)); ITexture *duvar=driver->getTexture("wall.jpg"); kutu->setMaterialTexture(0,duvar); kutu->setMaterialFlag(video::EMF_LIGHTING, false); kutu2->setMaterialTexture(0,duvar); kutu2->setMaterialFlag(video::EMF_LIGHTING, false); IAnimatedMesh* mesh = smgr->getMesh("sydney.md2"); IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); node->setMaterialFlag(EMF_LIGHTING, false); node->setMD2Animation(scene::EMAT_STAND); node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") ); node->setRotation(vector3df(0,270,0)); irFinder ir("test",true,230,255); CvPoint in; while(device->run()) { if(receiver.IsKeyDown(KEY_ESCAPE)) { device->drop(); return 0; } driver->beginScene(true, true, SColor(255,0,0,255)); in=ir.yenile(); //node->setPosition(vector3df(30*in.x/320,30*(240-in.y)/240,0)); kam->setPosition(vector3df(in.x-160,(240-in.y),200)); smgr->drawAll(); driver->endScene(); } device->drop(); }
int main() { IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16, false, false, false, 0); if (!device) cout<<"error"; else { device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", rect<s32>(10,10,260,22), true); IAnimatedMesh* mesh = smgr->getMesh("sydney.md2"); if (!mesh) { device->drop(); return 1; } IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setMD2Animation(scene::EMAT_STAND); node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") ); } smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); while(device->run()) { driver->beginScene(true, true, SColor(255,100,101,140)); smgr->drawAll(); guienv->drawAll(); driver->endScene(); } device->drop(); } cout<<"hello world2"; }
/** At the moment, this just verifies that the last frame of the animation produces the expected bitmap. */ bool md2Animation(void) { // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions. IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32); assert(device); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2"); IAnimatedMeshSceneNode* node; assert(mesh); if(mesh) { node = smgr->addAnimatedMeshSceneNode(mesh); assert(node); if(node) { node->setPosition(vector3df(20, 0, 30)); node->setMaterialFlag(EMF_LIGHTING, false); node->setMaterialTexture(0, driver->getTexture("../media/sydney.bmp")); node->setLoopMode(false); (void)smgr->addCameraSceneNode(); // Just jump to the last frame since that's all we're interested in. node->setMD2Animation(EMAT_DEATH_FALLBACK); node->setCurrentFrame((f32)(node->getEndFrame())); device->run(); driver->beginScene(true, true, SColor(255, 255, 255, 0)); smgr->drawAll(); driver->endScene(); } } bool result = takeScreenshotAndCompareAgainstReference(driver, "-md2Animation.png"); device->drop(); return result; }
int main() { MyEventReceiver receiver; IrrlichtDevice* device = createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640, 480), 16, false, false, false, &receiver); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); smgr->addLightSceneNode(0,vector3df(50,50,50)); ICameraSceneNode *camera = smgr->addCameraSceneNode(); IMeshSceneNode *node = smgr->addCubeSceneNode(); node->setPosition(vector3df(0,75,0)); camera->setTarget(vector3df(0,1,0)); smgr->getMeshManipulator()->setVertexColors(node->getMesh(), SColor(0,0,255,255)); smgr->addLightSceneNode(); while(device->run()){ if(receiver.IsKeyDown(irr::KEY_LEFT)){ node->setPosition(node->getPosition()+vector3df(0,0,-0.1)); } else if(receiver.IsKeyDown(irr::KEY_RIGHT)){ node->setPosition(node->getPosition()+vector3df(0,0,0.1)); } else if(receiver.IsKeyDown(irr::KEY_SPACE)){ } driver->beginScene(true, true, SColor(123,100,100,100)); smgr->drawAll(); driver->endScene(); } return 0; }