Commit 8f124fda authored by Christopher Tenter's avatar Christopher Tenter

add fly to action to camera node

parent 629bcf94
Pipeline #3749 failed with stage
in 41 minutes and 50 seconds
......@@ -117,9 +117,15 @@ public:
/// set model view matrix
void setModelView(ACG::GLMatrixd _modelView) { modelView_ = _modelView; modelViewInv_ = _modelView; modelViewInv_.invert(); update_vbo_ = true; }
/// Returns the modelview matrix
const ACG::GLMatrixd& modelview() const {return modelView_;}
/// Set projection Matrix ( used to calculate frustum ... )
void setProjection(ACG::GLMatrixd _projection) { projection_ = _projection; update_vbo_ = true; }
/// Returns the projection matrix
const ACG::GLMatrixd& projection() const {return projection_;}
/// Set viewport size ( This will be used to compute the aspect ratio )
DEPRECATED("setSize() is redundant, because it is already defined by the projection matrix.")
void setSize(int _w, int _h) { /*obsolete*/ }
......@@ -144,6 +150,7 @@ public:
/// Returns true if camera renders its whole frustum
bool showFrustum() { return showFrustum_; }
private:
void updateVBO();
......
......@@ -62,7 +62,7 @@ TypeCameraPlugin::TypeCameraPlugin() :
void TypeCameraPlugin::pluginsInitialized() {
if ( OpenFlipper::Options::gui() ){
contextMenu_ = new QMenu(tr("Rendering"));
contextMenu_ = new QMenu(tr("CameraNode"));
showFrustumAction_ = contextMenu_->addAction( tr("Show viewing frustum") );
showFrustumAction_->setCheckable(true);
......@@ -70,6 +70,10 @@ void TypeCameraPlugin::pluginsInitialized() {
showFrustumAction_->setToolTip(tr("Visualize cameras viewing frustum."));
showFrustumAction_->setStatusTip( showFrustumAction_->toolTip() );
QAction* flyAction = contextMenu_->addAction( tr("Fly to") );
flyAction->setToolTip(tr("Fly viewer to the camera position."));
flyAction->setStatusTip( flyAction->toolTip() );
// Add context menu
emit addContextMenuItem(contextMenu_->menuAction(), DATA_CAMERA, CONTEXTOBJECTMENU);
......@@ -109,6 +113,22 @@ void TypeCameraPlugin::contextMenuClicked(QAction* _contextAction) {
emit updatedObject(objectId, UPDATE_VISIBILITY);
}
else if (_contextAction->text() == tr("Fly to")) {
// calculate camera position and view direction in world space
ACG::GLMatrixd m = object->cameraNode()->modelview();
ACG::GLMatrixd mInv = m;
mInv.invert();
ACG::Vec3d camPosWS(mInv(0,3), mInv(1,3), mInv(2,3));
ACG::Vec3d camViewWS(mInv(0,2), mInv(1,2), mInv(2,2));
ACG::Vec3d camCenterWS = camPosWS - camViewWS;
// target up vector can't be specified unfortunately
PluginFunctions::flyTo(camPosWS, camCenterWS, 500.0);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment