//--------------------------------------------------------------------------- void TutorialApplication::createScene() { mSceneMgr->setAmbientLight(Ogre::ColourValue(.2f, .2f, .2f)); Ogre::Entity* tudorEntity = mSceneMgr->createEntity("tudorhouse.mesh"); Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Node"); node->attachObject(tudorEntity); Ogre::Light* light = mSceneMgr->createLight("Light1"); light->setType(Ogre::Light::LT_POINT); light->setPosition(Ogre::Vector3(250, 150, 250)); light->setDiffuseColour(Ogre::ColourValue::White); light->setSpecularColour(Ogre::ColourValue::White); node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "CamNode1", Ogre::Vector3(1200, -370, 0)); node->yaw(Ogre::Degree(90)); mCamNode = node; node->attachObject(mCamera); node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "CamNode2", Ogre::Vector3(-500, -370, 1000)); node->yaw(Ogre::Degree(-30)); }
void DemoState::onStart() { //shared_ptr<Grid> grid = make_shared<Grid>(1000.0f, 10.0f); GameManager::getSingleton().addObject(make_shared<HeadsUpDisplay>()); GameManager::getSingleton().addObject(make_shared<OverheadCameraMan>()); GameManager::getSingleton().addObject(make_shared<Background>()); //GameManager::getSingleton().addObject(grid); /* GameManager::getSingleton().addObject(make_shared<Ship>()); GameManager::getSingleton().addObject(make_shared<Ship>()); GameManager::getSingleton().addObject(make_shared<Ship>()); shared_ptr<Planet> planet = make_shared<Planet>(); planet->setPosition(Ogre::Vector3(10, 0, 0)); GameManager::getSingleton().addObject(planet); */ shared_ptr<AsteroidField> asteroidField = make_shared<AsteroidField>(); asteroidField->setPosition(Ogre::Vector3(10, 0, 0)); GameManager::getSingleton().addObject(asteroidField); getScene()->setAmbientLight(Ogre::ColourValue(0.2f, 0.2f, 0.3f)); Ogre::Light* light = getScene()->createLight("MainLight"); light->setPosition(20, 80, 50); }
void Application::setupScene() { mOgreScene = Ogre::Root::getSingleton().createSceneManager("OctreeSceneManager"); mOgreScene->setAmbientLight(Ogre::ColourValue::Black); mOgreCamera = mOgreScene->createCamera("Camera"); mOgreCamera->setNearClipDistance(0.1f); mOgreCamera->setFarClipDistance(1000.0f); Ogre::Viewport* viewport = mOgreWindow->addViewport(mOgreCamera); mOgreCamera->setAspectRatio(Ogre::Real(viewport->getActualWidth()) / Ogre::Real(viewport->getActualHeight())); mOgreCamera->setPosition(0, 0, 0); mOgreFloor = mOgreScene->createEntity("Floor", "plocha.mesh"); mOgreScene->getRootSceneNode()->attachObject(mOgreFloor); Ogre::Light* light = mOgreScene->createLight("Light"); light->setType(Ogre::Light::LT_POINT); mOgreChopterNode = mOgreScene->getRootSceneNode()->createChildSceneNode("ChopterNode"); mOgreChopterNode->setPosition(0, 20, 0); mOgreChopterNode->attachObject(mOgreCamera); mOgreChopterNode->attachObject(light); mOgreChopterNode->setFixedYawAxis(true); }
void GameState::enter() { OgreFramework::getSingletonPtr()->m_pLog->logMessage("Entering GameState..."); m_pSceneMgr = OgreFramework::getSingletonPtr()->m_pRoot->createSceneManager(ST_GENERIC, "GameSceneMgr"); m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.4f, 0.4f, 0.4f)); m_pSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE); Ogre::Light* dirLight = m_pSceneMgr->createLight("dirLight"); dirLight->setType(Ogre::Light::LT_DIRECTIONAL); dirLight->setDiffuseColour(Ogre::ColourValue(0.4f, 0.4f, 0.4f)); dirLight->setSpecularColour(Ogre::ColourValue(0.4f, 0.4f, 0.4f)); dirLight->setDirection(Ogre::Vector3(0, -1, 0)); m_pCamera = m_pSceneMgr->createCamera("GameCam"); m_pCamera->setPosition(Vector3(0, 15, -300)); m_pCamera->lookAt(Vector3(0, 15, 0)); m_pCamera->setNearClipDistance(1); m_pCamera->setAspectRatio(Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualWidth()) / Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualHeight())); limit = 0.0; OgreFramework::getSingletonPtr()->m_pViewport->setCamera(m_pCamera); // create an imageset for the face portrait CEGUI::ImagesetManager *im = &(CEGUI::ImagesetManager::getSingleton()); CEGUI::NamedXMLResourceManager<CEGUI::Imageset, CEGUI::Imageset_xmlHandler> *castedIm = NULL; castedIm = (CEGUI::NamedXMLResourceManager<CEGUI::Imageset, CEGUI::Imageset_xmlHandler>*) im; castedIm->create( "Face.imageset" ); // hide cursor CEGUI::MouseCursor::getSingleton().hide(); createScene(); }
Star::Star(int temperature, double radius, Ogre::SceneNode *systemNode, Ogre::SceneManager *sceneMgr, int x, int y) { kelvin = temperature; radius = radius; int rand2 = rand()%1000; double colorEvener = 0.35; std::string starNodeName = "Star" + Ogre::StringConverter::toString(temperature) + Ogre::StringConverter::toString(rand2); std::string starParticleName = "starParticle" + Ogre::StringConverter::toString(temperature) + Ogre::StringConverter::toString(rand2); std::string starParticleNodeName = "starParticleNode" + Ogre::StringConverter::toString(temperature) + Ogre::StringConverter::toString(rand2); starNode = systemNode->createChildSceneNode(starNodeName, Ogre::Vector3(0,0,0)); //Particle Gen Ogre::ParticleSystem* starParticle = sceneMgr->createParticleSystem(starParticleName, "StarWhite"); Ogre::SceneNode* particleNode = systemNode->createChildSceneNode(starParticleNodeName,Ogre::Vector3((-0.5+x),(0+y),0.5)); particleNode->attachObject(starParticle); setColor(color); starParticle->getEmitter(0)->setColour(Ogre::ColourValue(color[0]*colorEvener,color[1]*colorEvener,color[2]*colorEvener,color[3])); //Light Gen Ogre::SceneNode* lightNode = NULL; Ogre::Light* lightPoint = sceneMgr->createLight(); lightPoint->setType(Ogre::Light::LT_POINT); lightPoint->setDiffuseColour(color[0], color[1], color[2]); lightPoint->setSpecularColour(color[0], color[1], color[2]); lightNode = systemNode->createChildSceneNode(); lightNode->attachObject(lightPoint); //Rotation starRotationDegree = 1.0; }
LUA_DEFINE_FUNCTION(LightsManager, getLightPosition) { // // Pass it to Lua script // /* get number of arguments */ int n = lua_gettop(L); // n should be 1 /* get the first argument (the light name) */ Ogre::String lightName = lua_tostring(L, 1); // // Retrieve light position // Ogre::Light* light = LightsManager::getSingleton().getLight(lightName); Vector3 position = light->getPosition(); /* push the X */ lua_pushnumber(L, position.x); /* push the Y */ lua_pushnumber(L, position.y); /* push the Z */ lua_pushnumber(L, position.z); /* return the number of results */ return 3; }
void StandLatas::enter() { _loadingShoot =false; _timeLoadingShoot =0; reacomodateCamera(); _numCans=0; drawCans(); _crosshair = unique_ptr<Crosshair>(new Crosshair(_sceneMgr,_camera)); _crosshair.get()->createCrossHairManual("circle-01.png"); _rayScnQuery =_sceneMgr->createRayQuery(Ogre::Ray(), 0); _ballStack = _sceneMgr->createSceneNode("ballStack"); _sceneMgr->getRootSceneNode()->addChild(_ballStack); drawHud(); Carrusel c; c.go(); _timeWithoutBalls=0; _puntos=0; Ogre::Light* light = _sceneMgr->createLight("LightStandLatas"); light->setType(Ogre::Light::LT_DIRECTIONAL); light->setDirection(Ogre::Vector3(0,0,-1)); light->setPosition(_cameraNode->getPosition()); light->setCastShadows(true); }
//------------------------------------------------------------------------------------- void GameApplication::createScene() { // Create your scene here... //set ambient light Ogre::Light* light = mSceneMgr->createLight("MainLight"); light->setPosition(15,15,3); //create the puckManager singleton PuckManager::instance(mSceneMgr, 10); //create the shuffleboard singleton Shuffleboard::instance(mSceneMgr); //mPuck = PuckManager::instance()->getNextPuck(); /* we should only create a puck when SPACE key is pressed //This gives us the correct x,y,z position for the puck launch at the top of the shuffleboard Ogre::Real centreX = ( GameConstants::MAX_X - GameConstants::MIN_X ) / 2 + GameConstants::MIN_X; Ogre::Vector3 launchPos( centreX, GameConstants::LAUNCH_Y, GameConstants::LAUNCH_Z ); mPuck->activate(launchPos); mPuck->applyForce(Ogre::Real(7));*/ mGui3D = new Gui3D::Gui3D(&mMyPurplePanelColors); Ogre::Viewport *viewport = mWindow->getViewport(0); mGui3D->createScreen(viewport, "purple", "mainScreen"); createGamePanel(); mCurrentTime = 0; }
void CEditor::Create( HWND hWnd,int width,int height ) { GetCurrentDirectory(MAX_PATH, mCurDir); mpEntityMgr = new CEntityManager; mpPhysicsMgr = new CPhysicsManager; Ogre::NameValuePairList parms; parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)hWnd); mRenderWindow = mRoot->createRenderWindow("TerrainEditor", width, height, false, &parms); mhWnd = hWnd; mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC, "MainScene"); // Create the camera mCamera = mSceneManager->createCamera("PlayerCam"); mCamera->setPosition(mTerrainPos + Ogre::Vector3(200, 400, 0)); mCamera->lookAt(Ogre::Vector3(0, 50, 0)); mCamera->setNearClipDistance(1); mCamera->setFarClipDistance(12000); mViewport = mRenderWindow->addViewport(mCamera); mViewport->setBackgroundColour(Ogre::ColourValue(0.5f,0.5f,0.5f)); //SetupInput(); loadResources(); mGuiMgr = new OgreBites::GuiManager("BrowserControls", mRenderWindow, this); //mGuiMgr->showBackdrop("SdkTrays/Bands"); mGuiMgr->getTrayContainer(OgreBites::TL_NONE)->hide(); Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC); Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7); mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions(); Ogre::Light* l = mSceneManager->createLight("terrainLight"); l->setType(Ogre::Light::LT_DIRECTIONAL); Ogre::Vector3 lightdir(0.1f, -0.3f, 0.1f); lightdir.normalise(); l->setDirection(lightdir); l->setDiffuseColour(Ogre::ColourValue::White); l->setSpecularColour(Ogre::ColourValue(0.4f, 0.4f, 0.4f)); mTerrainLight = l; mSceneManager->setAmbientLight(Ogre::ColourValue(0.2f, 0.2f, 0.2f)); Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); mRoot->addFrameListener(this); mGuiMgr->showFrameStats(OgreBites::TL_TOPRIGHT); mpEntityMgr->Create(); mpPhysicsMgr->Create(); // Alter the camera aspect ratio to match the viewport mCamera->setAspectRatio( Ogre::Real(mViewport->getActualWidth()) / Ogre::Real(mViewport->getActualHeight())); SetEditTool(NULL); }
//-------------------------------------------------------------------------- void Utility::initComponents() { Application::initComponents(); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); Ogre::Root *root( getRoot() ); m_scene_manager = root->createSceneManager( Ogre::ST_GENERIC, "Scene" ); m_scene_manager->clearScene(); m_scene_manager->setAmbientLight( Ogre::ColourValue( 0.5, 0.5, 0.5 ) ); Ogre::Light* directionalLight = m_scene_manager->createLight("directionalLight"); directionalLight->setType( Ogre::Light::LT_DIRECTIONAL ); directionalLight->setDiffuseColour( Ogre::ColourValue( 0.5, 0.5, 0.5) ); directionalLight->setSpecularColour( Ogre::ColourValue( 0.5, 0.5, 0.5) ); directionalLight->setDirection( Ogre::Vector3( 0, 0, -1 ) ); m_camera = m_scene_manager->createCamera( "Camera" ); m_camera->setNearClipDistance( 0.01f ); m_camera->setPosition( 0, 5, 10 ); m_camera->lookAt( 0, 0, 0 ); Ogre::RenderWindow *window( getRenderWindow() ); m_viewport = window->addViewport( m_camera ); m_viewport->setBackgroundColour( Ogre::ColourValue( 0.0f, 0.4f, 0.0f ) ); m_camera->setAspectRatio( Ogre::Real( m_viewport->getActualWidth() ) / Ogre::Real( m_viewport->getActualHeight() ) ); m_frame_listener = new DisplayFrameListener( window ); m_frame_listener->setCamera( m_camera ); root->addFrameListener( m_frame_listener ); }
// insert a light related to the most recent insertBegin call. void InteriorCellRender::insertLight(float r, float g, float b, float radius) { assert (insert); Ogre::Light *light = scene.getMgr()->createLight(); light->setDiffuseColour (r, g, b); float cval=0.0f, lval=0.0f, qval=0.0f; if(lightConst) cval = lightConstValue; if(!lightOutQuadInLin) { if(lightLinear) radius *= lightLinearRadiusMult; if(lightQuadratic) radius *= lightQuadraticRadiusMult; if(lightLinear) lval = lightLinearValue / pow(radius, lightLinearMethod); if(lightQuadratic) qval = lightQuadraticValue / pow(radius, lightQuadraticMethod); } else { // FIXME: // Do quadratic or linear, depending if we're in an exterior or interior // cell, respectively. Ignore lightLinear and lightQuadratic. } light->setAttenuation(10*radius, cval, lval, qval); insert->attachObject(light); }
//------------------------------------------------------------------------------------- void HelloOGRE::createScene(void) { using namespace Ogre; Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "7.mesh"); //Ogre::Entity* cube = mSceneMgr->createEntity("cube","abc.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Head"); headNode->attachObject(ogreHead); ManualObject * axis = mSceneMgr->createManualObject("Axis"); axis->begin("line",Ogre::RenderOperation::OperationType::OT_LINE_LIST); axis->position(0.0f,0.0f,0.0f); axis->position(20.0f,0.0f,0.0f); axis->end(); headNode->attachObject(axis); // Set ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0,0.5, 0.0)); mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE); mSceneMgr->setSkyDome(true,"Examples/Rockwall"); //mSceneMgr->setSkyPlane(true,"Example/" // Create a light Ogre::Light* l = mSceneMgr->createLight("MainLight"); l->setDiffuseColour(0.0f,1.0f,0.0f); l->setPosition(20,80,50); l->setDirection(0.0,0.0,0.0); }
void MyApp::createScene() { // Setup shadows. if (mUseShadows) { mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE); } else { mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE); } // Set the ambient light level. mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3)); // Create a light source. Ogre::Light* light = mSceneMgr->createLight("light0"); light->setType(Ogre::Light::LT_POINT); light->setDiffuseColour(1.0, 1.0, 1.0); light->setSpecularColour(1.0, 1.0, 1.0); light->setPosition(100.0, 300.0, 100.0); // Setup the initial camera position. mPhysicalCamera->setPosition(opal::Point3r(0, 30, 50)); mPhysicalCamera->lookAt(opal::Point3r(0, 0, 0)); // Load models, create physical objects, etc. here. }
void AWGraphics::SceneDirector::createPlayer() { // Add player entity to the scene Ogre::Entity* ogreEntity = mSceneMgr->createEntity("ogrehead.mesh"); Ogre::SceneNode* parentNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); Ogre::SceneNode* ogreNode = parentNode->createChildSceneNode(); ogreNode->attachObject(ogreEntity); ogreNode->rotate(Ogre::Vector3(0.0, 1.0, 0.0), Ogre::Radian(Ogre::Degree(180))); ogreNode->setPosition(0, 80, 0); mPlayerNode = parentNode; // Initialize and add a light mSceneMgr->setAmbientLight(Ogre::ColourValue(.5, .5, .5)); Ogre::Light* light = mSceneMgr->createLight("MainLight"); light->setType(Ogre::Light::LT_DIRECTIONAL); light->setDirection(Ogre::Vector3(0, -1, 1)); /*// Directional light Ogre::Light* directionalLight = mSceneMgr->createLight("DirectionalLight"); directionalLight->setType(Ogre::Light::LT_DIRECTIONAL); directionalLight->setDiffuseColour(Ogre::ColourValue(.8, .6, .2)); directionalLight->setSpecularColour(Ogre::ColourValue(.8, .6, .2)); */ // Add skydome mSceneMgr->setSkyDome(true, "CloudySky", 5, 8); // cannot find... :( }
void TutorialApplication::createScene(void) { //create primary entity ent = mSceneMgr->createEntity("foo",inputfile); //this entity is for testing only //Ogre::Entity* ent2 = mSceneMgr->createEntity("Ogrehead2","ogrehead.mesh"); //cretae node to which .mesh entity will be attached node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node1"); node->setPosition(10,0,0); node->attachObject(ent); //Ogre::SceneNode* camnode = node->createChildSceneNode("Node2",Ogre::Vector3(80,0,0)); //camnode->attachObject(ent2); //camnode->attachObject(cam1); //camnode->attachObject(mCamera); mSceneMgr->setAmbientLight(Ogre::ColourValue(1,1,1)); Ogre::Light* light = mSceneMgr->createLight("mainlight"); light->setDiffuseColour(Ogre::ColourValue::White); light->setPosition(10,100,0); mCamera->setAutoTracking(true, node); }
void Hundir::createScene() { Ogre::Entity* inicio = _sceneManager->createEntity("Inicio.mesh"); Ogre::SceneNode* ninicio = _sceneManager->createSceneNode("ninicio"); _sceneManager->getRootSceneNode()->addChild(ninicio); ninicio->attachObject(inicio); ninicio->yaw(Ogre::Degree(-15)); ninicio->pitch(Ogre::Degree(50)); ninicio->roll(Ogre::Degree(90)); ninicio->setScale(1,1.5,1.2); ninicio->setPosition(0,0,-2); /* Sombras */ _sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE); _sceneManager->setShadowColour(Ogre::ColourValue(0.5, 0.5, 0.5) ); _sceneManager->setAmbientLight(Ogre::ColourValue(0.9, 0.9, 0.9)); _sceneManager->setShadowTextureCount(2); _sceneManager->setShadowTextureSize(512); /* Iluminacion */ Ogre::Light *light = _sceneManager->createLight("Light"); light->setType(Ogre::Light::LT_SPOTLIGHT); light->setDirection(Ogre::Vector3(0,-1,0)); light->setSpotlightInnerAngle(Ogre::Degree(25.0f)); light->setSpotlightOuterAngle(Ogre::Degree(200.0f)); light->setPosition(0, 150, 0); light->setSpecularColour(1, 1, 1); light->setDiffuseColour(1, 1, 1); light->setSpotlightFalloff(5.0f); light->setCastShadows(true); }
//-------------------------------- // C++ Methods called FROM Lua //-------------------------------- LUA_DEFINE_FUNCTION(LightsManager, getLightDiffuseColor) { // // Pass it to Lua script // /* get number of arguments */ int n = lua_gettop(L); // n should be 1 /* get the first argument (the light name) */ Ogre::String lightName = lua_tostring(L, 1); // // Retrieve light color // Ogre::Light* light = LightsManager::getSingleton().getLight(lightName); ColourValue color = light->getDiffuseColour(); /* push the Red */ lua_pushnumber(L, color.r); /* push the Green */ lua_pushnumber(L, color.g); /* push the Blue */ lua_pushnumber(L, color.b); /* return the number of results */ return 3; }
void RenderBoxScene::createScene() { // создае?новы?сцен менеджер mScene = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, MyGUI::utility::toString(this, "_SceneManagerRenderBox")); // создае?но??которуму буде?вс¤ку?др¤нь атачит? mNode = mScene->getRootSceneNode()->createChildSceneNode(); mScene->setAmbientLight(Ogre::ColourValue(0.8, 0.8, 0.8)); // главны?источник свет? Ogre::Vector3 dir(-1, -1, 0.5); dir.normalise(); Ogre::Light * light = mScene->createLight(MyGUI::utility::toString(this, "_LightRenderBox")); light->setType(Ogre::Light::LT_DIRECTIONAL); light->setDirection(dir); std::string camera(MyGUI::utility::toString(this, "_CameraRenderBox")); mCamera = mScene->createCamera(camera); mCamera->setNearClipDistance(1); mCameraNode = mScene->getRootSceneNode()->createChildSceneNode(camera); mCameraNode->attachObject(mCamera); if (mCanvas->getHeight() == 0) mCamera->setAspectRatio(1); else mCamera->setAspectRatio( float(mCanvas->getWidth()) / float(mCanvas->getHeight()) ); setViewport(mCamera); }
LUA_DEFINE_FUNCTION(LightsManager, setLightPosition) { // // Pass it to Lua script // /* get number of arguments */ int n = lua_gettop(L); // n should be 4 /* get the color arguments */ //if(!lua_isnumber(L,0)) //{ //lua_pushstring(L,"Incorrect argument to 'red' component"); //lua_error(L); //} Ogre::String lightName = lua_tostring(L, 1); Ogre::Real x = lua_tonumber(L, 2); Ogre::Real y = lua_tonumber(L, 3); Ogre::Real z = lua_tonumber(L, 4); // // Retrieve light color // Ogre::Light* light = LightsManager::getSingleton().getLight(lightName); light->setPosition(x,y,z); /* return the number of results */ return 0; }
void QOgreWindow::createScene() { // Put anything in here, I'll just put a plane and a dragon here for testing purposes. Go crazy. // Plane Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0); Ogre::MeshManager::getSingleton().createPlane( "ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 1500,1500,20,20, true, 1,5,5, Ogre::Vector3::UNIT_Z); Ogre::Entity* ground = oSceneMgr->createEntity("ground"); oSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ground); ground->setCastShadows(false); ground->setMaterialName("Examples/Rockwall"); // Dragon Mesh oSceneMgr->setAmbientLight(Ogre::ColourValue(0.5,0.5,0.5)); Ogre::Entity* ogreHead = oSceneMgr->createEntity("Icosphere.mesh"); Ogre::SceneNode* node = oSceneMgr->getRootSceneNode()->createChildSceneNode(); node->attachObject(ogreHead); node->setPosition(0.0,70.0,0.0); Ogre::Light* light = oSceneMgr->createLight("MainLight"); light->setPosition(20, 80, 50); }
void MainApplication::createScene(void) { mSceneMgr->setAmbientLight(Ogre::ColourValue(0.25, 0.25, 0.25)); // add the ninja ent = mSceneMgr->createEntity("Ninja", "ogrehead.mesh"); node = mSceneMgr->getRootSceneNode()->createChildSceneNode("NinjaNode", Ogre::Vector3(0.0f, 0.0f, 25.0f)); node->attachObject(ent); node->yaw(Ogre::Degree(90)); node -> setPosition(Ogre::Vector3(0, 0, -500)); Ogre::SceneNode *sceneNode = mSceneMgr -> getRootSceneNode() -> createChildSceneNode("CanNode", Ogre::Vector3(0, 0, 500)); sceneNode = sceneNode -> createChildSceneNode("Pitchnode"); sceneNode -> attachObject(mCamera); // create the light Ogre::Light *light = mSceneMgr->createLight("Light1"); light->setType(Ogre::Light::LT_POINT); light->setPosition(Ogre::Vector3(250, 150, 250)); light->setDiffuseColour(Ogre::ColourValue::White); light->setSpecularColour(Ogre::ColourValue::White); // Create the scene node //node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Ogre::Vector3(-400, 200, 400)); // Make it look towards the ninja //node -> setPosition(Ogre::Vector3(0,0,1000)); // Create the pitch node //node = node->createChildSceneNode("PitchNode1"); //node->attachObject(mCamera); }
void Sample::setupScene() { mSceneMgr->setSkyBox(true, "spaceSkyBox"); // Set the scene's ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f)); Ogre::Entity* pEntity = mSceneMgr->createEntity("SinbadInstance", "Sinbad.mesh"); Ogre::SceneNode* pNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); pNode->attachObject(pEntity); pNode->setScale(Ogre::Vector3(3.0f)); mDance = pEntity->getAnimationState("Dance"); mDance->setEnabled(true); mDance->setLoop(true); mDance->setTimePosition(0); Ogre::Light* pDirLight = mSceneMgr->createLight(); pDirLight->setDirection(Ogre::Vector3(0,-1,0)); pDirLight->setType(Ogre::Light::LT_DIRECTIONAL); pNode->attachObject(pDirLight); mCamera->setNearClipDistance(1.0f); mCamera->setFarClipDistance(100000.0f); mCamera->setPosition(0,0,30.0f); mCamera->lookAt(0,0,0); mCamera->setAutoAspectRatio(true); Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(1,0,0)); }
SceneWidget::SceneWidget(QWidget *parent) : QWidget(parent) , mWindow(NULL) , mCamera(NULL) , mSceneMgr(NULL) { setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_NoSystemBackground); mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC); // Throw in a random color just to make sure multiple scenes work Ogre::Real r = Ogre::Math::RangeRandom(0, 1); Ogre::Real g = Ogre::Math::RangeRandom(0, 1); Ogre::Real b = Ogre::Math::RangeRandom(0, 1); mSceneMgr->setAmbientLight(Ogre::ColourValue(r,g,b,1)); Ogre::Light* l = mSceneMgr->createLight(); l->setType (Ogre::Light::LT_DIRECTIONAL); l->setDirection (Ogre::Vector3(-0.4, -0.7, 0.3)); l->setDiffuseColour (Ogre::ColourValue(0.7,0.7,0.7)); mCamera = mSceneMgr->createCamera("foo"); Ogre::Entity* ent = mSceneMgr->createEntity("cube", Ogre::SceneManager::PT_CUBE); ent->setMaterialName("BaseWhite"); mSceneMgr->getRootSceneNode()->attachObject(ent); mCamera->setPosition(300,300,300); mCamera->lookAt(0,0,0); mCamera->setNearClipDistance(0.1); mCamera->setFarClipDistance(3000); }
//------------------------------------------------------------------------------------- TinyOgre::TinyOgre(void) { OgreRoot = new Ogre::Root(); if(OgreRoot->restoreConfig() || OgreRoot->showConfigDialog()) Window = OgreRoot->initialise(true, "TinyOgre Render Window"); //koniecznie tuż pod konstruktorem root! else throw -1; SceneMgr = OgreRoot->createSceneManager(Ogre::ST_GENERIC); SceneMgr->setAmbientLight(Ogre::ColourValue(0.4, 0.4, 0.4)); Ogre::Light* l = SceneMgr->createLight("MainLight"); l->setPosition(20,-80,50); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("Suzanne", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);//Ponoć niektóre API to omijają, więc warto dodać Camera = SceneMgr->createCamera("PlayerCam"); Camera->setPosition(Ogre::Vector3(10,-50,10)); Camera->setOrientation(Ogre::Quaternion(1,1,0,0)); Camera->setNearClipDistance(0.1); Ogre::Viewport* vp = Window->addViewport(Camera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); Camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); }
//------------------------------------------------------------------------------------- void TutorialApplication::createScene(void) { // create your scene here :) // Set the scene's ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f)); Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode"); headNode->attachObject(ogreHead); headNode->yaw( Ogre::Degree( -90 ) ); Ogre::Entity* ogreHead2 = mSceneMgr->createEntity( "Head2", "ogrehead.mesh" ); Ogre::SceneNode* headNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "HeadNode2", Ogre::Vector3( 100, 0, 0 ) ); headNode2->attachObject( ogreHead2 ); headNode2->pitch( Ogre::Degree( -90 ) ); Ogre::Entity* ogreHead3 = mSceneMgr->createEntity( "Head3", "ogrehead.mesh" ); Ogre::SceneNode* headNode3 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "HeadNode3", Ogre::Vector3( 200, 0, 0 ) ); headNode3->attachObject( ogreHead3 ); headNode3->roll( Ogre::Degree( -90 ) ); // Create a Light and set its position Ogre::Light* light = mSceneMgr->createLight("MainLight"); light->setPosition(20.0f, 80.0f, 50.0f); }
//------------------------------------------------------------------------------------- void UndeadLand::createScene(void) { mCamera->setPosition(Ogre::Vector3(1683, 50, 2116)); mCamera->lookAt(Ogre::Vector3(1963, 50, 1660)); mCamera->setNearClipDistance(0.1); mCamera->setFarClipDistance(50000); if( mRoot->getRenderSystem()->getCapabilities()->hasCapability( Ogre::RSC_INFINITE_FAR_PLANE ) ) mCamera->setFarClipDistance(0); Ogre::Vector3 lightdir(0.55, -0.3, 0.75); lightdir.normalise(); Ogre::Light* light = mSceneMgr->createLight("tstLight"); light->setType(Ogre::Light::LT_DIRECTIONAL); light->setDirection(lightdir); light->setDiffuseColour(Ogre::ColourValue::White); light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4)); mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); if( soundeng ) { //soundeng->play2D( "dist/media/sounds/Pong_Beat_100_bpm_www.loopartists.com.wav", true ); soundeng->play2D( "dist/media/sounds/looperman-loop-00500098-00050813-shortbusmusic-piano-in-bm7-a-e.wav", true ); } terrain = new TerrainEngine( "this is a ridiculously long string", mRoot, mSceneMgr, mCamera, light ); }
void QOgrePointLightWidget::updateInfo() { Ogre::Light *l = mSceneMgr->getLight(name); QOgreLightWidget::updateInfo(); const Ogre::Vector3 &n = l->getPosition(); for (unsigned int i=0; i<3; ++i) position[i]->setValue(n[i]); }
void Simulation::createScene() { // Set the scene's ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f)); // Set up camera // Position it at 500 in Z direction mCamera->setPosition(Ogre::Vector3(100, 100, 80)); // Look back along -Z mCamera->lookAt(Ogre::Vector3(0,0,-300)); mCamera->setNearClipDistance(5); // Set up world mWorld = new World(mSceneMgr); // Create a Light and set its position Ogre::Light* light = mSceneMgr->createLight("MainLight"); light->setPosition(20.0f, 80.0f, 50.0f); // Set up GUI mHud = CEGUI::WindowManager::getSingleton().loadLayoutFromFile("hud.layout"); mRootWindow->addChild(mHud); mRootWindow->getChild("Sidebar/QuitButton")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Simulation::quitEvent, this)); mRootWindow->getChild("Sidebar/ResetButton")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Simulation::resetEvent, this)); mRootWindow->getChild("Sidebar/EnvGroupBox/TempSpinner")->subscribeEvent(CEGUI::Spinner::EventValueChanged, CEGUI::SubscriberSlot(&Simulation::tempChangedEvent, this)); mRootWindow->getChild("Sidebar/EnvGroupBox/PhSpinner")->subscribeEvent(CEGUI::Spinner::EventValueChanged, CEGUI::SubscriberSlot(&Simulation::phChangedEvent, this)); mRootWindow->getChild("Sidebar/EnvGroupBox/ACellsSpinner")->subscribeEvent(CEGUI::Spinner::EventValueChanged, CEGUI::SubscriberSlot(&Simulation::numCellsChangedEvent, this)); mRootWindow->getChild("Sidebar/EnvGroupBox/ACellsSpinner")->subscribeEvent(CEGUI::Spinner::EventValueChanged, CEGUI::SubscriberSlot(&Simulation::numCellsChangedEvent, this)); mRootWindow->getChild("Sidebar/EnvGroupBox/ACellsSpinner")->subscribeEvent(CEGUI::Spinner::EventValueChanged, CEGUI::SubscriberSlot(&Simulation::numCellsChangedEvent, this)); static_cast<CEGUI::Spinner*>(mRootWindow->getChild("Sidebar/EnvGroupBox/TempSpinner"))->setCurrentValue((double)mWorld->getTemperature()); static_cast<CEGUI::Spinner*>(mRootWindow->getChild("Sidebar/EnvGroupBox/PhSpinner"))->setCurrentValue((double)mWorld->getPH()); }
void InputBufferSample::createScene() { mSceneMgr->setAmbientLight(Ogre::ColourValue(.2, .2, .2)); Ogre::Entity* tudorEntity = mSceneMgr->createEntity("tudorhouse.mesh"); Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "TudorNode"); node->attachObject(tudorEntity); Ogre::Light* light = mSceneMgr->createLight("Light1"); light->setType(Ogre::Light::LT_POINT); light->setPosition(Ogre::Vector3(300, 150, 0)); light->setDiffuseColour(Ogre::ColourValue::White); light->setSpecularColour(Ogre::ColourValue::White); mCamera->setPosition(Ogre::Vector3(1, 1, 1)); mCamera->lookAt(Ogre::Vector3(0, 0, 0)); node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "CamNode1", Ogre::Vector3(1000, 1000, 1000)); mCamNode = node; node->attachObject(mCamera); node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "CamNode2", Ogre::Vector3(500, 500, 500)); }
//------------------------------------------------------------------------------------- void TutorialApplication::createScene(void) { mSceneMgr->setAmbientLight(Ogre::ColourValue(0.25, 0.25, 0.25)); // add the ninja Ogre::Entity *ent = mSceneMgr->createEntity("Ninja", "ninja.mesh"); Ogre::SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("NinjaNode"); node->attachObject(ent); // create the light Ogre::Light *light = mSceneMgr->createLight("Light1"); light->setType(Ogre::Light::LT_POINT); light->setPosition(Ogre::Vector3(250, 150, 250)); light->setDiffuseColour(Ogre::ColourValue::White); light->setSpecularColour(Ogre::ColourValue::White); // Create the scene node node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Ogre::Vector3(-400, 200, 400)); // Make it look towards the ninja node->yaw(Ogre::Degree(-45)); // Create the pitch node node = node->createChildSceneNode("PitchNode1"); node->attachObject(mCamera); // create the second camera node/pitch node node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode2", Ogre::Vector3(0, 200, 400)); node = node->createChildSceneNode("PitchNode2"); }