00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
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
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
00085
00086 #ifdef USE_DISPLAY_LISTS
00087 GLuint partList;
00088 GLuint MODEL_LIST;
00089 #endif
00090
00091
00092
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