Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Convenience methods for Eigen / GlMatrix

Signed-off-by: Steven Lovegrove <stevenlovegrove@gmail.com>
  • Loading branch information...
commit 4122be5b21a1bd0d8ae7de50993271f4914d3c5b 1 parent f36cd8f
Steven Lovegrove authored
Showing with 33 additions and 4 deletions.
  1. +14 −0 pangolin/display.cpp
  2. +19 −4 pangolin/display.h
14 pangolin/display.cpp
View
@@ -301,12 +301,19 @@ namespace pangolin
void Scroll(float x, float y)
{
+ cout << "Scroll: " << x << ", " << y << endl;
+
if(x==0) {
Mouse(y>0?3:4,0, last_x, last_y);
context->mouse_state &= !MouseWheelUp;
context->mouse_state &= !MouseWheelDown;
}
}
+
+ void Zoom(float m)
+ {
+ cout << "Zoom: " << m << endl;
+ }
}
#ifdef HAVE_GLUT
@@ -339,6 +346,13 @@ namespace pangolin
if(glutScrollFunc) {
glutScrollFunc(&process::Scroll);
}
+ typedef void (*glutZoomFunc_t)(void (*)(float));
+ glutZoomFunc_t glutZoomFunc = (glutZoomFunc_t)glutGetProcAddress("glutZoomFunc");
+ if(glutZoomFunc) {
+ cout << "Registering zoom func" << endl;
+ glutZoomFunc(&process::Zoom);
+ }
+
#endif
}
23 pangolin/display.h
View
@@ -243,8 +243,11 @@ namespace pangolin
OpenGlMatrix();
#ifdef HAVE_EIGEN
- template<typename T>
- OpenGlMatrix(const Eigen::Matrix<T,4,4>& mat);
+ template<typename P>
+ OpenGlMatrix(const Eigen::Matrix<P,4,4>& mat);
+
+ template<typename P>
+ operator Eigen::Matrix<P,4,4>() const;
#endif // HAVE_EIGEN
// Load matrix on to OpenGl stack
@@ -525,8 +528,8 @@ inline OpenGlMatrix::OpenGlMatrix() {
}
#ifdef HAVE_EIGEN
- template<typename T> inline
- OpenGlMatrix::OpenGlMatrix(const Eigen::Matrix<T,4,4>& mat)
+ template<typename P> inline
+ OpenGlMatrix::OpenGlMatrix(const Eigen::Matrix<P,4,4>& mat)
{
for(int r=0; r<4; ++r ) {
for(int c=0; c<4; ++c ) {
@@ -535,6 +538,18 @@ inline OpenGlMatrix::OpenGlMatrix() {
}
}
+ template<typename P>
+ OpenGlMatrix::operator Eigen::Matrix<P,4,4>() const
+ {
+ Eigen::Matrix<P,4,4> mat;
+ for(int r=0; r<4; ++r ) {
+ for(int c=0; c<4; ++c ) {
+ mat(r,c) = m[c*4+r];
+ }
+ }
+ return mat;
+ }
+
#endif
#ifdef HAVE_TOON
Please sign in to comment.
Something went wrong with that request. Please try again.