本文整理汇总了C++中ogre::Camera::setAspectRatio方法的典型用法代码示例。如果您正苦于以下问题:C++ Camera::setAspectRatio方法的具体用法?C++ Camera::setAspectRatio怎么用?C++ Camera::setAspectRatio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Camera
的用法示例。
在下文中一共展示了Camera::setAspectRatio方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dualViewport
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()));
}
示例2: startup
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;
}
示例3: windowResized
void AsteroidGame::windowResized(Ogre::RenderWindow* rw){
/* Update the window and aspect ratio when the window is resized */
int width = rw->getWidth();
int height = rw->getHeight();
Ogre::SceneManager* scene_manager = ogre_root_->getSceneManager("MySceneManager");
Ogre::Camera* camera = scene_manager->getCamera("MyCamera");
if (camera != NULL){
camera->setAspectRatio(Ogre::Real(width/height));
}
Ogre::Camera* camera_2 = scene_manager->getCamera("MyCamera_2");
if (camera_2 != NULL){
camera_2->setAspectRatio(Ogre::Real(width/height));
}
const OIS::MouseState &ms = mouse_->getMouseState();
ms.width = width;
ms.height = height;
ogre_window_->resize(width, height);
ogre_window_->windowMovedOrResized();
ogre_window_->update();
}
示例4: createViewport
void BaseApp::createViewport()
{
Ogre::Camera* cam = mSceneMgr->getCamera("PlayerCam");
Ogre::Viewport * vp = mWindow->addViewport(cam);
vp->setBackgroundColour(ColourValue(0.0f,0.0f,0.0f,0.0f));
cam->setAspectRatio(Ogre::Real(vp->getActualWidth())/Ogre::Real(vp->getActualHeight()));
}
示例5: setMainCamera
void gkScene::setMainCamera(gkCamera* cam)
{
if (!cam)
return;
m_startCam = cam;
Ogre::Camera* main = m_startCam->getCamera();
GK_ASSERT(main);
if (!m_viewport)
{
gkWindow* window = getDisplayWindow(); GK_ASSERT(window);
m_viewport = window->addViewport(cam);
}
else
m_viewport->getViewport()->setCamera(main);
GK_ASSERT(m_viewport);
gkVector2 size = getDisplayWindow()->getSize();
main->setAspectRatio(size.x / size.y);
cam->setFov(gkDegree(cam->getFov()));
}
示例6: create_viewports
void application::create_viewports()
{
Ogre::Viewport* vp = wnd->addViewport(cam);
vp->setBackgroundColour (Ogre::ColourValue {0, 0, 0});
cam->setAspectRatio (Ogre::Real (vp->getActualWidth()) / Ogre::Real (vp->getActualHeight()));
}
示例7: updateFBO
void OgreNode::updateFBO()
{
Ogre::TexturePtr rttTexture = mRenderSystem->getRtt("RttTex", mSize.width(), mSize.height());
mRenderTarget = rttTexture->getBuffer()->getRenderTarget();
Ogre::Camera* cam = mRenderSystem->getOgreCamera();
mRenderTarget->addViewport(cam);
Ogre::Real aspectRatio = Ogre::Real(mSize.width()) / Ogre::Real(mSize.height());
cam->setAspectRatio(aspectRatio);
QSGGeometry::updateTexturedRectGeometry(&mGeometry,
QRectF(0, 0, mSize.width(), mSize.height()),
QRectF(0, 0, 1, 1));
Ogre::GLTexture *nativeTexture = static_cast<Ogre::GLTexture *>(rttTexture.get());
delete mTexture;
mTexture = mQuickWindow->createTextureFromId(nativeTexture->getGLID(), mSize);
mMaterial.setTexture(mTexture);
mMaterialO.setTexture(mTexture);
LOG(INFO) << "Updated FBO, new size: " << mSize.width() << "x" << mSize.height() << ", texture id: " << nativeTexture->getGLID();
}
示例8: start
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;
}
示例9: loadMesh
//-------------------------------------------------------------------------------------------
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()));
}
示例10: main
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;
}
示例11: OnRenderViewSize
//-----------------------------------------------------------------------------
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()));
}
示例12: setupViewport
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()));
}
示例13: addViewport
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()));
}
示例14:
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;
}
示例15: QWidget
// -----------------------------------------------------------------------------
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();
}