// generated by Fast Light User Interface Designer (fluid) version 2.0100 #ifndef GeoMeshView_h #define GeoMeshView_h #include #include #include #include #include #include #include #include //#ifndef GeoMeshViewUI_h #include #include //#endif namespace Geometry{ class LodTreeLibrary; } 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 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;}; // 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);}; // 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(); // JGA // Sets the colorsubmeshi variable void setColorSubmeshi(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(unsigned int lod); 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 colorsubmeshi; // 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; virtual int handle(int event); // Paint the mesh object. void drawGeoMesh(int selectedMesh); void drawTriangleList(int submesh, bool selectedMesh); void drawTriangleStrip(int submesh); void drawLodStrip(); void drawLodTree(); void enableColorStrips(); void disableColorStrips(); 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 *mSharedPosArray; GLfloat *mSharedNorArray; GLuint **mIndexArray; struct ColorElement { float r; float g; float b; }; ColorElement **mStripColors; int mStripColorsCount; // Idetifier of Visualization List. GLuint mIdVisualList; }; #endif