Browse Source

draw beach ball, fixed warning in camera and readobj

Former-commit-id: 64e4ed55b3eaf97a7b347123590ea4a7d494c81e
Alec Jacobson (jalec 12 years ago
parent
commit
b657cda5f9

+ 1 - 1
Makefile

@@ -8,7 +8,7 @@ include Makefile.conf
 all: LFLAGS +=
 all: LFLAGS +=
 OPTFLAGS=-O3 -DNDEBUG
 OPTFLAGS=-O3 -DNDEBUG
 #debug: OPTFLAGS= -g -Wall -Werror
 #debug: OPTFLAGS= -g -Wall -Werror
-debug: OPTFLAGS= -g -Wall
+debug: OPTFLAGS= -g -Wall -Weffc++
 CFLAGS += $(OPTFLAGS)
 CFLAGS += $(OPTFLAGS)
 
 
 EXTRA_DIRS=
 EXTRA_DIRS=

+ 6 - 6
include/igl/Camera.cpp

@@ -2,21 +2,23 @@
 #include <igl/canonical_quaternions.h>
 #include <igl/canonical_quaternions.h>
 #include <algorithm>
 #include <algorithm>
 
 
-igl::Camera::Camera()
+igl::Camera::Camera():
+  zoom(1.0),
+  angle(45)
 {
 {
   using namespace igl;
   using namespace igl;
   using namespace std;
   using namespace std;
   // Defaults
   // Defaults
   // canonical (X,Y) view
   // canonical (X,Y) view
   copy(XY_PLANE_QUAT_D,XY_PLANE_QUAT_D+4,rotation);
   copy(XY_PLANE_QUAT_D,XY_PLANE_QUAT_D+4,rotation);
-  zoom = 1.0;
-  angle = 45;
   pan[0] = 0.0;
   pan[0] = 0.0;
   pan[1] = 0.0;
   pan[1] = 0.0;
   pan[2] = 0.0;
   pan[2] = 0.0;
 }
 }
 
 
-igl::Camera::Camera(const Camera & that)
+igl::Camera::Camera(const Camera & that):
+  zoom(that.zoom),
+  angle(that.angle)
 {
 {
   pan[0] = that.pan[0];
   pan[0] = that.pan[0];
   pan[1] = that.pan[1];
   pan[1] = that.pan[1];
@@ -25,6 +27,4 @@ igl::Camera::Camera(const Camera & that)
   {
   {
     rotation[i] = that.rotation[i];
     rotation[i] = that.rotation[i];
   }
   }
-  zoom = that.zoom;
-  angle = that.angle;
 }
 }

+ 5 - 0
include/igl/draw_beach_ball.cpp

@@ -220,6 +220,9 @@ IGL_INLINE void igl::draw_beach_ball()
   using namespace std;
   using namespace std;
 
 
   CreateSphere();
   CreateSphere();
+  // Keep track of opengl settings
+  int cm;
+  glGetIntegerv(GL_COLOR_MATERIAL,&cm);
   // Draw triangles
   // Draw triangles
   glEnable(GL_COLOR_MATERIAL);
   glEnable(GL_COLOR_MATERIAL);
   glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);
   glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);
@@ -261,4 +264,6 @@ IGL_INLINE void igl::draw_beach_ball()
     glEnd();
     glEnd();
     glPopMatrix();
     glPopMatrix();
   }
   }
+
+  (cm ? glEnable(GL_COLOR_MATERIAL):glDisable(GL_COLOR_MATERIAL));
 }
 }

+ 4 - 4
include/igl/readMESH.cpp

@@ -220,10 +220,10 @@ IGL_INLINE bool igl::readMESH(
 
 
 template <typename DerivedV, typename DerivedF, typename DerivedT>
 template <typename DerivedV, typename DerivedF, typename DerivedT>
 IGL_INLINE bool igl::readMESH(
 IGL_INLINE bool igl::readMESH(
-                         const std::string str,
-                         Eigen::PlainObjectBase<DerivedV>& V,
-                         Eigen::PlainObjectBase<DerivedT>& T,
-                         Eigen::PlainObjectBase<DerivedF>& F)
+  const std::string str,
+  Eigen::PlainObjectBase<DerivedV>& V,
+  Eigen::PlainObjectBase<DerivedT>& T,
+  Eigen::PlainObjectBase<DerivedF>& F)
 {
 {
   std::vector<std::vector<double> > vV,vT,vF;
   std::vector<std::vector<double> > vV,vT,vF;
   bool success = igl::readMESH(str,vV,vT,vF);
   bool success = igl::readMESH(str,vV,vT,vF);

+ 4 - 4
include/igl/readMESH.h

@@ -35,10 +35,10 @@ namespace igl
   //   F  eigen int matrix #F by 3
   //   F  eigen int matrix #F by 3
   template <typename DerivedV, typename DerivedF, typename DerivedT>
   template <typename DerivedV, typename DerivedF, typename DerivedT>
   IGL_INLINE bool readMESH(
   IGL_INLINE bool readMESH(
-                           const std::string str,
-                           Eigen::PlainObjectBase<DerivedV>& V,
-                           Eigen::PlainObjectBase<DerivedT>& T,
-                           Eigen::PlainObjectBase<DerivedF>& F);
+    const std::string str,
+    Eigen::PlainObjectBase<DerivedV>& V,
+    Eigen::PlainObjectBase<DerivedT>& T,
+    Eigen::PlainObjectBase<DerivedF>& F);
 }
 }
 
 
 #ifdef IGL_HEADER_ONLY
 #ifdef IGL_HEADER_ONLY

+ 0 - 6
include/igl/readOBJ.cpp

@@ -33,10 +33,6 @@ IGL_INLINE bool igl::readOBJ(
   FN.clear();
   FN.clear();
   
   
   // variables an constants to assist parsing the .obj file
   // variables an constants to assist parsing the .obj file
-  // flag for whether vertex texture coordinates exist in file
-  bool has_texture = false;
-  // flag for whether vertex normals exist in file
-  bool has_normals = false;
   // Constant strings to compare against
   // Constant strings to compare against
   std::string v("v");
   std::string v("v");
   std::string vn("vn");
   std::string vn("vn");
@@ -78,7 +74,6 @@ IGL_INLINE bool igl::readOBJ(
         V.push_back(vertex);
         V.push_back(vertex);
       }else if(type == vn)
       }else if(type == vn)
       {
       {
-        has_normals = true;
         double x[3];
         double x[3];
         int count = 
         int count = 
         sscanf(l,"%lf %lf %lf\n",&x[0],&x[1],&x[2]);
         sscanf(l,"%lf %lf %lf\n",&x[0],&x[1],&x[2]);
@@ -98,7 +93,6 @@ IGL_INLINE bool igl::readOBJ(
         N.push_back(normal);
         N.push_back(normal);
       }else if(type == vt)
       }else if(type == vt)
       {
       {
-        has_texture = true;
         double x[3];
         double x[3];
         int count = 
         int count = 
         sscanf(l,"%lf %lf %lf\n",&x[0],&x[1],&x[2]);
         sscanf(l,"%lf %lf %lf\n",&x[0],&x[1],&x[2]);