Browse Source

unproject to zero plane

Former-commit-id: f04453a7abdb35dbfc03c77aabcf7ca5c5e47dba
jalec 13 years ago
parent
commit
1d90da86f8

+ 1 - 0
include/igl/cocoa_key_to_anttweakbar_key.cpp

@@ -20,6 +20,7 @@ IGL_INLINE int igl::cocoa_key_to_anttweakbar_key(int key)
       return TW_KEY_ESCAPE;
     case 32:
       return TW_KEY_SPACE;
+    case 40:
     case 63272:
       return TW_KEY_DELETE;
     case 63232:

+ 1 - 1
include/igl/unproject.h

@@ -3,7 +3,7 @@
 #include "igl_inline.h"
 namespace igl
 {
-  // Wrapper for gluProject that uses the current GL_MODELVIEW_MATRIX,
+  // Wrapper for gluUnproject that uses the current GL_MODELVIEW_MATRIX,
   // GL_PROJECTION_MATRIX, and GL_VIEWPORT
   // Inputs:
   //   win*  screen space x, y, and z coordinates respectively

+ 30 - 0
include/igl/unproject_to_zero_plane.cpp

@@ -0,0 +1,30 @@
+#include "unproject_to_zero_plane.h"
+
+#ifdef __APPLE__
+# include <OpenGL/gl.h>
+# include <OpenGL/glu.h>
+#else
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
+# include <GL/gl.h>
+# include <GL/glu.h>
+#endif
+
+#include "project.h"
+#include "unproject.h"
+
+IGL_INLINE int igl::unproject_to_zero_plane(
+  const double winX,
+  const double winY,
+  double* objX,
+  double* objY,
+  double* objZ)
+{
+  double winOrigin[3]; 
+  igl::project(0,0,0,&winOrigin[0],&winOrigin[1],&winOrigin[2]);
+  return igl::unproject(winX, winY, winOrigin[2], objX, objY, objZ);
+}
+

+ 27 - 0
include/igl/unproject_to_zero_plane.h

@@ -0,0 +1,27 @@
+#ifndef IGL_UNPROJECT_TO_ZERO_PLANE_H
+#define IGL_UNPROJECT_TO_ZERO_PLANE_H
+#include "igl_inline.h"
+namespace igl
+{
+  // Wrapper for gluUnproject that uses the current GL_MODELVIEW_MATRIX,
+  // GL_PROJECTION_MATRIX, and GL_VIEWPORT to unproject a screen postion
+  // (winX,winY) to a 3d location at same depth as the current origin.
+  // Inputs:
+  //   win*  screen space x, y, and z coordinates respectively
+  // Outputs:
+  //   obj*  pointers to 3D objects' x, y, and z coordinates respectively
+  // Returns return value of gluUnProject call
+  IGL_INLINE int unproject_to_zero_plane(
+    const double winX,
+    const double winY,
+    double* objX,
+    double* objY,
+    double* objZ);
+}
+
+#ifdef IGL_HEADER_ONLY
+#  include "unproject_to_zero_plane.cpp"
+#endif
+
+#endif
+

+ 1 - 0
include/igl/verbose.h

@@ -18,6 +18,7 @@ namespace igl
 #  include <cstdarg>
 #endif
 
+#include <string>
 // http://channel9.msdn.com/forums/techoff/254707-wrapping-printf-in-c/
 inline  int igl::verbose(const char * msg,...)
 {