|
|
|
@ -3,8 +3,12 @@
|
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
|
|
|
|
|
#include <osg/Camera>
|
|
|
|
|
#include <osg/Geode>
|
|
|
|
|
#include <osg/Group>
|
|
|
|
|
#include <osg/Matrixd>
|
|
|
|
|
#include <osg/Quat>
|
|
|
|
|
#include <osg/Shape>
|
|
|
|
|
#include <osg/ShapeDrawable>
|
|
|
|
|
|
|
|
|
|
namespace CSVRender
|
|
|
|
|
{
|
|
|
|
@ -261,7 +265,7 @@ namespace CSVRender
|
|
|
|
|
Orbit Camera Controller
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
OrbitCameraController::OrbitCameraController()
|
|
|
|
|
OrbitCameraController::OrbitCameraController(osg::Group* group)
|
|
|
|
|
: mInitialized(false)
|
|
|
|
|
, mFast(false)
|
|
|
|
|
, mLeft(false)
|
|
|
|
@ -271,7 +275,10 @@ namespace CSVRender
|
|
|
|
|
, mRollLeft(false)
|
|
|
|
|
, mRollRight(false)
|
|
|
|
|
, mCenter(0,0,0)
|
|
|
|
|
, mCenterNode(new osg::PositionAttitudeTransform())
|
|
|
|
|
{
|
|
|
|
|
group->addChild(mCenterNode);
|
|
|
|
|
createShape();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OrbitCameraController::handleKeyEvent(QKeyEvent* event, bool pressed)
|
|
|
|
@ -383,6 +390,8 @@ namespace CSVRender
|
|
|
|
|
if (mRollRight)
|
|
|
|
|
roll(rotDist);
|
|
|
|
|
|
|
|
|
|
mCenterNode->setPosition(mCenter);
|
|
|
|
|
|
|
|
|
|
lookAtCenter();
|
|
|
|
|
|
|
|
|
|
// Normalize the matrix to counter drift
|
|
|
|
@ -409,6 +418,19 @@ namespace CSVRender
|
|
|
|
|
mInitialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OrbitCameraController::createShape()
|
|
|
|
|
{
|
|
|
|
|
const float boxWidth = 100;
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Box> box = new osg::Box(osg::Vec3f(0, 0, 0), boxWidth);
|
|
|
|
|
osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(box);
|
|
|
|
|
drawable->setColor(osg::Vec4f(0.f, 0.9f, 0.f, 1.f));
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
|
|
|
|
geode->addChild(drawable);
|
|
|
|
|
mCenterNode->addChild(geode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OrbitCameraController::rotateHorizontal(double value)
|
|
|
|
|
{
|
|
|
|
|
osg::Vec3d position = getCamera()->getViewMatrix().getTrans();
|
|
|
|
|