Camera zoom to bounding box fix
This commit is contained in:
parent
599ff78539
commit
5404460fce
|
|
@ -103,10 +103,11 @@ namespace RNR
|
||||||
this->render_time += ogreRoot->getTimer()->getMilliseconds() / 1000.0;
|
this->render_time += ogreRoot->getTimer()->getMilliseconds() / 1000.0;
|
||||||
ogreRoot->getTimer()->reset();
|
ogreRoot->getTimer()->reset();
|
||||||
|
|
||||||
if(!world->getWorkspace()->getBoundingBox().isInfinite())
|
Ogre::AxisAlignedBox boundingBox = world->getWorkspace()->getBoundingBox();
|
||||||
|
if(!boundingBox.isNull() && !boundingBox.isInfinite())
|
||||||
{
|
{
|
||||||
ogreCamera->getParentSceneNode()->setPosition(world->getWorkspace()->getBoundingBox().getCorner(Ogre::AxisAlignedBox::CornerEnum::NEAR_LEFT_TOP));
|
ogreCamera->getParentSceneNode()->setPosition(boundingBox.getCorner(Ogre::AxisAlignedBox::CornerEnum::NEAR_LEFT_TOP));
|
||||||
ogreCamera->getParentSceneNode()->lookAt(world->getWorkspace()->getBoundingBox().getCenter(), Ogre::Node::TS_WORLD);
|
ogreCamera->getParentSceneNode()->lookAt(boundingBox.getCenter(), Ogre::Node::TS_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
ogreRoot->renderOneFrame(this->delta);
|
ogreRoot->renderOneFrame(this->delta);
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ void MainWindow::updateTree(RNR::Instance* root_instance)
|
||||||
void MainWindow::loadDatamodel()
|
void MainWindow::loadDatamodel()
|
||||||
{
|
{
|
||||||
this->ogreWidget->world->load(QFileDialog::getOpenFileName(this, tr("Open RBXL"), tr(""), tr("RBXLs (*.rbxl)")).toLocal8Bit().data());
|
this->ogreWidget->world->load(QFileDialog::getOpenFileName(this, tr("Open RBXL"), tr(""), tr("RBXLs (*.rbxl)")).toLocal8Bit().data());
|
||||||
|
|
||||||
|
updateTree(ogreWidget->world->getDatamodel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createToolbar()
|
void MainWindow::createToolbar()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#include <OGRE/OgreVector3.h>
|
#include <OGRE/Ogre.h>
|
||||||
#include <App/CoordinateFrame.hpp>
|
#include <App/CoordinateFrame.hpp>
|
||||||
|
|
||||||
namespace RNR
|
namespace RNR
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue