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

Fix head rotation #140

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions src/gui/qopenglplotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,10 @@ void ssr::QOpenGLPlotter::_draw_reference()

glTranslatef(0.03f, -0.03f, 0.0f);

// rotate according to reference position
glRotatef(_scene.get_reference().orientation.azimuth, 0.0f, 0.0f, 1.0f);
// rotate according to reference offset position
glRotatef(_scene.get_reference().orientation.azimuth +
_scene.get_reference_offset().orientation.azimuth,
0.0f, 0.0f, 1.0f);

glBindTexture(GL_TEXTURE_2D, _listener_shadow_texture);

Expand All @@ -396,8 +398,10 @@ void ssr::QOpenGLPlotter::_draw_reference()

glPopMatrix();

// rotate according to reference position
glRotatef(_scene.get_reference().orientation.azimuth, 0.0f, 0.0f, 1.0f);
// rotate according to reference offset position
glRotatef(_scene.get_reference().orientation.azimuth +
_scene.get_reference_offset().orientation.azimuth,
0.0f, 0.0f, 1.0f);

glBindTexture(GL_TEXTURE_2D, _listener_texture);

Expand Down
13 changes: 7 additions & 6 deletions src/gui/quserinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,8 @@ void ssr::QUserInterface::mouseMoveEvent(QMouseEvent *event)
// absolut mouse position in OpenGL coordinates
Position mouse_pos(static_cast<float>(pos_x), static_cast<float>(pos_y));

// position relative to reference position
mouse_pos -= _scene.get_reference().position;
// position relative to reference position offset
mouse_pos -= _scene.get_reference_offset().position;

_get_openGL_pos(_previous_mouse_event.x(),
_previous_mouse_event.y(),
Expand All @@ -990,11 +990,12 @@ void ssr::QUserInterface::mouseMoveEvent(QMouseEvent *event)
// previous absolut position in OpenGL coordinates
Position prev_mouse_pos(static_cast<float>(pos_x), static_cast<float>(pos_y));

// previous position relative to relative position
prev_mouse_pos -= _scene.get_reference().position;
// previous position relative to relative position offset
prev_mouse_pos -= _scene.get_reference_offset().position;

_controller.take_control()->reference_rotation(_scene.get_reference().orientation +
(mouse_pos.orientation() - prev_mouse_pos.orientation()));
_controller.take_control()->reference_rotation_offset(_scene.get_reference().orientation +
_scene.get_reference_offset().orientation +
(mouse_pos.orientation() - prev_mouse_pos.orientation()));

} // else if

Expand Down
2 changes: 1 addition & 1 deletion src/trackerpolhemus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ ssr::TrackerPolhemus::_open_serial_port(const char *portname)
void
ssr::TrackerPolhemus::calibrate()
{
_az_corr = _current_data.azimuth;
_az_corr = _current_data.azimuth + 90;
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/trackerrazor.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TrackerRazor : public Tracker
if (_tracker != nullptr) delete _tracker;
}

virtual void calibrate() { _az_corr = _current_azimuth; }
virtual void calibrate() { _az_corr = _current_azimuth + 90; }

private:
/// constructor
Expand Down
2 changes: 1 addition & 1 deletion src/trackervrpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ssr::TrackerVrpn::vrpn_change_handler(const vrpn_TRACKERCB t)
void
ssr::TrackerVrpn::calibrate()
{
_az_corr = _current_azimuth;
_az_corr = _current_azimuth + 90;
}

void
Expand Down