2012年7月20日 星期五

Ogre Two Viewport


main.cpp
#include "Ogre\ExampleApplication.h"
class Example : public ExampleApplication
{
public:
      void createScene()
      {
          Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
          Ogre::Entity* ent = mSceneMgr->createEntity("Sinbad.mesh");
          node->attachObject(ent);
      }
      void createCamera()
      {
        mCamera = mSceneMgr->createCamera("MyCamera1");
        mCamera->setPosition(0,10,20);
        mCamera->lookAt(0,0,0);
        mCamera->setNearClipDistance(5);
        mCamera2 = mSceneMgr->createCamera("MyCamera2");
        mCamera2->setPosition(20,10,0);
        mCamera2->lookAt(0,0,0);
        mCamera2->setNearClipDistance(5);
      }
      void createViewports()
    {
        Ogre::Viewport* vp1 = mWindow->addViewport(mCamera,0,0.0,0.0,0.5,1.0);
        vp1->setBackgroundColour(ColourValue(0.0f,0.0f,0.1f));
        Ogre::Viewport* vp2 = mWindow->addViewport(mCamera2,1,0.5,0.0,0.5,1.0);
        vp2->setBackgroundColour(ColourValue(0.0f,0.1f,0.0f));
        mCamera->setAspectRatio(Real(vp1->getActualWidth()) / Real(vp1->getActualHeight()));
        mCamera2->setAspectRatio(Real(vp2->getActualWidth()) / Real(vp2->getActualHeight()));
    }
private:
       Ogre::Camera* mCamera1;
       Ogre::Camera* mCamera2;
};
int main (void)
{
    Example app;
    app.go();
    return 0;
}

沒有留言:

張貼留言