// ---------------------------------------------------------------------------- bool Editor::init() { m_maps_path = NULL; m_music_loc = NULL; m_indicator = NULL; m_valid_data_dir = false; m_exe_loc = ""; m_toolbar = NULL; m_toolbox = NULL; m_rcs = NULL; m_tex_sel = NULL; m_indicator = NULL; m_viewport = NULL; m_rcs = NULL; m_font = NULL; m_new_dialog_wndw = NULL; m_screen_size = dimension2du(10, 10); IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL); m_screen_size = nulldevice->getVideoModeList()->getDesktopResolution(); readConfigFile(nulldevice->getFileSystem()); nulldevice->drop(); m_device = createDevice(EDT_OPENGL, m_screen_size, 16, false, false, true); if (!m_device) return false; m_device->setResizable(true); m_device->setWindowCaption(L"SuperTuxKart Track Editor Beta v0.03"); if (m_screen_size.Width < 20 || m_screen_size.Height < 20) m_device->maximizeWindow(); m_video_driver = m_device->getVideoDriver(); m_scene_manager = m_device->getSceneManager(); m_gui_env = m_device->getGUIEnvironment(); m_screen_size = m_video_driver->getScreenSize(); m_def_wd = m_device->getFileSystem()->getWorkingDirectory(); // lights m_scene_manager->setAmbientLight(SColorf(0.3f, 0.3f, 0.3f, 1.0f)); ILightSceneNode* l = m_scene_manager->addLightSceneNode(0, vector3df(0, 1, 0), SColorf(1.0f, 1.0f, 1.0f), 500, -1); l->setLightType(ELT_DIRECTIONAL); l->setPosition(vector3df(0, 1, 0)); m_device->setEventReceiver(this); if (!isValidDataLoc()) dataDirLocDlg(); return true; } // init
void Editor::LoadScene() { IVideoDriver *driver = device->getVideoDriver(); ISceneManager *smgr = device->getSceneManager(); // Calculate Projection Matrix matrix4 projMat; irr::f32 orth_w = (float)(driver->getScreenSize().Width - 256) / (float)driver->getScreenSize().Height; orth_w = 3 * orth_w; projMat.buildProjectionMatrixOrthoLH(orth_w, 3, 1, 100); // Create target target = smgr->addEmptySceneNode(0, 200); target->setPosition(vector3df(0, 0, 0)); // Add rotational camera pivot = smgr->addEmptySceneNode(target, 199); camera[0] = smgr->addCameraSceneNode(NULL, vector3df(0, 0, -2), vector3df(0, 0, 0)); camera[0]->setParent(pivot); pivot->setRotation(vector3df(25, -45, 0)); // Add Topdown camera camera[1] = smgr->addCameraSceneNode(target, vector3df(0, 2, -0.01), vector3df(0, 0, 0)); camera[1]->setProjectionMatrix(projMat, true); // Add front camera camera[2] = smgr->addCameraSceneNode(target, vector3df(0, 0, -5), vector3df(0, 0, 0)); camera[2]->setProjectionMatrix(projMat, true); // Add side camera camera[3] = smgr->addCameraSceneNode(target, vector3df(5, 0, 0), vector3df(0, 0, 0)); camera[3]->setProjectionMatrix(projMat, true); // Add Light ILightSceneNode* light = smgr->addLightSceneNode(target, vector3df(25, 50, 0)); light->setLightType(ELT_POINT); light->setRadius(2000); // Add Plane IMeshSceneNode* plane = smgr->addCubeSceneNode(1, 0, -1, vector3df(0.5, -5.5, 0.5), vector3df(0, 0, 0), vector3df(10, 10, 10)); plane->setMaterialTexture(0, driver->getTexture("media/texture_terrain.png")); plane->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); plane->getMaterial(0).getTextureMatrix(0).setTextureScale(10, 10); // Add sky box scene::IMeshSceneNode* skybox = smgr->addCubeSceneNode(50); skybox->setMaterialTexture(0, driver->getTexture("media/sky.jpg")); skybox->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); skybox->setMaterialFlag(video::EMF_LIGHTING, false); smgr->getMeshManipulator()->flipSurfaces(skybox->getMesh()); state->plane_tri = smgr->createOctreeTriangleSelector(skybox->getMesh(), skybox); }
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; }
void IrrQWidget::buildIrrlichtScene(){ if(idevice != 0){ collMan = iscene->getSceneCollisionManager(); geo = iscene->getGeometryCreator(); ILightSceneNode *light = iscene->addLightSceneNode(); light->setLightType( ELT_DIRECTIONAL ); light->setRotation( vector3df( 45.0f, 45.0f, 0.0f )); light->getLightData().AmbientColor = SColorf( 0.2f, 0.2f, 0.2f, 1.0f ); light->getLightData().DiffuseColor = SColorf( 0.8f, 0.8f, 0.8f, 1.0f ); camera = iscene->addCameraSceneNodeFPS(); camera->setPosition(vector3df(0,0,-90)); camera->setTarget(vector3df(0,0,0)); } }
void CIrrWindow::initScene() { IVideoDriver* driver = m_driver; IrrlichtDevice* device = m_device; ISceneManager* smgr = m_smgr; // create texture manager CTextureManager::createGetInstance(); // create design camera m_designCamera = new CGameCamera(); m_designCamera->setName( L"Design camera" ); m_designCamera->setTarget(core::vector3df(0,0,0)); m_designCamera->setPosition( core::vector3df(-400, 200, -400) ); // set active camera getIView()->setActiveCamera( m_designCamera ); // add oxyz plane node CGameOxyzSceneNode *oxyPlane = new CGameOxyzSceneNode( smgr->getRootSceneNode(), smgr, 1 ); oxyPlane->drop(); // add light ISceneNode* pNode = smgr->addEmptySceneNode(); // default light ILightSceneNode *light = smgr->addLightSceneNode( pNode, core::vector3df(0, 0, 0) ); light->setLightType( video::ELT_DIRECTIONAL ); // add demo particle m_particleObject = new CGameObject(); CParticleComponent *particleComp = new CParticleComponent(m_particleObject); particleComp->initParticle(); m_particleObject->m_components.push_back( particleComp ); }
void Editor::LoadScene() { IVideoDriver *driver = device->getVideoDriver(); ISceneManager *smgr = device->getSceneManager(); // Create target target = smgr->addEmptySceneNode(0, 200); target->setPosition(vector3df(0, 0, 0)); // Create cameras pivot = smgr->addEmptySceneNode(target, 199); pivot->setRotation(vector3df(25, -45, 0)); recreateCameras(); // Add Light ILightSceneNode* light = smgr->addLightSceneNode(target, vector3df(25, 50, 0)); light->setLightType(ELT_POINT); light->setRadius(2000); // Add Plane plane = smgr->addCubeSceneNode(1, 0, -1, vector3df(0.5, -5.5, 0.5), vector3df(0, 0, 0), vector3df(10, 10, 10)); plane->setMaterialTexture(0, driver->getTexture("media/texture_terrain.png")); plane->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); plane->setMaterialFlag(video::EMF_LIGHTING, false); plane->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true); plane->getMaterial(0).getTextureMatrix(0).setTextureScale(10, 10); // Add sky box scene::IMeshSceneNode* skybox = smgr->addCubeSceneNode(50); skybox->setMaterialTexture(0, driver->getTexture("media/sky.jpg")); skybox->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); skybox->setMaterialFlag(video::EMF_LIGHTING, false); smgr->getMeshManipulator()->flipSurfaces(skybox->getMesh()); state->plane_tri = smgr->createOctreeTriangleSelector(skybox->getMesh(), skybox); }
void CLiquidbodyExample::runExample() { debugDraw = true; drawProperties = true; drawWireFrame = false; int rows=2, columns=2; device = createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16, false, false, false, this); printf("Please enter the number of rows and columns of floating objects to create: \n"); cin >> rows; cin >> columns; device->setWindowCaption(L"irrBullet Liquidbody Example - Josiah Hartzell"); device->getFileSystem()->addFolderFileArchive("../../media/"); ILightSceneNode* light = device->getSceneManager()->addLightSceneNode(0, vector3df(20, 40, -50), SColorf(1.0f, 1.0f, 1.0f), 4000.0f); light->setLightType(ELT_DIRECTIONAL); light->setRotation(vector3df(0,200,30)); device->getSceneManager()->setAmbientLight(SColor(100,100,100,100)); camera = device->getSceneManager()->addCameraSceneNodeFPS(); camera->setPosition(vector3df(50,15,4)); camera->setTarget(vector3df(0,0,0)); //////////////////////////// // Create irrBullet World // //////////////////////////// world = createIrrBulletWorld(device, true, debugDraw); world->setDebugMode(EPDM_DrawAabb | EPDM_DrawContactPoints); world->setGravity(vector3df(0,-10,0)); ILiquidBody* water = world->addLiquidBody(vector3df(-5000,0,5000),irr::core::aabbox3df(0, -10000, 0, 10000, 0, 10000), 500.0f, 200.0f); water->setCurrentDirection(vector3df(0,0,0)); water->setGlobalWaveChangeIncrement(0.01f); water->setGlobalWaveUpdateFrequency(1.0f); water->setMaxGlobalWaveHeight(4.0f); water->setMinGlobalWaveHeight(-1.0f); water->setLocalWaveValues(10,1,0.5f); water->setInfinite(true); water->setInfiniteDepth(true); water->setLiquidDensity(0.1f); //water->setDebugDrawEnabled(false); IAnimatedMesh* mesh = device->getSceneManager()->addHillPlaneMesh( "myHill", core::dimension2d<f32>(20,20), core::dimension2d<u32>(40,40), 0, 0, core::dimension2d<f32>(0,0), core::dimension2d<f32>(1000,1000)); ISceneNode* node = device->getSceneManager()->addWaterSurfaceSceneNode(mesh->getMesh(0), 0.0f, 300.0f, 30.0f); node->setPosition(core::vector3df(0,5,0)); node->setMaterialTexture(0, device->getVideoDriver()->getTexture("water.jpg")); node->setScale(vector3df(1000,1,1000)); node->setMaterialType(EMT_TRANSPARENT_ADD_COLOR); node->setMaterialFlag(EMF_BACK_FACE_CULLING, false); for(u32 i=0; i < rows; i++) { for(u32 j=0; j < columns; j++) { IRigidBody* body = addCube(vector3df(i*15,0,j*15), vector3df(10,10,10), 1, "crate.jpg"); irr::f32 t = 0.5f; irr::f32 buoyancy = 0.2f; irr::core::array<SBuoyancyPoint> points; //points.push_back(SBuoyancyPoint(irr::core::vector3df(0,0,0), 180.0f)); points.push_back(SBuoyancyPoint(irr::core::vector3df(t,t,t), buoyancy)); points.push_back(SBuoyancyPoint(irr::core::vector3df(-t,t,t), buoyancy)); points.push_back(SBuoyancyPoint(irr::core::vector3df(-t,t,-t), buoyancy)); points.push_back(SBuoyancyPoint(irr::core::vector3df(t,t,-t), buoyancy)); points.push_back(SBuoyancyPoint(irr::core::vector3df(-t,-t,t), buoyancy)); points.push_back(SBuoyancyPoint(irr::core::vector3df(t,-t,t), buoyancy)); points.push_back(SBuoyancyPoint(irr::core::vector3df(-t,-t,-t), buoyancy)); points.push_back(SBuoyancyPoint(irr::core::vector3df(t,-t,-t), buoyancy)); /*ICollisionObjectAffectorBuoyancy* affector = new ICollisionObjectAffectorBuoyancy(points, irr::core::aabbox3df(0, -100, 0, 10000, 0, 10000), 1); affector->setDebugDrawing(true); body->addAffector(affector);*/ body->setBuoyancyPoints(points); //body->setActivationState(EAS_DISABLE_DEACTIVATION); } } // Set our delta time and time stamp u32 TimeStamp = device->getTimer()->getTime(); u32 DeltaTime = 0; while(device->run()) { device->getVideoDriver()->beginScene(true, true, SColor(255,100,101,140)); DeltaTime = device->getTimer()->getTime() - TimeStamp; TimeStamp = device->getTimer()->getTime(); // Step the simulation with our delta time world->stepSimulation(DeltaTime*0.001f, 120); //static_cast<ISoftBody*>(world->getCollisionObjectByName("SOFTBODY1"))->addForce(vector3df(-2,0,0)); //world->debugDrawWorld(debugDraw); // This call will draw the technical properties of the physics simulation // to the GUI environment. world->debugDrawProperties(drawProperties); device->getSceneManager()->drawAll(); device->getGUIEnvironment()->drawAll(); device->getVideoDriver()->endScene(); } //delete Liquid; // We're done with the IrrBullet world, so we free the memory that it takes up. if(world) delete world; if(device) device->drop(); }