// generated by Fast Light User Interface Designer (fluid) version 2.0100 #ifndef GeoMeshView_h #define GeoMeshView_h #include "GL/glew.h" #ifdef _WIN32 #include "GL/wglew.h" #endif #include #include #include #include #include #include #include #include #include #include namespace Geometry{ class LodTreeLibrary; } using namespace Geometry; using namespace std; class GeoMeshView : public fltk::GlWindow { friend class GeoMeshViewUI; public: // this value determines the scaling factor used to draw the cube. double size; double mScaleFactor; bool mWire; bool mSolid; bool mLighting; bool mCW; bool mCCW; bool mPan; bool mRotate; bool mLodStrip; bool mLodTree; GeoMeshView(int x, int y, int w, int h, const char *l = 0, GeoMeshViewUI *geoMeshViewUI = 0); /* This function is callalled by the zoom slider * */ void scale(double factor){size = factor;}; /* Set the rotation about the vertical (y ) axis. * * This function is called by the horizontal roller in GeoMeshViewUI * and the initialize button in GeoMeshViewUI. */ void v_angle(float angle){vAng = angle;}; // Return the rotation about the vertical (y ) axis. float v_angle(){return vAng;}; /* Set the rotation about the horizontal (x ) axis. * * This function is called by the vertical roller in GeoMeshViewUI and the * initialize button in GeoMeshViewUI. */ void h_angle(float angle){hAng = angle;}; // the rotation about the horizontal (x ) axis. float h_angle(){return hAng;}; /* Sets the x shift of the cube view camera. * * This function is called by the slider in GeoMeshViewUI and the * initialize button in GeoMeshViewUI. */ void panx(float x){xshift = x;}; /* Sets the y shift of the cube view camera. * * This function is called by the slider in GeoMeshViewUI and the * initialize button in GeoMeshViewUI. */ void pany(float y){yshift = y;}; // Wire model. void activeWire(){mWire = true;}; void deactiveWire(){mWire = false;}; // Solid model. void activeSolid(){mSolid = true;}; void deactiveSolid(){mSolid = false;}; // Lighting. void activeLighting(){mLighting = true;}; void deactiveLighting(){mLighting = false;}; // Clockwise mode. void activeCW(){mCW = true;}; void deactiveCW(){mCW = false;}; // Counter Clockwise mode. void activeCCW(){mCCW = true;} void deactiveCCW(){mCCW = false;} // Pan mode. void activePan(){mPan = true;} void deactivePan(){mPan = false;} // Rotate mode. void activeRotate(){mRotate = true;} void deactiveRotate(){mRotate = false;} // LodStrip mode. void activeLodStrip(){mLodStrip = true;} void deactiveLodStrip(){mLodStrip = false;} // LodTree mode. void activeLodTree(){mLodTree = true;} void deactiveLodTree(){mLodTree = false;} // Ilumination modes. void flat(){glShadeModel(GL_FLAT);}; void smooth(){glShadeModel(GL_SMOOTH);}; // Change Open GL context. #ifdef _WIN32 HDC hOldDC; HGLRC hOldRC; #endif void saveContext() { #ifdef _WIN32 hOldDC = wglGetCurrentDC(); hOldRC = wglGetCurrentContext(); #endif } void restoreContext() { #ifdef _WIN32 wglMakeCurrent( hOldDC, hOldRC ); #endif } // Fits the object in the window view. void fit() { vAng = 0.0; hAng = 0.0; size = 0.0; xshift = 0.0; yshift = 0.0; }; /* Sets the Mesh to display. */ void setMesh(Geometry::Mesh *geomesh); /* The widget class draw() override. * The draw() function initialize Gl for another round of * drawing then calls specialized functions for drawing each * of the entities displayed in the cube view. */ void draw(); // Gets the bounding box. //Geometry::GeometryBounds getBoundingBox(); // Store one random color to each strip. void setStripColors(); // Get the number of frames per second. size_t getFPS(); // Sets the submesh selected. void setSubMeshSelected(int submeshIndex); // Sets the leaves submesh index. void setLeavesSubMesh(int submeshIndex); // Gets the leaves submesh index. int getLeavesSubMesh(); // Gets the triangle count of the current lod. size_t getLodStripsTriangleCount(); // Sets the lodstripslibrary object. void setLodStripsLibrary(Geometry::LodStripsLibrary *lodstrips); // Sets the lodtreeslibrary object. void setLodTreesLibrary(Geometry::LodTreeLibrary *lodtrees); // Change de Level of detail of the object. void GoToLod_LodStrip(float lod); void GoToLod_LodTree(float lod); // load a image file as a texture void LoadTexture(const char *); void LoadTextureSubMesh(int isubmesh, const char *); void addTexFile(const char *); void changeTexFile(int isubmesh, const char *); int getSubMeshCount(void) const { return mSubMeshCount; } void resetTextures(void); int findLeavesSubMesh(void); private: /* Draw the cube boundaries * Draw the faces of the cube using the boxv[] vertices, using * GL_LINE_LOOP for the faces. The color is #defined by * CUBECOLOR. */ // GeoMeshViewUI. GeoMeshViewUI *mGeoMeshViewUI; // LodStrips library object. Geometry::LodStripsLibrary *lodStripsLib; // LodTree library object. Geometry::LodTreeLibrary *lodTreeLib; // Flag tha activate / deactivate the color strips. bool colorStripsFlag; // Stores the index of the mesh to paint of red color. int mSubMeshSelected; // Frames per second. size_t mFPS; // StartTime for FPS. clock_t mStartTime; float xMed; float yMed; float zMed; int leavesSubMesh; // Submesh count. int mSubMeshCount; // Mesh to show. Geometry::Mesh *geoMesh; // Current texture handle (OpenGL handle: 0=no texture) GLuint current_texture; GLuint *current_texture_submesh; bool use_texture_mapping; // this flag enables texture mapping when a texture is loaded bool SetTextureRenderingState(int submesh); // returns true if textures must be used virtual int handle(int event); // Paint the mesh object. void drawGeoMesh(bool paintWire); void drawTriangleList(int submesh, bool selectedMesh, bool paintWire); void drawTriangleStrip(int submesh); void drawLodStrip(); void drawLodTree(); void enableColorStrips(); void disableColorStrips(); void enableTextureMapping(){ use_texture_mapping=true; } void disableTextureMapping(){ use_texture_mapping=false; } bool isTextureMappingEnabled(){ return use_texture_mapping; } bool getColorStrips(); // Calculate the number of frames per second. void calcFPS(); // Copy the mesh vertices to the vertex array. void refreshVertices(Geometry::Mesh *geomesh); float vAng; float hAng; float xshift; float yshift; int mMouseX; int mMouseY; int mSizeY; GLfloat **mPosArray; GLfloat **mNorArray; GLfloat **mTexCoordArray; GLfloat *mSharedPosArray; GLfloat *mSharedNorArray; GLfloat *mSharedTexCoordArray; GLuint **mIndexArray; struct ColorElement { float r; float g; float b; }; ColorElement **mStripColors; int mStripColorsCount; // Idetifier of Visualization List. GLuint mIdVisualList; // List of texture files of the mesh. vector mMeshTexFiles; }; #endif