Browse Source

axes from autodof

Former-commit-id: 7c6b051ac34ea012b55b545016e4a3afe3f9c215
Alec Jacobson (jalec 11 years ago
parent
commit
e8ea1f9c76

+ 30 - 0
include/igl/right_axis.cpp

@@ -0,0 +1,30 @@
+#include "right_axis.h"
+
+#if __APPLE__
+#  include <OpenGL/gl.h>
+#elif defined(_WIN32)
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#    include <GL/glew.h>
+#    include <GL/gl.h>
+#else
+#  define GL_GLEXT_PROTOTYPES
+#  include <GL/gl.h>
+#  include <GL/glext.h>
+#endif
+
+IGL_INLINE void igl::right_axis(double * x, double * y, double * z)
+{
+  double mv[16];
+  glGetDoublev(GL_MODELVIEW_MATRIX, mv);
+  igl::right_axis(mv,x,y,z);
+}
+
+IGL_INLINE void igl::right_axis(const double * mv,double * x, double * y, double * z)
+{
+  *x = -mv[0*4+0];
+  *y = -mv[1*4+0];
+  *z = -mv[2*4+0];
+}
+

+ 24 - 0
include/igl/right_axis.h

@@ -0,0 +1,24 @@
+#ifndef IGL_RIGHT_AXIS_H
+#define IGL_RIGHT_AXIS_H 
+#include "igl_inline.h"
+namespace igl
+{
+  // Determines the right axis or depth axis of the current gl matrix
+  // Outputs:
+  //   x  pointer to x-coordinate in scene coordinates of the un-normalized
+  //     right axis 
+  //   y  pointer to y-coordinate in scene coordinates of the un-normalized
+  //     right axis 
+  //   z  pointer to z-coordinate in scene coordinates of the un-normalized
+  //     right axis
+  //   mv pointer to modelview matrix
+  //
+  // Note: Right axis is returned *UN-normalized*
+  IGL_INLINE void right_axis(double * x, double * y, double * z);
+  IGL_INLINE void right_axis(const double * mv, double * x, double * y, double * z);
+};
+
+#ifdef IGL_HEADER_ONLY
+#  include "right_axis.cpp"
+#endif
+#endif

+ 30 - 0
include/igl/up_axis.cpp

@@ -0,0 +1,30 @@
+#include "up_axis.h"
+
+#if __APPLE__
+#  include <OpenGL/gl.h>
+#elif defined(_WIN32)
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#    include <GL/glew.h>
+#    include <GL/gl.h>
+#else
+#  define GL_GLEXT_PROTOTYPES
+#  include <GL/gl.h>
+#  include <GL/glext.h>
+#endif
+
+IGL_INLINE void igl::up_axis(double * x, double * y, double * z)
+{
+  double mv[16];
+  glGetDoublev(GL_MODELVIEW_MATRIX, mv);
+  igl::up_axis(mv,x,y,z);
+}
+
+IGL_INLINE void igl::up_axis(const double *mv, double * x, double * y, double * z)
+{
+  *x = -mv[0*4+1];
+  *y = -mv[1*4+1];
+  *z = -mv[2*4+1];
+}
+

+ 26 - 0
include/igl/up_axis.h

@@ -0,0 +1,26 @@
+#ifndef IGL_UP_AXIS_H
+#define IGL_UP_AXIS_H 
+#include "igl_inline.h"
+namespace igl
+{
+// Determines the up axis or depth axis of the current gl matrix
+// Outputs:
+//   x  pointer to x-coordinate in scene coordinates of the un-normalized
+//     up axis 
+//   y  pointer to y-coordinate in scene coordinates of the un-normalized
+//     up axis 
+//   z  pointer to z-coordinate in scene coordinates of the un-normalized
+//     up axis
+  //   mv pointer to modelview matrix
+//
+// Note: Up axis is returned *UN-normalized*
+IGL_INLINE void up_axis(double * x, double * y, double * z);
+IGL_INLINE void up_axis(const double * mv, double * x, double * y, double * z);
+};
+
+#ifdef IGL_HEADER_ONLY
+#  include "up_axis.cpp"
+#endif
+#endif
+
+

+ 29 - 0
include/igl/view_axis.cpp

@@ -0,0 +1,29 @@
+#include "view_axis.h"
+
+#if __APPLE__
+#  include <OpenGL/gl.h>
+#elif defined(_WIN32)
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#    include <GL/glew.h>
+#    include <GL/gl.h>
+#else
+#  define GL_GLEXT_PROTOTYPES
+#  include <GL/gl.h>
+#  include <GL/glext.h>
+#endif
+
+IGL_INLINE void igl::view_axis(double * x, double * y, double * z)
+{
+  double mv[16];
+  glGetDoublev(GL_MODELVIEW_MATRIX, mv);
+  igl::view_axis(mv,x,y,z);
+}
+
+IGL_INLINE void igl::view_axis(const double * mv, double * x, double * y, double * z)
+{
+  *x = -mv[0*4+2];
+  *y = -mv[1*4+2];
+  *z = -mv[2*4+2];
+}

+ 28 - 0
include/igl/view_axis.h

@@ -0,0 +1,28 @@
+#ifndef IGL_VIEW_AXIS_H
+#define IGL_VIEW_AXIS_H 
+#include "igl_inline.h"
+
+namespace igl
+{
+  // Determines the view axis or depth axis of the current gl matrix
+  // Outputs:
+  //   x  pointer to x-coordinate in scene coordinates of the un-normalized
+  //     viewing axis 
+  //   y  pointer to y-coordinate in scene coordinates of the un-normalized
+  //     viewing axis 
+  //   z  pointer to z-coordinate in scene coordinates of the un-normalized
+  //     viewing axis
+  //   mv pointer to modelview matrix
+  //
+  // Note: View axis is returned *UN-normalized*
+  IGL_INLINE void view_axis(double * x, double * y, double * z);
+  IGL_INLINE void view_axis(const double * mv, double * x, double * y, double * z);
+};
+
+
+#ifdef IGL_HEADER_ONLY
+#  include "view_axis.cpp"
+#endif
+
+#endif
+

+ 2 - 0
todos.txt

@@ -23,3 +23,5 @@
     e.g. check_mesh(V,F,MANIFOLD | CLOSED | TRIANGLES_ONLY)
 - clean up Timer.h
 - svd.* depends on lapack, should use eigen...
+- use preprocessor macros to automatically include .cpp files at end of .h
+- unify include opengl with convenience includes