//----------------------------------------------------------------------------- void Engine::OnRenderViewSize() { if(m_pRenderWnd) m_pRenderWnd->windowMovedOrResized(); if(m_pCamera) m_pCamera->setAspectRatio( Ogre::Real(m_pViewport->getActualWidth()) / Ogre::Real(m_pViewport->getActualHeight())); }
//--------------------------------------------------------------------------- void TutorialApplication::createViewports() { Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); mCamera->setAspectRatio( Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); }
//--------------------------------------------------------------------------- void BaseApplication::createViewports(void) { // Create one viewport, entire window Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); // Alter the camera aspect ratio to match the viewport mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); }
//--------------------------------------------------------------------------- Ogre::CompositorInstance::Listener* HDRLogic::createListener(Ogre::CompositorInstance* instance) { LOG_FUNCTION HDRListener* listener = new HDRListener; Ogre::Viewport* vp = instance->getChain()->getViewport(); listener->notifyViewportSize(vp->getActualWidth(), vp->getActualHeight()); listener->notifyCompositor(instance); return listener; }
int main(int argc, char* argv[]){ cout << "Test Ogre Program" << endl; //Relative to where its executed from, not binary location Ogre::Root *mRoot = new Ogre::Root("configs/plugins.cfg","configs/config.cfg","logs/main.log"); if(!(mRoot->restoreConfig() || mRoot->showConfigDialog())){ delete mRoot; return -1; } // setup resources // Only add the minimally required resource locations to load up the Ogre head mesh Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs", "FileSystem", "General"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs/GLSL", "FileSystem", "General"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/scripts", "FileSystem", "General"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/textures", "FileSystem", "General"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/models", "FileSystem", "General"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/github/Ogre_test/data","FileSystem","General"); //Create the window Ogre::RenderWindow *mWindow = mRoot->initialise(true, "initial Render Window"); Ogre::SceneManager *sceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC); Ogre::Camera *camera = sceneManager->createCamera("PlayerCam"); camera->setPosition(Ogre::Vector3(0,0,80)); camera->lookAt(Ogre::Vector3(0,0,-300)); camera->setNearClipDistance(5); Ogre::Viewport* vp = mWindow->addViewport(camera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0,0)); camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); //Ogre::Entity* ogreHead = sceneManager->createEntity("Head","ogreHead.mesh"); Ogre::Entity* ogreHead = sceneManager->createEntity("Head","myTest.obj"); Ogre::SceneNode* headNode = sceneManager->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(ogreHead); sceneManager->setAmbientLight(Ogre::ColourValue(0.5,0.5,0.5)); //Run the system bool continueRunning = true; while(continueRunning){ mRoot->renderOneFrame(); headNode->rotate(Ogre::Vector3(0,1,0),Ogre::Radian(0.005)); if(mWindow->isClosed()){ continueRunning = false; } } delete mRoot; }
GameState* StateManager::changeState ( const std::string& state_name, Ogre::RenderWindow* window ){ _prev_state = _current_state; _current_state = _states[state_name]; window->removeAllViewports(); Ogre::Camera* camera = _current_state->getScene()->getCamera(MainCameraName); Ogre::Viewport* vp = window->addViewport(camera); vp->setBackgroundColour(Ogre::ColourValue(0.5,0.5,0.5)); camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); return _current_state; }
void MultiMgrSample::setupViewport(Ogre::SceneManager *curr) { mWindow->removeAllViewports(); Ogre::Camera *cam = curr->getCamera(CAMERA_NAME); Ogre::Viewport *vp = mWindow->addViewport(cam); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); cam->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); }
void GUIManager::ShowMainMenu(bool isVisible) { if (isVisible == true) { if (m_gui_GameMainMenu.get() == nullptr) m_gui_GameMainMenu = std::unique_ptr<GUI::GameMainMenu>(new GUI::GameMainMenu()); /* Adjust menu position */ Ogre::Viewport* viewport = RoR::Application::GetOgreSubsystem()->GetRenderWindow()->getViewport(0); int margin = (viewport->getActualHeight() / 15); m_gui_GameMainMenu->SetPosition( margin, // left viewport->getActualHeight() - m_gui_GameMainMenu->GetHeight() - margin // top ); m_gui_GameMainMenu->Show(); } else m_gui_GameMainMenu->Hide(); }
// ----------------------------------------------------------------------------- CardEditor::CardEditor(EditorProject* project, DeckEditor* parentEditor, QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags), EditorWidget(project, parentEditor), widget(0), cards(project->getCards()), current(0), hasChanged(false), notified(false), currentItem(0), cardCount(cards.size()), rsError(false) { ui.setupUi(this); // We're trying to create a 3D Render Preview. If this fails, the user // will still be able to edit stuff, but can't preview changes. try { // Create Editor RenderView widget = new OgreWidget(Util::toQString(EditorSystem::getInstance().getRenderView()), ui.ogreWidget); widget->setBaseSize(QSize(288,384)); widget->setFixedWidth(288); widget->setFixedHeight(384); widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); widget->setFocusPolicy(Qt::NoFocus); ui.ogreWidget->setAttribute(Qt::WA_PaintOnScreen); ui.ogreWidget->setAttribute(Qt::WA_NoSystemBackground); ui.ogreWidget->setAttribute(Qt::WA_NoBackground); ui.innerLayout->addWidget(widget, 1, 1); // We need a camera and Viewport in order to display anything Ogre::Camera* camera = Ogre::Root::getSingletonPtr()->getSceneManager("root")->createCamera("PlayerCam"); Ogre::Viewport* viewport = static_cast<OgreWidget*>(widget)->getRenderWindow()->addViewport(camera); camera->setAspectRatio( Ogre::Real(viewport->getActualWidth()) / Ogre::Real(viewport->getActualHeight())); // Initialize UI & associated Managers Arcomage::UI::UIManager::getInstance().bootstrap(); // Preload required Editor Fonts Arcomage::ResourceManager::getInstance().preloadResources( Arcomage::ConfigurationManager::getInstance().getPath("Fonts")+"/fonts.xml", /* unused, Music */ "", /* unused, Sound effects */ ""); } catch (Ogre::Exception& e) { rsError = true; widget = new OgreWidget("errorwidget", ui.ogreWidget, true); ToolkitUtil::getInstance().notifyError(e.what()); } populateTree(); this->connectUI(); }
MiniMapManager::MiniMapManager(Ogre::Root *root, Ogre::RenderWindow *window): mRoot(root), mWindow(window) { mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "MiniMapSceneMgr"); mCamera = mSceneMgr->createCamera("miniMapCamera"); Ogre::Viewport *vp = mWindow->addViewport(mCamera, 1, 0, 0.8, 0.2, 0.2); vp->setBackgroundColour(Ogre::ColourValue(0, 0, 0)); mCamera->setAutoAspectRatio((Ogre::Real(vp->getActualWidth())) / (Ogre::Real(vp->getActualHeight()))); mSceneMgr->setAmbientLight(Ogre::ColourValue(0.8, 0.8, 0.8)); }
// funcion que configura la camara void createCamera(Ogre::RenderWindow* window){ camera = _sceneManager->createCamera("Camera"); camera->setPosition(Ogre::Vector3(0,60,-100)); camera->lookAt(Ogre::Vector3(0,0,50)); camera->setNearClipDistance(5); Ogre::Viewport* viewport = window->addViewport(camera); viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0)); camera->setAspectRatio(Ogre::Real(viewport->getActualWidth())/Ogre::Real(viewport->getActualHeight())); }
//------------------------------------------------------------------------------------- void THIS::createViewports(void) { cout << "<TRACE><LOG><SceneManager><createViewports> " << endl; // Create one viewport, entire window Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); // Alter the camera aspect ratio to match the viewport mCamera->setAspectRatio( Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); }
void GUIManager::windowResized(Ogre::RenderWindow* rw) { int width = (int)rw->getWidth(); int height = (int)rw->getHeight(); setInputViewSize(width, height); BeamFactory *bf = BeamFactory::getSingletonPtr(); if (bf) bf->windowResized(); if (m_gui_GameMainMenu.get() != nullptr) { /* Adjust menu position */ Ogre::Viewport* viewport = RoR::Application::GetOgreSubsystem()->GetRenderWindow()->getViewport(0); int margin = (viewport->getActualHeight() / 15); m_gui_GameMainMenu->SetPosition( margin, // left viewport->getActualHeight() - m_gui_GameMainMenu->GetHeight() - margin // top ); } }
//------------------------------------------------------------------------------------- void DigitalForensicsVisualisation::createViewports(void) { // Create one viewport, entire window Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(.35,.35,.35)); // Alter the camera aspect ratio to match the viewport //mCamera->setFarClipDistance(2000); mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); mCamera->pitch(static_cast <Ogre::Radian>(-0.45)); }
// дл¤ оповещений об изменении окна рендера void Gui::windowResized(Ogre::RenderWindow* rw) { FloatSize oldViewSize = mViewSize; Ogre::Viewport * port = rw->getViewport(mActiveViewport); mViewSize.set(port->getActualWidth(), port->getActualHeight()); mLayerManager->_windowResized(mViewSize); // выравниваем рутовые окна for (VectorWidgetPtr::iterator iter = mWidgetChild.begin(); iter!=mWidgetChild.end(); ++iter) { _alignWidget((*iter), oldViewSize, mViewSize); } }
void AsteroidGame::InitViewport(void){ try { /* Retrieve scene manager and root scene node */ Ogre::SceneManager* scene_manager = ogre_root_->createSceneManager(Ogre::ST_GENERIC, "MySceneManager"); Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode(); /* Create camera object */ camera = scene_manager->createCamera("MyCamera"); Ogre::SceneNode* camera_scene_node = root_scene_node->createChildSceneNode("MyCameraNode"); camera_scene_node->attachObject(camera); camera->setNearClipDistance(camera_near_clip_distance_g); camera->setFarClipDistance(camera_far_clip_distance_g); camera->setPosition(camera_position_g); camera->lookAt(camera_look_at_g); //camera->setFixedYawAxis(true, camera_up_g); /* Create second camera object */ camera_2 = scene_manager->createCamera("MyCamera_2"); Ogre::SceneNode* camera_scene_node_2 = root_scene_node->createChildSceneNode("MyCameraNode_2"); camera_scene_node_2->attachObject(camera_2); camera_2->setNearClipDistance(camera_near_clip_distance_g); camera_2->setFarClipDistance(camera_far_clip_distance_g); camera_2->setPosition(camera_position_g); camera_2->lookAt(camera_look_at_g); //camera->setFixedYawAxis(true, camera_up_g); /*Create viewport */ Ogre::Viewport *viewport = ogre_window_->addViewport(camera, viewport_z_order_g, viewport_left_g, viewport_top_g, viewport_width_g, viewport_height_g); viewport->setAutoUpdated(true); viewport->setBackgroundColour(viewport_background_color_g); /* Set aspect ratio */ float ratio = float(viewport->getActualWidth()) / float(viewport->getActualHeight()); camera->setAspectRatio(ratio); camera_2->setAspectRatio(ratio); } catch (Ogre::Exception &e){ throw(OgreAppException(std::string("Ogre::Exception: ") + std::string(e.what()))); } catch(std::exception &e){ throw(OgreAppException(std::string("std::Exception: ") + std::string(e.what()))); } }
Player* PlayerManager::createHumanPlayer(const Ogre::String& name, Ogre::RenderWindow *window, GUI* gui) { // TODO: Handle Human Multiplayer, also this code should be somewhere else Ogre::Camera *camera = mSceneMgr->createCamera("Player1"); camera->setNearClipDistance(NEAR_CLIP_DISTANCE); Ogre::Viewport *vp = window->addViewport(camera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); HumanController* hc = new HumanController(gui); Player* player = createPlayer(name + "Human", hc, false); player->attachCamera(camera); return player; }
// для оповещений об изменении окна рендера void windowResized(Ogre::RenderWindow* _window) { if (_window->getNumViewports() > mActiveViewport) { Ogre::Viewport* port = _window->getViewport(mActiveViewport); #if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0 Ogre::OrientationMode orient = port->getOrientationMode(); if (orient == Ogre::OR_DEGREE_90 || orient == Ogre::OR_DEGREE_270) mViewSize.set(port->getActualHeight(), port->getActualWidth()); else mViewSize.set(port->getActualWidth(), port->getActualHeight()); #else mViewSize.set(port->getActualWidth(), port->getActualHeight()); #endif // обновить всех mUpdate = true; updateRenderInfo(); onResizeView(mViewSize); } }
// We will have a single viewport. If you wanted splitscreen, or a rear-view mirror, then // you may want multiple viewports. void OgreTank::createViewports(void) { // Create one viewport, entire window Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); // Alter the camera aspect ratio to match the viewport mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); Ogre::Viewport* vp2 = mWindow->addViewport(mCamera2, 1, 0.03, 0.03, 0.3, 0.3); vp2->setBackgroundColour(Ogre::ColourValue(0,0,0)); vp2->setOverlaysEnabled(false); mCamera->setAspectRatio(Ogre::Real(vp2->getActualWidth()) / Ogre::Real(vp2->getActualHeight())); }
void StateManager::setupViewport( OgreManager & _ogreManager, Ogre::Camera * camera ) { if (camera != NULL && (camera != _ogreManager.getActiveCamera())) { _ogreManager.getWindowHandle()->removeAllViewports(); // Create one viewport, entire window Ogre::Viewport* vp = _ogreManager.getWindowHandle()->addViewport(camera); //Set Background color vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); // Alter the camera aspect ratio to match the viewport camera->setAspectRatio( Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); _ogreManager.setActiveCamera(camera); } }
CAtlas::CAtlas(CEntity *pParent, Ogre::SceneNode *pRootSceneNode) : CWorldEntity("atlas", pParent, nullptr), mFirstFrame(false), mFirstFrameUpdated(false), m_pCurrentMap(nullptr), m_pNextMap(nullptr), m_pPlayer(nullptr), m_pCameraPerspective(nullptr), m_bSwitchingMaps(false), m_bPlayerTargetReached(false), mEllipticFader(CFader::ELLIPTIC_FADER, this), mAlphaFader(CFader::ALPHA_FADER, this) { LOGV("Creating the Atlas"); m_pSceneNode = pRootSceneNode->createChildSceneNode("Atlas"); // create the world camera m_pWorldCamera = pRootSceneNode->getCreator()->createCamera("WorldCamera"); m_pWorldCamera->setNearClipDistance(0.001f); m_pWorldCamera->setFarClipDistance(1000.0f); // default position m_pWorldCamera->setPosition(Ogre::Vector3(0,1,1)); m_pWorldCamera->lookAt(Ogre::Vector3(0,0,0)); //m_pWorldCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); Ogre::Viewport *vp = CGame::getSingleton().getMainViewPort(); m_pWorldCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); vp->setCamera(m_pWorldCamera); m_pWorldCamera->setOrthoWindowWidth(1.6); LOGV(" - Creating Player"); m_pPlayer = new CPlayer(this, m_pWorldCamera, CGame::getSingleton().getSceneManager()); //m_pCameraPerspective = new CAerialCameraPerspective(m_pWorldCamera, (Ogre::SceneNode*)m_pAtlas->getChildren().front()->getSceneNode()->getChild(0)); m_pCameraPerspective = new CAerialCameraPerspective(m_pWorldCamera, m_pPlayer); LOGV(" - Creating initial map"); m_pCurrentMap = new CMap(this, CMapPackPtr(new CMapPack(CFileManager::getResourcePath("maps/Atlases/LightWorld/"), "inner_house_link")), m_pSceneNode, m_pPlayer); mFirstFrame = true; //m_pCurrentMap = new CMap(this, CMapPackPtr(new CMapPack(CFileManager::getResourcePath("maps/Atlases/LightWorld/"), "link_house_left")), m_pSceneNode, m_pPlayer); m_pPlayer->enterMap(m_pCurrentMap, Ogre::Vector3(0, 2, 0)); m_pCurrentMap->start(); CMessageHandler::getSingleton().addMessage(new CMessageSwitchMap(m_pCurrentMap->getMapPack()->getName(), CMessageSwitchMap::FINISHED, m_eSwitchMapType, m_pCurrentMap, nullptr)); mEllipticFader.startFadeIn(1); }
void RenderSystem::Init() { InfoLog << "RenderSystem init...." << std::endl; mpRoot = new Ogre::Root(); bool hasConfig = false; if (mpRoot->restoreConfig()) { hasConfig = true; } else if (mpRoot->showConfigDialog()) { hasConfig = true; } if (hasConfig) { // initialise system according to user options. mpRenderWin = mpRoot->initialise(true, "Magic3D"); // Create the scene manager mpSceneMgr = mpRoot->createSceneManager(Ogre::ST_GENERIC, "MainSceneManager"); // Create and initialise the camera mpMainCam = mpSceneMgr->createCamera("MainCamera"); SetupCameraDefaultParameter(); // Create a viewport covering whole window Ogre::Viewport* vp = mpRenderWin->addViewport(mpMainCam); //vp->setBackgroundColour(Ogre::ColourValue(0, 0, 0)); vp->setBackgroundColour(Ogre::ColourValue(0.8627450980392157, 0.8627450980392157, 0.8627450980392157)); // Update the camera aspect ratio to that of the viewport mpMainCam->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); mpRoot->addFrameListener(MagicListener::GetSingleton()); Ogre::WindowEventUtilities::addWindowEventListener(mpRenderWin, MagicListener::GetSingleton()); //get supported syntax information const Ogre::GpuProgramManager::SyntaxCodes &syntaxCodes = Ogre::GpuProgramManager::getSingleton().getSupportedSyntax(); for (Ogre::GpuProgramManager::SyntaxCodes::const_iterator iter = syntaxCodes.begin();iter != syntaxCodes.end();++iter) { InfoLog << "supported syntax : " << (*iter) << std::endl; } } else { //Exist } }
PFCamera::PFCamera(Ogre::SceneManager* mSceneMgr, Ogre::RenderWindow* mWindow) { // Create the camera mCamera = mSceneMgr->createCamera("PlayerCam"); // Position it at 500 in Z direction mCamera->setPosition(Ogre::Vector3(0,0,200)); // Look back along -Z mCamera->lookAt(Ogre::Vector3(0,0,0)); mCamera->setNearClipDistance(5); // Create one viewport, entire window Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); // Alter the camera aspect ratio to match the viewport mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); }
EC_OgreCamera::EC_OgreCamera(Foundation::ModuleInterface* module) : Foundation::ComponentInterface(module->GetFramework()), renderer_(checked_static_cast<OgreRenderingModule*>(module)->GetRenderer()), attached_(false), camera_(0) { RendererPtr renderer = renderer_.lock(); Ogre::SceneManager* scene_mgr = renderer->GetSceneManager(); Ogre::Viewport* viewport = renderer->GetViewport(); camera_ = scene_mgr->createCamera(renderer->GetUniqueObjectName()); // Set default values for the camera camera_->setNearClipDistance(0.1f); camera_->setFarClipDistance(2000.f); camera_->setAspectRatio(Ogre::Real(viewport->getActualWidth() / Ogre::Real(viewport->getActualHeight()))); camera_->setAutoAspectRatio(true); }
void DemoApplication::InitCamera() { // Create the camera mCamera = mSceneMgr->createCamera("PlayerCam"); // Position it at 500 in Z direction mCamera->setPosition(Ogre::Vector3(0,0,80)); // Look back along -Z mCamera->lookAt(Ogre::Vector3(0,0,-200)); mCamera->setNearClipDistance(0.1f); // create view ports // Create one viewport, entire window Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); // Alter the camera aspect ratio to match the viewport mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); }
int MyApp::start() { _root = new Ogre::Root(); if(!_root->restoreConfig()) { _root->showConfigDialog(); _root->saveConfig(); } _pTrackManager = new TrackManager; _pSoundFXManager = new SoundFXManager; Ogre::RenderWindow* window = _root->initialise(true,"MyApp Example"); _sceneManager = _root->createSceneManager(Ogre::ST_GENERIC); Ogre::Camera* cam = _sceneManager->createCamera("MainCamera"); cam->setPosition(Ogre::Vector3(7,10.5,8)); cam->lookAt(Ogre::Vector3(0,3.5,0)); cam->setNearClipDistance(5); cam->setFarClipDistance(10000); Ogre::Viewport* viewport = window->addViewport(cam); viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0)); double width = viewport->getActualWidth(); double height = viewport->getActualHeight(); cam->setAspectRatio(width / height); loadResources(); createScene(); createOverlay(); Ogre::SceneNode *node = _sceneManager->getSceneNode("Neptuno"); _framelistener = new MyFrameListener(this, window, cam, node, _overlayManager, _sceneManager); _root->addFrameListener(_framelistener); // Reproducción del track principal... this->_mainTrack->play(); _root->startRendering(); return 0; }
void BaseManager::createSceneManager(){ mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC, "BaseSceneManager"); mCamera = mSceneManager->createCamera("BaseCamera"); mCamera->setNearClipDistance(5); mCamera->setPosition(100, 100, 100); mCamera->lookAt(0, 0, 0); // Create one viewport, entire window Ogre::Viewport* vp = mWindow->addViewport(mCamera); // Alter the camera aspect ratio to match the viewport mCamera->setAspectRatio((float)vp->getActualWidth() / (float)vp->getActualHeight()); mSceneManager->setAmbientLight(Ogre::ColourValue::White); Ogre::Light* light = mSceneManager->createLight("MainLight"); light->setType(Ogre::Light::LT_DIRECTIONAL); Ogre::Vector3 vec(-0.3f, -0.3f, -0.3f); vec.normalise(); light->setDirection(vec); }
int startup(){ _root = new Ogre::Root("plugins_d.cfg"); /* if(!_root->showConfigDialog()){ return -1; } */ Ogre::RenderSystem* _rs = _root->getRenderSystemByName("Direct3D9 Rendering Subsystem"); // or use "OpenGL Rendering Subsystem" _root->setRenderSystem(_rs); _rs->setConfigOption("Full Screen", "No"); _rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour"); _rs->setConfigOption("FSAA", "0"); _rs->setConfigOption("Floating-point mode", "Fastest"); _rs->setConfigOption("Use Multihead", "Auto"); _rs->setConfigOption("VSync", "No"); _rs->setConfigOption("VSync Interval", "1"); Ogre::RenderWindow* window = _root->initialise(true, "Ventana Ogre"); _sceneManager = _root->createSceneManager(Ogre::ST_GENERIC); Ogre::Camera* camera = _sceneManager->createCamera("Camera"); camera->setPosition(Ogre::Vector3(0.0f,300.0f,-1000.0f)); camera->lookAt(Ogre::Vector3(0,0,0)); camera->setNearClipDistance(5); Ogre::Viewport* viewport = window->addViewport(camera); viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0)); camera->setAspectRatio(Ogre::Real(viewport->getActualWidth()/viewport->getActualHeight())); _listener = new FrameListenerProyectos(window,camera); _root->addFrameListener(_listener); loadResources(); createScene(); _root->startRendering(); return 0; }
//------------------------------------------------------------------------------------- void SpaceLogin::createScene(void) { g_accountName = kbe_getLastAccountName(); if(g_accountName.size() == 0) g_accountName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); mTrayMgr->createButton(OgreBites::TL_CENTER, "login", "fast login", 120); Ogre::StringVector values; values.push_back(g_accountName); mTrayMgr->createParamsPanel(OgreBites::TL_CENTER, "accountName", 300, values); mTrayMgr->showCursor(); mTrayMgr->hideFrameStats(); mTrayMgr->hideLogo(); mTrayMgr->hideBackdrop(); mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); // Create the camera mActiveCamera = mSceneMgr->createCamera("PlayerCam"); // Position it at 500 in Z direction mActiveCamera->setPosition(Ogre::Vector3(0,0,80)); // Look back along -Z mActiveCamera->lookAt(Ogre::Vector3(0,0,-300)); mActiveCamera->setNearClipDistance(5); mCameraMan = new OgreBites::SdkCameraMan(mActiveCamera); // create a default camera controller mCameraMan->setTopSpeed(7.0f); OgreApplication::getSingleton().setCurrCameraMan(mCameraMan); // Create one viewport, entire window Ogre::Viewport* vp = mWindow->addViewport(mActiveCamera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); // Alter the camera aspect ratio to match the viewport mActiveCamera->setAspectRatio( Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); }
void Game::initRendering() { #ifdef _DEBUG const char* plugin_file = "plugins_d.cfg"; #else const char* plugin_file = "plugins.cfg"; #endif m_ogreRoot = new Ogre::Root(plugin_file); m_ogreRoot->showConfigDialog(); m_ogreRoot->initialise(true); m_renderWindow = m_ogreRoot->getAutoCreatedWindow(); //createRenderWindow("mkdemo", 800, 600, false); m_ogreSceneMgr = m_ogreRoot->createSceneManager(Ogre::ST_GENERIC); m_ogreCamera = m_ogreSceneMgr->createCamera("main_cam"); Ogre::Viewport* viewport = m_renderWindow->addViewport(m_ogreCamera); m_ogreCamera->setAspectRatio(viewport->getActualWidth() / (float)viewport->getActualHeight()); // DebugDrawer singleton new DebugDrawer(m_ogreSceneMgr, .75f); loadOgreResources(); // overlay Ogre::Overlay* hud = Ogre::OverlayManager::getSingleton().getByName("Game/HUD"); hud->show(); if (m_disableShadows) m_ogreSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE); else m_ogreSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE); m_ogreCamera->setNearClipDistance(0.1f); if (!m_startWithFreelook) m_playerCam = new CameraTPP(m_ogreCamera, NULL); else m_playerCam = new CameraFPP(m_ogreCamera, NULL); m_ogreSceneMgr->setAmbientLight(Ogre::ColourValue(0.3f, 0.3f, 0.3f)); // please note it's usually changed on level deserialization with RenderSettingsSetter }