Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Viewport.h

00001 // Mesh Algorithms: a library of algorithms to manipulate 3D meshes
00002 // Copyright (C) 2001 Tim Garthwaite and Jason Reposa
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 #ifndef VIEWPORT_H
00018 #define VIEWPORT_H
00019 
00020 #define DEFAULT_WIDTH 300
00021 #define DEFAULT_HEIGHT 300
00022 #define MODEL_CONTROL 0x0401
00023 #define EYE_CONTROL 0x0402
00024 
00025 #define PERCENTAGE 0x0101
00026 #define NUMBER 0x0102
00027 #define DEFAULT 0x0103
00028 
00029 #include "options.h"
00030 #include "VRMLParser.h"
00031 #include "Decimate.h"
00032 #include <iostream>
00033 #include <GL/gl.h>
00034 #include <GL/glu.h>
00035 
00036 class Viewport {
00037   GLint startx;
00038   GLint starty;
00039   GLint width;
00040   GLint height;
00041   Scene * scene;
00042   std::string filename;
00043 
00044   GLfloat TRANS_STEP;
00045   GLfloat ROT_STEP;
00046 
00047   Point center;
00048   GLfloat backUp;
00049   GLint viewportID;
00050 
00051   bool loaded;
00052 
00053   /*
00054     Transformation and rotation settings
00055   */
00056   GLfloat normalLength;
00057   GLfloat frustrumDepth;
00058   GLfloat X_Rot;
00059   GLfloat Y_Rot;
00060   GLfloat Z_Rot;
00061 
00062   GLfloat X_Off;
00063   GLfloat Y_Off;
00064   GLfloat Z_Off;
00065 
00066   /*
00067     Viewport drawing settings
00068   */
00069   bool lighting;
00070   bool smooth;
00071   bool normals;
00072   bool vert_normals;
00073 
00074   bool draw_points;
00075   bool draw_edges;
00076   bool draw_triangles;
00077 
00078   GLint control;
00079 
00080   GLvoid startingView();
00081   GLvoid defaultInit();
00082 
00083   /*
00084     For the display list
00085   */
00086 #ifdef USE_DISPLAY_LISTS
00087   GLuint partList;
00088   GLuint MODEL_LIST;
00089 #endif
00090 
00091   /*
00092     For normal functions
00093   */
00094   Point getCenter(Triangle * t);
00095   GLvoid drawNormals();
00096   GLvoid drawVertNormals();
00097   GLvoid drawModel();
00098   GLvoid drawWireframe();
00099   GLfloat findDistance(Vertex * v, std::set <Vertex *> * neighbors);
00100 
00101  public:
00102 
00103   GLint getMax(GLfloat d, GLint TYPE);
00105   Viewport(
00106     std::string file, 
00107     GLint id, 
00108     bool GUI = true
00109   );
00110 
00112   ~Viewport();
00113 
00115   bool save(std::string file = "NONE_SPECIFIED");
00116 
00118   bool load(std::string file);
00119 
00121   bool reload();
00122 
00124   bool fileOk();
00125 
00127   GLvoid render();
00128 
00130   bool resetSize(
00131     GLint x, 
00132     GLint y, 
00133     GLint w, 
00134     GLint h  
00135   );
00136 
00138   bool decimate(
00139     GLfloat d, 
00140     GLint TYPE 
00141   );
00142 
00143   GLint getStartX();     
00144   GLint getStartY();     
00145   GLint getWidth();      
00146   GLint getHeight();     
00147   GLint getViewportID(); 
00148   Scene * getScene();    
00149 
00150   bool setStartX(GLint x); 
00151   bool setStartY(GLint y); 
00152   bool setWidth(GLint w);  
00153   bool setHeight(GLint h); 
00154 
00155   bool setViewportID(GLint v);        
00156   bool setScene(Scene * s);           
00157   bool setFilename(std::string file); 
00158 
00159   std::string getFilename(); 
00160 
00161   GLvoid reset(); 
00162 
00163   GLvoid reportStatistics();  
00164   GLvoid makeSmooth();        
00165   GLvoid makeFlat();          
00166   GLvoid switchLighting();    
00167   GLvoid switchNormals();     
00168   GLvoid switchVertNormals(); 
00169 
00170   GLvoid switchViewPoints();    
00171   GLvoid switchViewEdges();     
00172   GLvoid switchViewTriangles(); 
00173 
00174   GLvoid setCameraControl(GLint c); 
00175 
00176   GLvoid decreaseX_Off(); 
00177   GLvoid increaseX_Off(); 
00178   GLvoid decreaseY_Off(); 
00179   GLvoid increaseY_Off(); 
00180   GLvoid decreaseZ_Off(); 
00181   GLvoid increaseZ_Off(); 
00182 
00183   GLvoid mouseX_Rot(GLfloat f); 
00184   GLvoid mouseY_Rot(GLfloat f); 
00185   GLvoid mouseZ_Rot(GLfloat f); 
00186 
00187   GLvoid decreaseX_Rot(); 
00188   GLvoid increaseX_Rot(); 
00189   GLvoid decreaseY_Rot(); 
00190   GLvoid increaseY_Rot(); 
00191   GLvoid decreaseZ_Rot(); 
00192   GLvoid increaseZ_Rot(); 
00193 };
00194 
00195 #endif

Generated on Fri Dec 21 00:16:49 2001 for Mesh Decimation by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001