Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relative zoom and translation with mouse #843

Merged
merged 1 commit into from
Jan 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dart/gui/Win3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ void Win3D::click(int _button, int _state, int _x, int _y) {
} else if (_button == 3 && _state == GLUT_DOWN) { // mouse wheel up
// each scroll generates a down and an immediate up,
// so ignore ups
mZoom += 0.1;
mZoom += mZoom * 0.1;
} else if (_button == 4 && _state == GLUT_DOWN) { // mouse wheel down?
// each scroll generates a down and an immediate up,
// so ignore ups
mZoom -= 0.1;
mZoom -= mZoom * 0.1;
}
mMouseX = _x;
mMouseY = _y;
Expand All @@ -159,7 +159,7 @@ void Win3D::drag(int _x, int _y) {
}
if (mTranslate) {
Eigen::Matrix3d rot = mTrackBall.getRotationMatrix();
mTrans += rot.transpose()*Eigen::Vector3d(deltaX, -deltaY, 0.0);
mTrans += (1 / mZoom) * rot.transpose()*Eigen::Vector3d(deltaX, -deltaY, 0.0);
}
if (mZooming) {
mZoom += deltaY*0.01;
Expand Down