added free navigation mode

actorid
Marc Zinnschlag 11 years ago
parent c977b2a756
commit 4eea2c7a86

@ -68,7 +68,7 @@ opencs_units (view/render
)
opencs_units_noqt (view/render
navigation navigation1st
navigation navigation1st navigationfree
)
opencs_units_noqt (view/world

@ -0,0 +1,60 @@
#include "navigationfree.hpp"
#include <OgreCamera.h>
#include <QPoint>
CSVRender::NavigationFree::NavigationFree() : mCamera (0) {}
bool CSVRender::NavigationFree::activate (Ogre::Camera *camera)
{
mCamera = camera;
mCamera->setFixedYawAxis (false);
return false;
}
bool CSVRender::NavigationFree::wheelMoved (int delta)
{
mCamera->move (getFactor (true) * mCamera->getDirection() * delta);
return true;
}
bool CSVRender::NavigationFree::mouseMoved (const QPoint& delta, int mode)
{
if (mode==0)
{
// turn camera
if (delta.x())
mCamera->yaw (Ogre::Degree (getFactor (true) * delta.x()));
if (delta.y())
mCamera->pitch (Ogre::Degree (getFactor (true) * delta.y()));
return true;
}
else if (mode==1)
{
// pan camera
if (delta.x())
mCamera->move (getFactor (true) * mCamera->getDerivedRight() * delta.x());
if (delta.y())
mCamera->move (getFactor (true) * -mCamera->getDerivedUp() * delta.y());
return true;
}
return false;
}
bool CSVRender::NavigationFree::handleMovementKeys (int vertical, int horizontal)
{
if (vertical)
mCamera->move (getFactor (false) * mCamera->getDerivedUp() * vertical);
if (horizontal)
mCamera->move (getFactor (true) * mCamera->getDerivedRight() * horizontal);
return true;
}

@ -0,0 +1,32 @@
#ifndef OPENCS_VIEW_NAVIGATIONFREE_H
#define OPENCS_VIEW_NAVIGATIONFREE_H
#include "navigation.hpp"
namespace CSVRender
{
/// \brief Free camera controls
class NavigationFree : public Navigation
{
Ogre::Camera *mCamera;
public:
NavigationFree();
virtual bool activate (Ogre::Camera *camera);
///< \return Update required?
virtual bool wheelMoved (int delta);
///< \return Update required?
virtual bool mouseMoved (const QPoint& delta, int mode);
///< \param mode: 0: default mouse key, 1: default mouse key and modifier key 1
/// \return Update required?
virtual bool handleMovementKeys (int vertical, int horizontal);
///< \return Update required?
};
}
#endif

@ -86,7 +86,7 @@ void CSVWorld::SceneSubView::selectNavigationMode (const std::string& mode)
mScene->setNavigation (&m1st);
else if (mode=="free")
{
mScene->setNavigation (&mFree);
}
else if (mode=="orbit")
{

@ -4,6 +4,7 @@
#include "../doc/subview.hpp"
#include "../render/navigation1st.hpp"
#include "../render/navigationfree.hpp"
class QModelIndex;
@ -30,6 +31,7 @@ namespace CSVWorld
TableBottomBox *mBottom;
CSVRender::SceneWidget *mScene;
CSVRender::Navigation1st m1st;
CSVRender::NavigationFree mFree;
public:

Loading…
Cancel
Save