45 #include <Qt3DRender/QCamera>
46 #include <Qt3DCore/qtransform.h>
56 using namespace DISP3DLIB;
67 :QAbstractCameraController(pParent)
77 if(newStatusFlag ==
true) {
78 m_fRotationInverseFactor = -1.0f;
81 m_fRotationInverseFactor = 1.0f;
87 void OrbitalCameraController::moveCamera(
const Qt3DExtras::QAbstractCameraController::InputState &state,
float dt)
89 Qt3DRender::QCamera *pCamera = this->camera();
91 if(pCamera ==
nullptr) {
96 if(state.rightMouseButtonActive) {
97 if(state.altKeyActive) {
99 pCamera->translate(QVector3D(state.rxAxisValue * this->linearSpeed() * dt * 0.2f,
100 state.ryAxisValue * this->linearSpeed() * dt * 0.2f,
105 pCamera->panAboutViewCenter(state.rxAxisValue * this->lookSpeed() * dt * m_fRotationInverseFactor,
106 QVector3D(0.0f, 0.0f, 1.0f));
107 pCamera->tiltAboutViewCenter(state.ryAxisValue * this->lookSpeed() * dt * m_fRotationInverseFactor);
111 if(state.middleMouseButtonActive) {
113 pCamera->translate(QVector3D(state.rxAxisValue * this->linearSpeed() * dt * 0.2f,
114 state.ryAxisValue * this->linearSpeed() * dt * 0.2f,
119 if(distance(pCamera->position(), pCamera->viewCenter()) > m_fZoomInLimit) {
120 pCamera->translate(QVector3D(0.0f, 0.0f, state.tzAxisValue * this->linearSpeed() * dt),
121 pCamera->DontTranslateViewCenter);
124 pCamera->translate(QVector3D(0.0f, 0.0f, -m_fZoomInLimit), pCamera->DontTranslateViewCenter);
128 pCamera->panAboutViewCenter(state.txAxisValue * this->lookSpeed() * dt * 0.8f * m_fRotationInverseFactor,
129 QVector3D(0.0f, 0.0f, 1.0f));
130 pCamera->tiltAboutViewCenter(state.tyAxisValue * this->lookSpeed()* dt * 0.8f * m_fRotationInverseFactor);
135 void OrbitalCameraController::initController()
137 this->setLinearSpeed(0.55f);
138 this->setLookSpeed(143.f);
146 Qt3DRender::QCamera *pCamera = this->camera();
149 QQuaternion quat = QQuaternion::QQuaternion::fromEulerAngles(0,0,m_fAutoRotationSpeed);
150 pCamera->rotateAboutViewCenter(quat);