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; }
int main(int argc, char **argv) { BSPdungeon dun(50,50,5); IrrlichtDevice *device =createDevice( video::EDT_OPENGL, dimension2d<u32>(1280,720), 16,false, false, false, 0); if (!device) return 1; device->setWindowCaption(L"Pangolin Kwest"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); smgr->setAmbientLight(video::SColorf(0.1,0.1,0.1,1)); ILightSceneNode* mylight1 = smgr->addLightSceneNode( 0, core::vector3df(00,00,00), video::SColorf(0.3f,0.3f,0.3f), 30.0f, 1 ); //IGUIFont* myfont=guienv->getFont("./myfont.xml"); //if(myfont==0)exit(93); //guienv->addMessageBox(L"Alertz!",L"You pangolin are been createrized. You totalleh ready to bash monstaz etc.!"); mylight1->enableCastShadow(true); //guienv->addStaticText(L"Pangolin Kwest 3D",rect<s32>(10,10,260,22), true); //------------------------------------------- int x,y,z; for(x=0;x<50;x++){ for(y=0;y<50;y++){ if(dun.map[x][y]==NIL){ for(z=0;z<3;z++){ ISceneNode* cueb=smgr->addCubeSceneNode(10); cueb->setMaterialFlag(EMF_LIGHTING, true); cueb->setMaterialTexture( 0, driver->getTexture("media/stdwall.jpg") ); // cueb->getMaterial(0).getTextureMatrix(0).setTextureTranslate(0.25,0.5); // cueb->getMaterial(0).getTextureMatrix(0).setTextureScale(0.0625,0.0625); cueb->setPosition(vector3df(x*10,z*10,y*10)); } } // ISceneNode* cueb=smgr->addCubeSceneNode(10); // cueb->setMaterialFlag(EMF_LIGHTING, true); // cueb->setMaterialTexture( 0, driver->getTexture("media/stdfloor.jpg") ); // cueb->setPosition(vector3df(x*10,-10,y*10)); ISceneNode* cueb=smgr->addCubeSceneNode(10); cueb->setMaterialFlag(EMF_LIGHTING, true); cueb->setMaterialTexture( 0, driver->getTexture("media/stdup.jpg") ); cueb->setPosition(vector3df(x*10,30,y*10)); } } ISceneNode* cueb=smgr->addCubeSceneNode(500); cueb->setMaterialFlag(EMF_LIGHTING, true); cueb->setMaterialTexture( 0, driver->getTexture("media/stdfloor.jpg") ); cueb->setPosition(vector3df(250,-255,250)); //cueb->getMaterial(0).getTextureMatrix(0).setTextureTranslate(0.25,0.5); cueb->getMaterial(0).getTextureMatrix(0).setTextureScale(50,50); //cueb->setScale(vector3df(0,-5,0)); //cueb->addshadowVolumeSceneNode(); //------------------------------------------- int lastFPS; //smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); ICameraSceneNode* mycam; mycam=smgr->addCameraSceneNodeFPS(0,100.0f,0.025f); mycam->setFOV(45); mylight1->setParent(mycam); while(device->run()) { //mylight1->setPosition(); //mylight1-> driver->beginScene(true, true, SColor(255,100,101,140)); smgr->drawAll(); guienv->drawAll(); driver->endScene(); int fps = driver->getFPS(); if (lastFPS != fps) { core::stringw str = L"Pangolin Kwest 3D ["; str += driver->getName(); str += "] FPS:"; str += fps; device->setWindowCaption(str.c_str()); lastFPS = fps; } } device->drop(); return 0; }
int main() { // create device EventHandler receiver; Init(); Output(); ISceneNode* objects [MAX_OBJECTS]; IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(ResX, ResY), 32, fullscreen, false, vsync, &receiver); receiver.device = device; if (!device) return 1; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); HMDDescriptor HMD; // Parameters from the Oculus Rift DK1 HMD.hResolution = ResX; HMD.vResolution = ResY; HMD.hScreenSize = 0.14976; HMD.vScreenSize = 0.0936; HMD.interpupillaryDistance = 0.064; HMD.lensSeparationDistance = 0.064; HMD.eyeToScreenDistance = 0.041; HMD.distortionK[0] = 1.0; HMD.distortionK[1] = 0.22; HMD.distortionK[2] = 0.24; HMD.distortionK[3] = 0.0; HMDStereoRender renderer(device, HMD, 10); #ifdef OCCULUS ICameraSceneNode* camera = smgr->addCameraSceneNode(); camera->bindTargetAndRotation(false); camera->setTarget(vector3df(1,0,0)); #else ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(); #endif device->getCursorControl()->setVisible(false); // load a faerie IAnimatedMesh* faerie = smgr->getMesh("media/faerie.md2"); IAnimatedMeshSceneNode* faerieNode = smgr->addAnimatedMeshSceneNode(faerie); faerieNode->setMaterialTexture(0, driver->getTexture("media/faerie2.bmp")); faerieNode->setMaterialFlag(EMF_LIGHTING, false); faerieNode->setPosition(vector3df(40,190,-1030)); faerieNode->setRotation(vector3df(0,-90,0)); faerieNode->setMD2Animation(EMAT_SALUTE); // load a dwarf IAnimatedMesh* dwarf = smgr->getMesh("media/dwarf.x"); IAnimatedMeshSceneNode* dwarfNode = smgr->addAnimatedMeshSceneNode(dwarf); dwarfNode->setPosition(vector3df(40,-25,20)); Level currentLevel(device); currentLevel.makeLevel(0); smgr->setAmbientLight(video::SColorf(0.1,0.1,0.1,1)); ILightSceneNode* light1 = smgr->addLightSceneNode( camera , vector3df(0,0,0), video::SColorf(0.3f,0.4f,0.4f), 80.0f, 1 ); vector3df pos = vector3df(0,0,0); //naplníme tunel pøekážkama srand (time(NULL)); /* generate secret number between 1 and 10: */ for(int i = 0; i < MAX_OBJECTS; i++){ objects[i] = smgr->addCubeSceneNode(2); objects[i]->setMaterialFlag(EMF_LIGHTING, false); objects[i]->setPosition( vector3df( (rand() % 30) - 5, (rand() % 30) - 5, rand() % 80) ); } //device->setInputReceivingSceneManager(smgr); //použivane pro vector3df tempRot; irr::core::quaternion tempQ; irr::core::matrix4 tempM; float round = 0; while(device->run()) { round += 0.01; driver->beginScene(true, true, SColor(255,100,101,140)); for(int i = 0; i < MAX_OBJECTS; i++){ vector3df tmpPos = objects[i]->getPosition(); if(tmpPos.Z > pos.Z) continue; objects[i]->setPosition( vector3df( (rand() % 30) - 15, (rand() % 30) - 15, rand() % 80 + pos.Z) ); } #ifndef OCCULUS tempM.setRotationDegrees(vector3df(sin(round*0.5)*360-180, sin(round)*360-180, cos(round*0.8)*360-180)); // transform forward vector of camera irr::core::vector3df frv = irr::core::vector3df (0.0f, 0.0f, 1.0f); tempM.transformVect(frv); // transform upvector of camera irr::core::vector3df upv = irr::core::vector3df (0.0f, 1.0f, 0.0f); tempM.transformVect(upv); camera->setUpVector(upv); //set up vector of camera camera->setTarget(frv); //set target of camera (look at point) (thx Zeuss for correcting it) #endif if(pSensor){ Quatf quaternion = FusionResult.GetOrientation(); ICameraSceneNode* camera = smgr->getActiveCamera(); tempQ.set(-quaternion.z,quaternion.y,-quaternion.x, quaternion.w); tempQ.normalize(); tempQ.toEuler(tempRot); tempM.setRotationDegrees(tempRot); // transform forward vector of camera irr::core::vector3df frv = irr::core::vector3df (0.0f, 0.0f, 1.0f); tempM.transformVect(frv); // transform upvector of camera irr::core::vector3df upv = irr::core::vector3df (0.0f, 1.0f, 0.0f); tempM.transformVect(upv); camera->setUpVector(upv); //set up vector of camera camera->setTarget(frv); //set target of camera (look at point) (thx Zeuss for correcting it) // update absolute position camera->updateAbsolutePosition(); float yaw, pitch, roll; quaternion.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch, &roll); camera->getParent()->setRotation( vector3df(RadToDegree(pitch),RadToDegree(yaw),RadToDegree(roll))); //camera->setRotation( vector3df(RadToDegree(-pitch),RadToDegree(-yaw),RadToDegree(roll))); //camera->setProjectionMatrix(ToMatrix(quaternion)); cout << " Yaw: " << RadToDegree(yaw) << ", Pitch: " << RadToDegree(pitch) << ", Roll: " << RadToDegree(roll) << endl; if (_kbhit()) exit(0); } #ifdef OCCULUS renderer.drawAll(smgr); #else smgr->drawAll(); #endif guienv->drawAll(); driver->endScene(); } device->drop(); Clear(); return 0; }
int main(int argc, char** argv) { CustomEventReceiver receiver; IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(800, 600), 16, false, false, false, &receiver); if (!device) { return EXIT_FAILURE; } device->setWindowCaption(L"Solar System Simulator"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* sceneManager = device->getSceneManager(); scene::ISceneCollisionManager* collisionManager= sceneManager->getSceneCollisionManager(); IGUIEnvironment* guiEnv = device->getGUIEnvironment(); guiEnv->addStaticText(L"Click on a planet to attach the camera to it", rect<s32>(10,10,260,22), false); sf::SoundBuffer buffer; if (buffer.loadFromFile(currentPath() + "/sounds/burning.aif")) { sf::Listener::setPosition(0, 0,0); sf::Sound sound; sound.setBuffer(buffer); sound.setPosition(0, 0, 0); sound.setLoop(true); sound.play(); } const char* spaceTexturePath = ( currentPath() + "/textures/space.jpg" ).c_str(); video::ITexture* space = driver->getTexture(spaceTexturePath); scene::ISceneNode* skybox = sceneManager->addSkyBoxSceneNode(space, space, space, space, space, space); sceneManager->addLightSceneNode(0, vector3df(0, 0, -50), video::SColorf(1.0f, 1.0f, 1.0f), 50.0f, 1001); PlanetFactory planetFactory(sceneManager, driver); Planet sun = planetFactory.create(PlanetId::Sun); Planet earth = planetFactory.create(PlanetId::Earth); Planet pluto = planetFactory.create(PlanetId::Pluto); Planet jupiter = planetFactory.create(PlanetId::Jupiter); Planet uranus = planetFactory.create(PlanetId::Uranus); Planet neptune = planetFactory.create(PlanetId::Neptune); vector<Planet> planets = { sun, planetFactory.create(PlanetId::Mercury) }; planets.push_back(planetFactory.create(PlanetId::Venus)); planets.push_back(earth); planets.push_back(planetFactory.create(PlanetId::Mars)); planets.push_back(jupiter); planets.push_back(planetFactory.create(PlanetId::Saturn)); planets.push_back(uranus); planets.push_back(neptune); planets.push_back(pluto); ICameraSceneNode* camera = sceneManager->addCameraSceneNode(0, vector3df(0,0,40), vector3df(0,0,0)); rect<s32> mainCameraViewPortRect(0, 0, 800, 600); ICameraSceneNode* topViewCamera = sceneManager->addCameraSceneNode(0, vector3df(0,50,0), vector3df(0,0,0)); sceneManager->setAmbientLight(video::SColorf(255.0,255.0,255.0)); ISceneNode* selectedNode = sun.node; while(device->run()) { if(receiver.GetMouseState().LeftButtonDown) { position2di mousepos = receiver.GetMouseState().Position; line3df ray = sceneManager->getSceneCollisionManager()->getRayFromScreenCoordinates( mousepos, camera); vector3df intersection; triangle3df tri; for(Planet& planet : planets) { ITriangleSelector* wselector = sceneManager->createTriangleSelectorFromBoundingBox(planet.node); if (collisionManager->getCollisionPoint(ray, wselector, intersection, tri, planet.node)) { selectedNode = planet.node; } wselector->drop(); } } camera->setTarget(selectedNode->getAbsolutePosition()); skybox->setVisible(true); driver->setViewPort(mainCameraViewPortRect); driver->beginScene(true, true, SColor(255,100,101,140)); sceneManager->setActiveCamera(camera); sceneManager->drawAll(); guiEnv->drawAll(); driver->setViewPort(rect<s32>(0, 380, 200, 600)); driver->draw2DRectangle(SColor(100,0,0,190), mainCameraViewPortRect); skybox->setVisible(false); sceneManager->setActiveCamera(topViewCamera); sceneManager->drawAll(); driver->endScene(); } device->drop(); return EXIT_SUCCESS; }