mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
GCS/Modelview Implemented real-time updates from AttitudeActual object
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@681 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
3fae030433
commit
4893dead52
@ -3,6 +3,7 @@ TARGET = ModelViewGadget
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../libs/glc_lib/glc_lib.pri)
|
||||
include(modelview_dependencies.pri)
|
||||
INCLUDEPATH += ../../libs/glc_lib/install/include/GLC_lib
|
||||
HEADERS += modelviewplugin.h \
|
||||
modelviewgadgetconfiguration.h \
|
||||
|
3
ground/src/plugins/modelview/modelview_dependencies.pri
Normal file
3
ground/src/plugins/modelview/modelview_dependencies.pri
Normal file
@ -0,0 +1,3 @@
|
||||
include(../../plugins/uavobjects/uavobjects.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../libs/utils/utils.pri)
|
@ -82,7 +82,7 @@ void ModelViewGadgetOptionsPage::finish()
|
||||
void ModelViewGadgetOptionsPage::changeAC()
|
||||
{
|
||||
QString ac = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
|
||||
tr("Model 3D File"), "../artwork/", tr("3D File (*.dae)") );
|
||||
tr("Model 3D File"), "../artwork/", tr("3D File (*.dae *.3ds)") );
|
||||
m_config->setAcFilename(ac);
|
||||
m_acFileLabel->setText(ac);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "modelviewgadgetwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include <iostream>
|
||||
|
||||
ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
|
||||
@ -48,11 +49,17 @@ ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
|
||||
m_MoverController= m_pFactory->createDefaultMoverController(repColor, &m_GlView);
|
||||
|
||||
m_GlView.cameraHandle()->setDefaultUpVector(glc::Y_AXIS);
|
||||
m_GlView.cameraHandle()->setRightView();
|
||||
//m_GlView.cameraHandle()->setIsoView();
|
||||
|
||||
// Get required UAVObjects
|
||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
|
||||
attActual = AttitudeActual::GetInstance(objManager);
|
||||
|
||||
// Create objects to display
|
||||
CreateScene();
|
||||
connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(rotateView()));
|
||||
connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude()));
|
||||
}
|
||||
|
||||
ModelViewGadgetWidget::~ModelViewGadgetWidget()
|
||||
@ -78,7 +85,7 @@ void ModelViewGadgetWidget::initializeGL()
|
||||
m_GlView.setDistMinAndMax(m_World.boundingBox());
|
||||
glEnable(GL_NORMALIZE);
|
||||
|
||||
m_MotionTimer.start(60);
|
||||
m_MotionTimer.start(100);
|
||||
}
|
||||
|
||||
void ModelViewGadgetWidget::resizeEvent(QResizeEvent *event)
|
||||
@ -172,10 +179,20 @@ void ModelViewGadgetWidget::mouseReleaseEvent(QMouseEvent*)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Private slots Functions
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Rotate the view
|
||||
void ModelViewGadgetWidget::rotateView()
|
||||
void ModelViewGadgetWidget::updateAttitude()
|
||||
{
|
||||
m_GlView.cameraHandle()->rotateAroundTarget(glc::Y_AXIS, 2.0 * glc::PI / static_cast<double>(200));
|
||||
// Reset view to zero angles
|
||||
// NOTE: Some aircraft 3D models have different orientation and axis
|
||||
m_GlView.cameraHandle()->setTopView();
|
||||
m_GlView.cameraHandle()->rotateAroundTarget(glc::X_AXIS, 180.0*glc::PI/180.0);
|
||||
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, 90.0*glc::PI/180.0);
|
||||
// Rotate to the actual angles (if a gimbal lock at yaw 90/270 deg, change sequence of rotations)
|
||||
AttitudeActual::DataFields data = attActual->getData();
|
||||
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, data.Yaw*glc::PI/180.0);
|
||||
m_GlView.cameraHandle()->rotateAroundTarget(glc::X_AXIS, data.Roll*glc::PI/180.0);
|
||||
m_GlView.cameraHandle()->rotateAroundTarget(glc::Y_AXIS, -data.Pitch*glc::PI/180.0);
|
||||
updateGL();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -37,6 +37,9 @@
|
||||
#include <GLC_Light>
|
||||
#include <GLC_World>
|
||||
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
#include "uavobjects/attitudeactual.h"
|
||||
|
||||
|
||||
|
||||
class ModelViewGadgetWidget : public QGLWidget
|
||||
@ -70,8 +73,7 @@ private:
|
||||
// Private slots Functions
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
private slots:
|
||||
//! Rotate the view
|
||||
void rotateView();
|
||||
void updateAttitude();
|
||||
|
||||
private:
|
||||
GLC_Factory* m_pFactory;
|
||||
@ -85,6 +87,8 @@ private:
|
||||
|
||||
QString acFilename;
|
||||
QString bgFilename;
|
||||
|
||||
AttitudeActual* attActual;
|
||||
};
|
||||
|
||||
#endif /* MODELVIEWGADGETWIDGET_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user