示例#1
0
//Ogre::Camera::getRight() const
void camera_get_right(CameraHandle handle, coiVector3* right)
{
    Ogre::Camera* camera = static_cast<Ogre::Camera*>(handle);
    const Ogre::Vector3& u = camera->getRight();

    right->x = u.x;
    right->y = u.y;
    right->z = u.z;
}
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);
}
示例#3
0
// Ogre::Camera::getUp() const
void camera_get_up(CameraHandle handle, coiVector3* up)
{
    Ogre::Camera* camera = static_cast<Ogre::Camera*>(handle);
    const Ogre::Vector3& u = camera->getUp();

    up->x = u.x;
    up->y = u.y;
    up->z = u.z;
}
示例#4
0
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;
}
示例#5
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));
		
	}
}
示例#6
0
文件: graphics.cpp 项目: Mononofu/OTE
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);
}
示例#7
0
文件: window.cpp 项目: fingerx/eqOgre
    void Window::addViewport()
    {
        Pipe *pipe = static_cast<Pipe *>(getPipe());
        Ogre::Camera *cam = pipe->_ogre->getCamera();
        _vp = mWindow->addViewport(cam);
        _vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
        cam->setAspectRatio(
               Ogre::Real(_vp->getActualWidth()) / Ogre::Real(_vp->getActualHeight()));

    }
示例#8
0
//Ogre::Camera::getDerivedOrientation() const
void camera_get_derived_orientation(CameraHandle handle, coiQuaternion* orientation)
{
    Ogre::Camera* camera = static_cast<Ogre::Camera*>(handle);
    const Ogre::Quaternion & getter = camera->getDerivedOrientation();

    orientation->w = getter.w;
    orientation->x = getter.x;
    orientation->y = getter.y;
    orientation->z = getter.z;
}
示例#9
0
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()));
}
示例#10
0
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;
}
示例#11
0
void Stall::SetPosition(Ogre::Rectangle2D *rect, Ogre::Vector3 pos, float size)
{    
    Ogre::Camera *camera =  CommonDeclarations::GetCamera()->GetOgreCamera();
    Ogre::Matrix4 vm = camera->getViewMatrix();
    Ogre::Matrix4 pm = camera->getProjectionMatrix();
    Ogre::Vector3 vpos = vm*pos;
    Ogre::Vector3 ppos = pm*vpos;

    rect->setCorners(ppos.x-size, ppos.y+size, ppos.x+size/AspectRatio, ppos.y-size);
}
示例#12
0
文件: Camera.cpp 项目: Pured/CSCI356
Ogre::Vector2 DemoApp::GetScreenspaceCoords(const Ogre::Vector3& iPoint, const Ogre::Camera& iCamera)
{
    Ogre:: Vector3 point = iCamera.getProjectionMatrix() * (iCamera.getViewMatrix() * iPoint);

    Ogre::Vector2 screenSpacePoint = Ogre::Vector2::ZERO;
    screenSpacePoint.x = (point.x / 2.f) + 0.5f;
    screenSpacePoint.y = (point.y / 2.f) + 0.5f;

    return screenSpacePoint;
}
示例#13
0
// -----------------------------------------------------------------------------
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();
}
示例#14
0
	bool mouseMoved(const OIS::MouseEvent &arg)
	{
		mCameraAngleH -= Ogre::Degree((Ogre::Real)arg.state.X.rel);
		mCameraAngleV -= Ogre::Degree((Ogre::Real)arg.state.Y.rel);
		mCamera->setOrientation(Ogre::Quaternion::IDENTITY);
		mCamera->yaw(mCameraAngleH*0.1);
		mCamera->pitch(mCameraAngleV*0.1);

		mGUI->injectMouseMove(arg);
		return true;
	}
示例#15
0
// 设置眼睛的位置, 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));
		
	}
}
示例#16
0
//-------------------------------------------------------------------------------------------
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()));
}
示例#17
0
文件: main.cpp 项目: Isaj7/finalOgre
			// 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()));

			}
示例#18
0
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);
}
void TextComponent::OnUpdate(double time_diff) {
    if(mRefresh && mFont != "") {
        // calculate the text width
        mTextWidth = 0;
        Ogre::Font* font = dynamic_cast<Ogre::Font*>(Ogre::FontManager::getSingleton().getByName(Utils::ToStdString(mFont)).getPointer());
        if(font == nullptr) {
            Logger::Get().Warning("Cannot find font: \"" + mFont + "\".");
        } else {
            std::string str = Utils::ToStdString(mText);
            for(Ogre::String::iterator iter = str.begin(); iter < str.end(); ++iter) {
                if(*iter == 0x0020) {
                    mTextWidth += font->getGlyphAspectRatio(0x0030);
                } else {
                    mTextWidth += font->getGlyphAspectRatio(*iter);
                }
            }
            mTextWidth *= mFontSize;
        }
        mRefresh = false;
    }

    // set the position

    if(DisplayManager::Get()->GetMainCamera() == nullptr) {
        Logger::Get().Error("Cannot get main camera for text component: no main camera set. Disabling text component " + mName + ".");
        Disable();
        return;
    }
    Ogre::Camera* camera = DisplayManager::Get()->GetMainCamera()->GetCamera();
    Ogre::Vector3 screen_pos(camera->getProjectionMatrix() * camera->getViewMatrix() * GetNode()->GetPosition(Node::SCENE));

    if(screen_pos.z >= 1) {
        // behind or in the camera, hide
        mOverlay->hide();
    } else {
        mOverlay->show();
    }

    float x = 1.0f - ((-screen_pos.x * 0.5f) + 0.5f);   // 0 <= x <= 1 // left := 0,right := 1
    float y = ((-screen_pos.y * 0.5f) + 0.5f);          // 0 <= y <= 1 // bottom := 0,top := 1

    x *= camera->getViewport()->getActualWidth();
    y *= camera->getViewport()->getActualHeight();

    mPanel->setMetricsMode(Ogre::GMM_PIXELS);
    mPanel->setWidth(mTextWidth + 2 * mPadding.x);
    mPanel->setHeight(mFontSize + 2 * mPadding.y);
    mPanel->setLeft(x - mTextWidth / 2 - mPadding.x);
    mPanel->setTop(y - mFontSize / 2 - mPadding.y);

    mLabel->setPosition(mPadding.x, mPadding.y);
    mLabel->setDimensions(mTextWidth, mFontSize);
}
示例#20
0
void OGKSceneManager::setActiveScene(const Ogre::String name, Ogre::Real transitionTime)
{
    mPreviousScene = mActiveScene;
    mActiveScene = getScene(name);
    
    Ogre::ColourValue bg = Ogre::ColourValue::Black;
    
    if(mPreviousScene) {
        if(mPreviousScene->mCamera) {
            // save viewport settings for rtt
            Ogre::Camera *cam = mPreviousScene->mCamera->getCamera();
            bg = cam->getViewport()->getBackgroundColour();
        }
        mPreviousScene->onExitTransitionDidStart();
    }
    
    if(mActiveScene) {
        OGKLOG("Transitioning to " + name + " scene");
        mActiveScene->onEnter();
    }
    
    if(transitionTime > 0.01) {
        // transition
        mTransitionTime = transitionTime;
        mTransitionTimeRemaining = transitionTime;
        
        _initRTT();
        
        if(mPreviousScene && mPreviousScene->mCamera &&
           mPreviousScene->mCamera->getCamera()) {
            // render to texture instead
            Ogre::Camera *cam = mPreviousScene->mCamera->getCamera();
            mRenderTexture->removeAllViewports();
            Ogre::Viewport *vp = mRenderTexture->addViewport(cam);
            if(vp) {
                //OGKLOG("Preparing rtt viewport");
                vp->setClearEveryFrame(true);
                vp->setBackgroundColour(bg);
                vp->setOverlaysEnabled(true);
                vp->setCamera(cam);
            }
        }

        if(mOverlay) {
            //OGKLOG("Showing Overlay");
            mOverlay->show();
        }
    }
    else {
        if(mPreviousScene) mPreviousScene->onExit();
        if(mActiveScene) mActiveScene->onEnterTransitionDidFinish();
    }
}
//------------------------------------------------------------------------
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);
}
示例#22
0
//---------------------------------------------------------------------------------------------
//void TControlCamera::MouseLeftButtonDown( int x, int y)
//{
  //mOldX = x;
  //mOldY = y;
//}
//---------------------------------------------------------------------------------------------
//void TControlCamera::MouseLeftButtonUp()
//{
  //flgMovedCamera = false;
//}
//---------------------------------------------------------------------------------------------
// передавать разницу в координатах! а не сами координаты
//void TControlCamera::MoveMouse(int new_x, int new_y)
//{
//  flgMovedCamera = true;
//
//  Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera();
//
//  Ogre::Radian angle;
//  angle = mOldY - new_y;
//  pCamera->pitch(MOUSE_Y_AMP*angle);
//
//  angle = mOldX - new_x;
//  pCamera->yaw(MOUSE_X_AMP*angle);
//
//  mOldX = new_x;
//  mOldY = new_y;
//}
//---------------------------------------------------------------------------------------------
void TControlCamera::MoveMouse(int dX, int dY)
{
  //flgMovedCamera = true;

  Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera();

  Ogre::Radian angle;
  angle = -dY;
  pCamera->pitch(MOUSE_Y_AMP*angle);

  angle = -dX;
  pCamera->yaw(MOUSE_X_AMP*angle);
}
示例#23
0
void Camera::toggleWireframe()
{
	Ogre::Camera* cam = mCameraNode->getCreator()->getCamera(stringify(mHandle));
	Ogre::PolygonMode mode = cam->getPolygonMode();
	if (mode == Ogre::PM_WIREFRAME)
	{
		cam->setPolygonMode(Ogre::PM_SOLID);
	} 
	else
	{
		cam->setPolygonMode(Ogre::PM_WIREFRAME);
	}
}
示例#24
0
void OgreWidget::moveAndResize()
{
    mWindow->reposition(x(), y());
    mWindow->resize(width(), height());
    mWindow->windowMovedOrResized();

    for (int ct = 0; ct < mWindow->getNumViewports(); ++ct)
    {
        Ogre::Viewport* pViewport = mWindow->getViewport(ct);
        Ogre::Camera* pCamera = pViewport->getCamera();
        pCamera->setAspectRatio(static_cast<Ogre::Real>(pViewport->getActualWidth()) / static_cast<Ogre::Real>(pViewport->getActualHeight()));
    }
}
示例#25
0
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;
}
示例#26
0
Ogre::Vector3& PhysicsManager::getMouseWorldPosition(float x, float y){

	Ogre::Camera* cam = _sceneManager->getCamera("PlayState");
	Ogre::Ray ray = cam->getCameraToViewportRay(x, y);	
	Ogre::Vector3 position;
	
	OgreBulletCollisions::CollisionClosestRayResultCallback cQuery = OgreBulletCollisions::CollisionClosestRayResultCallback(ray, _world, 10000);	
	_world->launchRay(cQuery);

	if (cQuery.doesCollide()) {
		position = cQuery.getCollisionPoint();
	}
	return position;
}
示例#27
0
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;
}
示例#28
0
/**
 * @brief resize the GL window
 * @author Kito Berg-Taylor
 */
void THIS::resizeGL( int width, int height )
{
    if ( !mWindow ) return;

    mWindow->resize(width, height);
    mWindow->windowMovedOrResized();
    for(int i = 0; i < mWindow->getNumViewports(); ++i)
    {
        Ogre::Viewport* pViewport = mWindow->getViewport(i);
        Ogre::Camera* pCamera = pViewport->getCamera();
        pCamera->setAspectRatio(static_cast<Ogre::Real>(pViewport->getActualWidth()) / static_cast<Ogre::Real>(pViewport->getActualHeight()));
        pViewport->_updateDimensions();
    }
    paintGL();
}
示例#29
0
void MultiMgrSample::dualViewport(Ogre::SceneManager *primarySceneMgr, Ogre::SceneManager *secondarySceneMgr)
{
	mWindow->removeAllViewports();

	Ogre::Viewport *vp = 0;
	Ogre::Camera *cam = primarySceneMgr->getCamera(CAMERA_NAME);
	vp = mWindow->addViewport(cam, 0, 0, 0, 0.5, 1);
	vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
	cam->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));

	cam = secondarySceneMgr->getCamera(CAMERA_NAME);
	vp = mWindow->addViewport(cam, 1, 0.5, 0, 0.5, 1);
	vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
	cam->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}
示例#30
0
	void OgreWidget::resizeEvent(QResizeEvent* evt)
	{
		if(m_pOgreRenderWindow)
		{
			m_pOgreRenderWindow->resize(width(), height());
			m_pOgreRenderWindow->windowMovedOrResized();

			for(int ct = 0; ct < m_pOgreRenderWindow->getNumViewports(); ++ct)
			{
				Ogre::Viewport* pViewport = m_pOgreRenderWindow->getViewport(ct);
				Ogre::Camera* pCamera = pViewport->getCamera();
				pCamera->setAspectRatio(static_cast<Ogre::Real>(pViewport->getActualWidth()) / static_cast<Ogre::Real>(pViewport->getActualHeight()));
			}
		}
	}