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

Test scenehandler with follow #386

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions include/pangolin/display/opengl_render_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ inline OpenGlMatrix OpenGlMatrix::ColMajor4x4(const P* col_major_4x4)
}

inline OpenGlMatrix::OpenGlMatrix() {
SetIdentity();
}

#ifdef USE_EIGEN
Expand Down
39 changes: 23 additions & 16 deletions src/display/opengl_render_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ void OpenGlRenderState::Apply() const
glMatrixMode(GL_MODELVIEW);
modelview.Load();

if(follow) {
T_cw.Multiply();
}
// if(follow) {
// T_cw.Multiply();
// }
}

OpenGlMatrix& OpenGlRenderState::GetProjectionMatrix(unsigned int view)
Expand Down Expand Up @@ -339,24 +339,31 @@ void OpenGlRenderState::DisableProjectiveTexturing() const

void OpenGlRenderState::Follow(const OpenGlMatrix& T_wc, bool follow)
{

const OpenGlMatrix T_vc = GetModelViewMatrix() * (this->T_cw) * T_wc;

this->T_cw = T_wc.Inverse();

if(follow != this->follow) {
if(follow) {
const OpenGlMatrix T_vc = GetModelViewMatrix() * T_wc;
SetModelViewMatrix(T_vc);
this->follow = true;
}else{
Unfollow();
}
}

SetModelViewMatrix(T_vc);
this->follow = follow;

//! old code
// if(follow != this->follow) {
// if(follow) {
// const OpenGlMatrix T_vc = GetModelViewMatrix() * T_wc;
// SetModelViewMatrix(T_vc);
// this->follow = true;
// }else{
// Unfollow();
// }
// }
}

void OpenGlRenderState::Unfollow()
{
const OpenGlMatrix T_vw = GetModelViewMatrix() * T_cw;
SetModelViewMatrix(T_vw);
this->follow = false;
// const OpenGlMatrix T_vw = GetModelViewMatrix() * T_cw;
// SetModelViewMatrix(T_vw);
// this->follow = false;
}

// Use OpenGl's default frame of reference
Expand Down