//------------------------------------------------------------------------------------------- void MagickWidget::loadMesh(Ogre::MeshPtr pMesh) { QString directory(OgitorsRoot::getSingletonPtr()->GetProjectOptions()->ProjectDir.c_str()); if(directory.isEmpty()) directory = "./"; QDir(directory).mkpath("entitycache"); Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( "MeshMagickTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8A8 , Ogre::TU_RENDERTARGET ); Ogre::RenderTexture *rttTex = texture->getBuffer()->getRenderTarget(); Ogre::SceneManager *mSceneMgr = Ogre::Root::getSingletonPtr()->createSceneManager("OctreeSceneManager", "MeshMagickTexMgr"); Ogre::Light *dirl = mSceneMgr->createLight("DisplayLight"); dirl->setDirection(-1,-1,-1); dirl->setDiffuseColour(1,1,1); dirl->setType(Ogre::Light::LT_DIRECTIONAL); Ogre::Camera* RTTCam = mSceneMgr->createCamera("MeshMagickCam"); RTTCam->setNearClipDistance(0.01F); RTTCam->setFarClipDistance(0); RTTCam->setAspectRatio(1); RTTCam->setFOVy(Ogre::Degree(90)); RTTCam->setPosition(0,0,1); RTTCam->lookAt(0,0,0); Ogre::Viewport *v = rttTex->addViewport( RTTCam ); v->setClearEveryFrame( true ); v->setBackgroundColour(Ogre::ColourValue(0,0,0)); Ogre::Entity *mEntity; mEntity = mSceneMgr->createEntity("scbDisplay", pMesh->getName()); mSceneMgr->getRootSceneNode()->attachObject(mEntity); Ogre::Vector3 vSize = mEntity->getBoundingBox().getHalfSize(); Ogre::Vector3 vCenter = mEntity->getBoundingBox().getCenter(); vSize += Ogre::Vector3(vSize.z, vSize.z, vSize.z); float maxsize = std::max(std::max(vSize.x,vSize.y),vSize.z); vSize = Ogre::Vector3(0, 0, maxsize * 1.15f) + vCenter; RTTCam->setPosition(vSize.x,vSize.y,vSize.z); RTTCam->lookAt(vCenter.x,vCenter.y,vCenter.z); rttTex->update(); Ogre::String imagefile = OgitorsUtils::QualifyPath(directory.toStdString() + "/entitycache/meshmagick.png"); rttTex->writeContentsToFile(imagefile); mEntity->detachFromParent(); mSceneMgr->destroyEntity(mEntity); rttTex->removeAllViewports(); Ogre::Root::getSingletonPtr()->destroySceneManager(mSceneMgr); mDisplayWidget->setImage(QString(imagefile.c_str())); }
int startup(){ _root = new Ogre::Root("plugins_d.cfg"); if(!_root->showConfigDialog()){ return -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(500,100,500)); 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; }
int Hundir::start() { _root = new Ogre::Root(); if(!_root->restoreConfig()) { _root->showConfigDialog(); _root->saveConfig(); } Ogre::RenderWindow* window = _root->initialise(true,"Hundir Example"); _sceneManager = _root->createSceneManager(Ogre::ST_GENERIC); Ogre::Camera* cam = _sceneManager->createCamera("MainCamera"); cam->setPosition(Ogre::Vector3(-10,30,35)); cam->lookAt(Ogre::Vector3(0,0,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(); _framelistener = new MyFrameListener(window, cam, _sceneManager); _root->addFrameListener(_framelistener); _root->startRendering(); return 0; }
void SingleplayerGame::createScene(std::vector<std::string> partyNames){ auto scnMgr = mRenderer->mSceneManager; auto root = scnMgr->getRootSceneNode(); Ogre::Camera* camera = mRenderer->mCamera; mRoomRoot = root->createChildSceneNode(); scnMgr->setSkyBox(true, "Examples/MorningSkyBox", 5000, true); // Set ambient light scnMgr->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3)); scnMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE); // Create a light mMainLight = scnMgr->createLight(BaseGame::mainLightName); mMainLight->setPosition(0, 500, 0); mMainLight->setType(Ogre::Light::LT_POINT); mMainLight->setDiffuseColour(.5, .5, .5); // Create ground plane ground = new Plane(scnMgr, mRoomRoot); // Add test objects Player* p = new Player(scnMgr, mRoomRoot, mPlayerBank->getPlayerInfo(partyNames[0]), Ogre::Vector3(500, 0, 200), mSoundBank); myParty.push_back(p); Player* p2 = new Player(scnMgr, mRoomRoot, mPlayerBank->getPlayerInfo(partyNames[1]), Ogre::Vector3(500, 0, 0), mSoundBank); myParty.push_back(p2); Player* p3 = new Player(scnMgr, mRoomRoot, mPlayerBank->getPlayerInfo(partyNames[2]), Ogre::Vector3(500, 0, -200), mSoundBank); myParty.push_back(p3); Player* p4 = new Player(scnMgr, mRoomRoot, mPlayerBank->getPlayerInfo("Mecha-Scoot"), Ogre::Vector3(-500, 0, 200), mSoundBank); enemyParty.push_back(p4); Player* p5 = new Player(scnMgr, mRoomRoot, mPlayerBank->getPlayerInfo("SSJVirginia"), Ogre::Vector3(-500, 0, 0), mSoundBank); enemyParty.push_back(p5); Player* p6 = new Player(scnMgr, mRoomRoot, mPlayerBank->getPlayerInfo("Metal Scoot"), Ogre::Vector3(-500, 0, -200), mSoundBank); enemyParty.push_back(p6); // Set Camera Position cameraInitialPosition = Ogre::Vector3(1100, 250, 700); cameraInitialLookAt = Ogre::Vector3(0, 0, 0); camera->setPosition(cameraInitialPosition); camera->lookAt(cameraInitialLookAt); }
void Player::_handleCamera() { Ogre::Camera *cam = indie::GameManager::getCamera(); cam->setPosition(gameObject->getPosition().x, cam->getPosition().y, gameObject->getPosition().z + 300); }
int main(int argc, char* argv[]){ cout << "Test Ogre Program blaha" << 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"); //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::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; }
void application::create_camera() { cam = scene_mgr->createCamera("PlayerCam"); cam->setPosition(Ogre::Vector3 {0, 0, 80}); cam->lookAt(Ogre::Vector3 {0, 0, -300}); cam->setNearClipDistance(5); cameraman = new OgreBites::SdkCameraMan(cam); }
void GraphicsImpl::createCamera() { camera = sceneMgr->createCamera("MainCamera"); // Position it at 500 in Z direction camera->setPosition(Ogre::Vector3(0, 50, 100)); // Look back along -Z camera->lookAt(Ogre::Vector3(0, -10, 0)); camera->setNearClipDistance(5); camera->setFarClipDistance(0); }
// 设置眼睛的位置, ogre 坐标 VOID CEngineInterface::Camera_SetEyePos(const fVector3& fvPos) { if(m_pFairySystem) { Ogre::Camera* pOgreCamera = m_pFairySystem->getCamera(); pOgreCamera->setPosition(Ogre::Vector3(fvPos.x, fvPos.y, fvPos.z)); } }
// 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 BaseApp::createCamera() { Ogre::Camera* cam = mSceneMgr->createCamera("PlayerCam"); cam->setPosition(0,0,0); cam->lookAt(0,0,0); //cam->setAutoAspectRatio(true); cam->setNearClipDistance(1); cam->setFarClipDistance(10000); mCameraMan = new OgreBites::SdkCameraMan(cam); mCameraMan->setTopSpeed(1000); }
// 设置眼睛的位置, ogre 坐标 VOID CRenderSystem::Camera_SetEyePos(const fVector3& fvPos) { if(m_pRenderSystem) { Ogre::Camera* pOgreCamera = m_pRenderSystem->getCamera(); pOgreCamera->setPosition(Ogre::Vector3(fvPos.x, fvPos.y, fvPos.z)); } }
//------------------------------------------------------------------------ void TApplySetup_CameraUp::WorkFromThread_Ogre() { Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera(); nsMathTools::TVector3 point(0,0,0); pCamera->setPosition(point.x, point.y, point.z); pCamera->lookAt(mVCameraUp.x, mVCameraUp.y, mVCameraUp.z); Ogre::Degree degree; degree = 90; Ogre::Radian rad; rad = degree.valueRadians(); pCamera->pitch(rad); }
void ReliefApp::GenerateRelief() { //Get depth data Ogre::TexturePtr depthTex = Ogre::TextureManager::getSingleton().createManual( "DepthTexture", // name Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, // type 512, // width 512, // height 0, // number of mipmaps //Ogre::PF_B8G8R8A8, // pixel format Ogre::PF_FLOAT32_R, Ogre::TU_RENDERTARGET ); Ogre::RenderTarget* pTarget = depthTex->getBuffer()->getRenderTarget(); Ogre::Camera* pOrthCam = MagicCore::RenderSystem::GetSingleton()->GetMainCamera(); pOrthCam->setProjectionType(Ogre::PT_ORTHOGRAPHIC); pOrthCam->setOrthoWindow(3, 3); pOrthCam->setPosition(0, 0, 3); pOrthCam->lookAt(0, 0, 0); pOrthCam->setAspectRatio(1.0); pOrthCam->setNearClipDistance(0.5); pOrthCam->setFarClipDistance(5); Ogre::Viewport* pViewport = pTarget->addViewport(pOrthCam); pViewport->setDimensions(0, 0, 1, 1); MagicCore::RenderSystem::GetSingleton()->RenderLightMesh3D("RenderMesh", "Depth", mpLightMesh); MagicCore::RenderSystem::GetSingleton()->Update(); Ogre::Image img; depthTex->convertToImage(img); std::vector<double> heightField(512 * 512); for(int x = 0; x < 512; x++) { for(int y = 0; y < 512; y++) { heightField.at(x * 512 + y) = (img.getColourAt(x, 511 - y, 0))[1]; } } Ogre::TextureManager::getSingleton().remove("DepthTexture"); // MagicDGP::LightMesh3D* pReliefMesh = MagicDGP::ReliefGeneration::PlaneReliefFromHeightField(heightField, 511, 511); //MagicDGP::LightMesh3D* pReliefMesh = MagicDGP::ReliefGeneration::CylinderReliefFromHeightField(heightField, 511, 511); if (pReliefMesh != NULL) { delete mpLightMesh; mpLightMesh = pReliefMesh; mpLightMesh->UnifyPosition(2); mpLightMesh->UpdateNormal(); } MagicCore::RenderSystem::GetSingleton()->SetupCameraDefaultParameter(); MagicCore::RenderSystem::GetSingleton()->RenderLightMesh3D("RenderMesh", "MyCookTorrance", mpLightMesh); }
void World::EnableFreeCamera( bool bEnable ) { assert(m_pRenderSystem->m_pMainCamera && m_cameraMan); if(!bEnable) { Ogre::Camera* cam = m_pRenderSystem->m_pMainCamera; const Ogre::Vector3 pos = cam->getPosition(); cam->setPosition(0, 24, 0); cam->lookAt(0, 0, 8); } m_bFreeCamMode = bEnable; }
void DotSceneLoader::processCamera(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent) { // Process attributes Ogre::String name = getAttrib(XMLNode, "name"); Ogre::String id = getAttrib(XMLNode, "id"); // Ogre::Real fov = getAttribReal(XMLNode, "fov", 45); // Ogre::Real aspectRatio = getAttribReal(XMLNode, "aspectRatio", 1.3333); Ogre::String projectionType = getAttrib(XMLNode, "projectionType", "perspective"); // Create the camera Ogre::Camera *pCamera = mSceneMgr->createCamera(name); // Set the projection type if (projectionType == "perspective") pCamera->setProjectionType(Ogre::PT_PERSPECTIVE); else if (projectionType == "orthographic") pCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); rapidxml::xml_node<>* pElement; // Process clipping (?) pElement = XMLNode->first_node("clipping"); if (pElement) { Ogre::Real nearDist = getAttribReal(pElement, "near"); if (nearDist > 0) pCamera->setNearClipDistance(nearDist); Ogre::Real farDist = getAttribReal(pElement, "far"); pCamera->setFarClipDistance(farDist); } // Process position (?) pElement = XMLNode->first_node("position"); if (pElement) pCamera->setPosition(parseVector3(pElement)); // Process rotation (?) pElement = XMLNode->first_node("rotation"); if (pElement) pCamera->setOrientation(parseQuaternion(pElement)); // construct a scenenode is no parent if (!pParent) { Ogre::SceneNode* pNode = mAttachNode->createChildSceneNode(name); pNode->setPosition(pCamera->getPosition()); pNode->setOrientation(pCamera->getOrientation()); pNode->scale(1, 1, 1); } }
static void setupScene() { LOGI("------->setupScene()"); Ogre::ConfigFile cf; cf.load(openAPKFile("resources.cfg")); Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); while (seci.hasMoreElements()) { Ogre::String sec, type, arch; sec = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); i++) { type = i->first; arch = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec); } } Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup( Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); gSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC); Ogre::Camera* camera = gSceneMgr->createCamera("MyCam"); Ogre::Entity* pEntity = gSceneMgr->createEntity("SinbadInstance", "Sinbad.mesh"); Ogre::SceneNode* pNode = gSceneMgr->getRootSceneNode()->createChildSceneNode(); pNode->attachObject(pEntity); Ogre::Light* pDirLight = gSceneMgr->createLight(); pDirLight->setDirection(Ogre::Vector3(0, -1, 0)); pDirLight->setType(Ogre::Light::LT_DIRECTIONAL); pNode->attachObject(pDirLight); camera->setNearClipDistance(1.0f); camera->setFarClipDistance(100000.0f); camera->setPosition(0, 0, 20.0f); camera->lookAt(0, 0, 0); camera->setAutoAspectRatio(true); Ogre::Viewport* vp = gRenderWnd->addViewport(camera); vp->setBackgroundColour(Ogre::ColourValue(1, 0, 0)); LOGI("<-------setupScene()"); }
//We're not sure whether return a reference to a vector is such a great idea. void CinematicManager::createPerspectiveCamera(Ogre::Real windowW, Ogre::Real windowH, const Ogre::Vector3 &initialPos, const Ogre::Quaternion &initialOrient, Control* control) { Ogre::Camera* cam = _scnMgr->createCamera(PERSP_CAM_NAME + Ogre::StringConverter::toString(_camCurId)); cam->setNearClipDistance(1.0f); cam->setFarClipDistance(400.0f); cam->setPosition(0.0f, 0.0f, 0.0f); cam->setAspectRatio(windowW / windowH); Ogre::SceneNode* defaultNode = _scnMgr->createSceneNode(); defaultNode->setPosition(initialPos); //It's in local space. defaultNode->setOrientation(initialOrient); defaultNode->attachObject(cam); _camsVec.push_back(new ZCameraInfo(_camsVec.size(), "PERSPECTIVE", cam->getName(), control, cam)); }
void CinematicManager::createOrthoCamera(Ogre::Real windowW, Ogre::Real windowH, const Ogre::Vector3 &initialPos, const Ogre::Quaternion &initialOrient, Control* control) { Ogre::Camera* cam = _scnMgr->createCamera(ORTHO_CAM_NAME + Ogre::StringConverter::toString(_camCurId)); cam->setProjectionType(Ogre::PT_ORTHOGRAPHIC); cam->setOrthoWindow(100, 50); cam->setNearClipDistance(1); cam->setPosition(0.0f, 0.0f, 0.0f); //cam->setFarClipDistance(100.0f); cam->setFOVy(Ogre::Radian(Ogre::Math::PI / 2.0f)); Ogre::SceneNode* defaultNode = _scnMgr->createSceneNode(); defaultNode->setPosition(initialPos); defaultNode->setOrientation(initialOrient); defaultNode->attachObject(cam); _camsVec.push_back(new ZCameraInfo(_camsVec.size(), "ORTHOGRAPHIC", cam->getName(), control, cam)); }
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 TShowTankWoT_test::ShowTanks(int cnt) { Ogre::SceneManager* pSM = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetSceneManager(); pSM->setAmbientLight(Ogre::ColourValue(1, 1, 1)); // light Ogre::String nameLight = "mainLight"; Ogre::Light* pLight = NULL; if( pSM->hasLight(nameLight) ) pLight = pSM->getLight(nameLight); else pLight = pSM->createLight(nameLight); pLight->setType(Ogre::Light::LT_SPOTLIGHT); pLight->setCastShadows(false); pLight->setVisible(true); Ogre::Vector3 posLight(0,0,0); pLight->setPosition(posLight); Ogre::Vector3 dirLight(1,0,0); dirLight.normalise(); pLight->setDirection(dirLight); //pLight->setSpotlightRange(Ogre::Degree(20.0f), Ogre::Degree(25.0f), 0.95f); pLight->setDiffuseColour(1.0f, 1.0f, 1.0f); pLight->setDiffuseColour(1.0f, 1.0f, 1.0f); pLight->setSpecularColour(1.0f, 1.0f, 1.0f); //pLight->setAttenuation(1000.0f, 1.0f, 0.0005f, 0.0f); // light Ogre::Vector3 pos; pos.y = 0; pos.z = 0; for( int i = 0 ; i < cnt ; i++ ) { pos.x = i*50; ShowTank(i, pos); } Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera(); pCamera->setPosition(160,160,160); pCamera->lookAt(0,0,0); }
//---------------------------------------------------------------------------------------- ImageConverter::ImageConverter(const size_t& width/*=128*/, const size_t& height/*=128*/) { mWidth = width; mHeight = height; mResourceManager = Ogre::ResourceGroupManager::getSingletonPtr(); mResourceManager->createResourceGroup("QTImageConverter"); mResourceManager->initialiseResourceGroup("QTImageConverter"); mSceneMgrPtr = Ogre::Root::getSingletonPtr()->createSceneManager("OctreeSceneManager", "QTImageConverterSceneManager"); mSceneMgrPtr->setAmbientLight(Ogre::ColourValue(1, 1, 1)); Ogre::TexturePtr rendertexture = Ogre::TextureManager::getSingleton().createManual("RenderTex", "QTImageConverter", Ogre::TEX_TYPE_2D, mWidth, mHeight, 1, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET); mRttTex = rendertexture->getBuffer()->getRenderTarget(); // create our plane to set a texture to Ogre::Plane plane(Ogre::Vector3::UNIT_Z, 0); Ogre::MeshManager::getSingleton().createPlane("terrain", "QTImageConverter", plane, 100, 100, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Y); // attach the plane to the scene manager and rotate it so the camera can see it mEntityTerrain = mSceneMgrPtr->createEntity("terrainEntity", "terrain"); Ogre::SceneNode* node = mSceneMgrPtr->getRootSceneNode()->createChildSceneNode(); node->attachObject(mEntityTerrain); mEntityTerrain->setCastShadows(false); Ogre::Camera* RTTCam = mSceneMgrPtr->createCamera("QTImageConverterCam"); RTTCam->setNearClipDistance(0.01F); RTTCam->setFarClipDistance(0); RTTCam->setAspectRatio(1); RTTCam->setFOVy(Ogre::Degree(90)); RTTCam->setPosition(0, 0, 50); RTTCam->lookAt(0, 0, 0); Ogre::Viewport *v = mRttTex->addViewport(RTTCam); v->setBackgroundColour(Ogre::ColourValue(1, 1, 1)); v->setClearEveryFrame(true); }
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; }
GameCamera* CameraFactory::make(const rapidjson::Value& jsonobj){ // Create the sphere Ogre::Camera* camera = game_manager->GetSceneManager()->createCamera(jsonobj["name"].GetString()); SpaceObject*spaceobj=game_manager->getSpaceObject(jsonobj["attached_object"].GetString()); // Set the node's position Eigen::Vector3f positionVec=spaceobj->position.cast<float>(); camera->setPosition(Ogre::Vector3( static_cast<Ogre::Real*>(positionVec.data()) )); // Set the node's orientation Eigen::Quaterniond attitude=spaceobj->attitude; camera->setOrientation(Ogre::Quaternion(attitude.w(),attitude.x(),attitude.y(),attitude.z() )); camera->setNearClipDistance(jsonobj["near_clip"].GetDouble()); camera->setFarClipDistance(jsonobj["far_clip"].GetDouble()); GameCamera* gamecamera=new GameCamera(camera,spaceobj); return gamecamera; }
//--------------------------------------------------------------------------------------------- void TEditorMapLogic::LoadSettingCamera() { Ogre::Vector3 pos( -4.225f, 44.0f, -6.4f ); Ogre::Quaternion dir( 0.279825151f, -0.0655403361f, -0.932625532f, -0.218426302f ); GetSettings()->BeginGroup( "SettingCamera" ); pos.x = GetSettings()->ReadEntry<float>( "pos_x", &pos.x ); pos.y = GetSettings()->ReadEntry<float>( "pos_y", &pos.y ); pos.z = GetSettings()->ReadEntry<float>( "pos_z", &pos.z ); dir.x = GetSettings()->ReadEntry<float>( "dir_x", &dir.x ); dir.y = GetSettings()->ReadEntry<float>( "dir_y", &dir.y ); dir.z = GetSettings()->ReadEntry<float>( "dir_z", &dir.z ); dir.w = GetSettings()->ReadEntry<float>( "dir_w", &dir.w ); Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera(); pCamera->setPosition( pos ); pCamera->setOrientation( dir ); pCamera->setNearClipDistance( 0.01f ); }
void InputHandler::miniMap(){ Ogre::TexturePtr tex = Ogre::Root::getSingletonPtr()->getTextureManager()->createManual( "RTT", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET); Ogre::RenderTexture *rtex = tex->getBuffer()->getRenderTarget(); Ogre::Camera *cam = mSceneMgr->createCamera("MiniCam"); //Vector3 fool = Ogre::Vector3(1550,0,1250); cam->setPosition(0, 300, 0); cam->lookAt(750,50,750); Ogre::Viewport *v = rtex->addViewport(cam); v->setOverlaysEnabled(false); v->setClearEveryFrame(true); v->setBackgroundColour(Ogre::ColourValue::Black); CEGUI::Texture &guiTex = mGUIRenderer->createTexture(tex); CEGUI::Imageset &imageSet = CEGUI::ImagesetManager::getSingleton().create("RTTImageset", guiTex); imageSet.defineImage("RTTImage", CEGUI::Point(0.0f, 0.0f), CEGUI::Size(guiTex.getSize().d_width, guiTex.getSize().d_height), CEGUI::Point(0.0f, 0.0f)); mini_map = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "RTTWindow"); mini_map->setSize(CEGUI::UVector2(CEGUI::UDim(0.3f, 0),CEGUI::UDim(0.2f, 0))); mini_map->setPosition(CEGUI::UVector2(CEGUI::UDim(0.69f, 0),CEGUI::UDim(0.0f, 0))); mini_map->setProperty("Image", CEGUI::PropertyHelper::imageToString(&imageSet.getImage("RTTImage"))); sheet->addChildWindow(mini_map); mini_map->setVisible(false); }
/** * This is the most basic "triangle" example, done as a Scene in Ogre. */ Ogre::SceneManager* createTriangleScene() { Ogre::SceneManager* scene = mRoot->createSceneManager(Ogre::ST_GENERIC); // Configure camera (~ view & projection transforms, i.e. gluLookAt + glOrtho) Ogre::Camera* camera = scene->createCamera("MainCamera"); // We can use an arbitrary name here camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); camera->setOrthoWindow(2, 2); // ~ glOrtho(-1, 1, -1, 1) camera->setAspectRatio((float) mWindow->getWidth() / mWindow->getHeight()); camera->setNearClipDistance(0.5); camera->setPosition(Ogre::Vector3(0,0,1)); // Move camera away from (0, 0, 0), otherwise the triangle at z=0 will be clipped // Now add some geometry to the scene Ogre::ManualObject* triangle = scene->createManualObject("Triangle"); // ~ glBegin, glVertex, glEnd // "BaseWhiteNoLighting" is a built-in name for a basic non-lit material triangle->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST); triangle->position(0, 0.5, 0); // ~ glVertex. // Contrary to OpenGL we *first* must create the vertex triangle->colour(Ogre::ColourValue::Red); // .. and then provide its attributes such as color (~ glColor) triangle->position(-0.5, -0.5, 0); triangle->colour(Ogre::ColourValue::Green); triangle->position(0.5, -0.5, 0); triangle->colour(Ogre::ColourValue::Blue); triangle->end(); // Add the created triangle object to the scene graph // For this we create a SceneNode object, which will combine information about // the object's geometry with its modeling transform // (see frameRenderingQueued to understand how to rotate the triangle by changing this transform) scene->getRootSceneNode()->createChildSceneNode("Triangle")->attachObject(triangle); // Exercise 1: Create new object, add vertices, attach the object to a new SceneNode // ... return scene; }
void OgreApplication::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 */ Ogre::Camera* 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 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); } 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()))); } }
void DotSceneLoader::processCamera(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent) { // Process attributes Ogre::String name = getAttrib(XMLNode, "name"); Ogre::String id = getAttrib(XMLNode, "id"); Ogre::Real fov = getAttribReal(XMLNode, "fov", 45); Ogre::Real aspectRatio = getAttribReal(XMLNode, "aspectRatio", 1.3333); Ogre::String projectionType = getAttrib(XMLNode, "projectionType", "perspective"); // Create the camera Ogre::Camera *pCamera = mSceneMgr->createCamera(name); //TODO: make a flag or attribute indicating whether or not the camera should be attached to any parent node. //if(pParent) // pParent->attachObject(pCamera); // Set the field-of-view //! @todo Is this always in degrees? //pCamera->setFOVy(Ogre::Degree(fov)); // Set the aspect ratio //pCamera->setAspectRatio(aspectRatio); // Set the projection type if (projectionType == "perspective") pCamera->setProjectionType(Ogre::PT_PERSPECTIVE); else if (projectionType == "orthographic") pCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); rapidxml::xml_node<>* pElement; // Process clipping (?) pElement = XMLNode->first_node("clipping"); if (pElement) { Ogre::Real nearDist = getAttribReal(pElement, "near"); pCamera->setNearClipDistance(nearDist); Ogre::Real farDist = getAttribReal(pElement, "far"); pCamera->setFarClipDistance(farDist); } // Process position (?) pElement = XMLNode->first_node("position"); if (pElement) pCamera->setPosition(parseVector3(pElement)); // Process rotation (?) pElement = XMLNode->first_node("rotation"); if (pElement) pCamera->setOrientation(parseQuaternion(pElement)); // Process normal (?) pElement = XMLNode->first_node("normal"); if (pElement) ;//!< @todo What to do with this element? // Process lookTarget (?) pElement = XMLNode->first_node("lookTarget"); if (pElement) ;//!< @todo Implement the camera look target // Process trackTarget (?) pElement = XMLNode->first_node("trackTarget"); if (pElement) ;//!< @todo Implement the camera track target // Process userDataReference (?) pElement = XMLNode->first_node("userDataReference"); if (pElement) ;//!< @todo Implement the camera user data reference // construct a scenenode is no parent if (!pParent) { Ogre::SceneNode* pNode = mAttachNode->createChildSceneNode(name); pNode->setPosition(pCamera->getPosition()); pNode->setOrientation(pCamera->getOrientation()); pNode->scale(1, 1, 1); } }
int main( int argc, char** argv ) { // initialize the entire render system RenderSystem* render_system = RenderSystem::get(); QApplication app( argc, argv ); // make the render window RenderWidget* window = new RenderWidget( render_system ); window->setWindowTitle( "I hope this is not all black." ); QVBoxLayout* layout = new QVBoxLayout; layout->addWidget( window ); QPushButton* hide_button = new QPushButton( "hide" ); layout->addWidget( hide_button ); QPushButton* show_button = new QPushButton( "show" ); layout->addWidget( show_button ); QWidget container; container.setLayout( layout ); container.resize( 900, 600 ); container.show(); // Make a scene and show it in the window. Ogre::SceneManager* scene_manager = render_system->root()->createSceneManager( Ogre::ST_GENERIC ); Ogre::Entity* thing = scene_manager->createEntity( "thing", "rviz_cone.mesh" ); Ogre::SceneNode* node = scene_manager->getRootSceneNode()->createChildSceneNode(); node->attachObject( thing ); scene_manager->setAmbientLight( Ogre::ColourValue( .5, .5, .5 )); Ogre::Light* light = scene_manager->createLight( "light" ); light->setPosition( 20, 80, 50 ); Ogre::Camera* camera = scene_manager->createCamera( "SampleCam" ); camera->setPosition( Ogre::Vector3( 0, 0, 10 )); camera->lookAt( Ogre::Vector3( 0, 0, -300 )); camera->setNearClipDistance( 5 ); Ogre::Viewport* viewport = window->getRenderWindow()->addViewport( camera ); viewport->setBackgroundColour( Ogre::ColourValue( 0, 0, 1.0 )); camera->setAspectRatio( Ogre::Real( viewport->getActualWidth() ) / Ogre::Real( viewport->getActualHeight() )); // redraw every 33ms. QTimer timer; QObject::connect( &timer, SIGNAL(timeout()), window, SLOT(update()) ); timer.start( 33 ); RenderWidget window2( render_system ); window2.resize( 400, 400 ); window2.setWindowTitle( "I hope this is also not all black." ); window2.show(); hide_button->connect( hide_button, SIGNAL( clicked() ), &window2, SLOT( hide() )); show_button->connect( show_button, SIGNAL( clicked() ), &window2, SLOT( show() )); Ogre::Camera* camera2 = scene_manager->createCamera( "SampleCam2" ); camera2->setPosition( Ogre::Vector3( 0, 10, 0 )); camera2->setFixedYawAxis( false ); camera2->lookAt( Ogre::Vector3( 0, 0, 0 )); camera2->setNearClipDistance( 5 ); Ogre::Viewport* viewport2 = window2.getRenderWindow()->addViewport( camera2 ); viewport2->setBackgroundColour( Ogre::ColourValue( 0, 1.0, 0 )); camera2->setAspectRatio( Ogre::Real( viewport2->getActualWidth() ) / Ogre::Real( viewport2->getActualHeight() )); // redraw every 33ms. QTimer timer2; QObject::connect( &timer2, SIGNAL(timeout()), &window2, SLOT(update()) ); timer2.start( 33 ); // main loop return app.exec(); }