Changeset 829 for GTP/trunk/Lib
- Timestamp:
- 04/26/06 16:00:29 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj
r774 r829 286 286 </File> 287 287 <File 288 RelativePath=".\ src\libs\GeoLodStripsConstructor.h">289 </File> 290 <File 291 RelativePath=".\ src\libs\GeoLodStripsLibrary.h">292 </File> 293 <File 294 RelativePath=".\ src\libs\GeoLodTreeConstructor.h">295 </File> 296 <File 297 RelativePath=".\ src\libs\GeoLodTreeLibrary.h">298 </File> 299 <File 300 RelativePath=".\ src\libs\GeoMesh.h">301 </File> 302 <File 303 RelativePath=".\ src\libs\GeoMeshSimplifier.h">304 </File> 305 <File 306 RelativePath=".\ src\libs\GeoMeshSimpSequence.h">307 </File> 308 <File 309 RelativePath=".\ src\libs\GeoMeshStripifier.h">310 </File> 311 <File 312 RelativePath=".\ src\libs\GeoSerializable.h">313 </File> 314 <File 315 RelativePath=".\ src\libs\GeoSerializer.h">316 </File> 317 <File 318 RelativePath=".\ src\libs\GeoSubMesh.h">319 </File> 320 <File 321 RelativePath=".\ src\libs\GeoTreeSimplifier.h">322 </File> 323 <File 324 RelativePath=".\ src\libs\GeoTreeSimpSequence.h">325 </File> 326 <File 327 RelativePath=".\ src\libs\GeoVector2.h">328 </File> 329 <File 330 RelativePath=".\ src\libs\GeoVector3.h">331 </File> 332 <File 333 RelativePath=".\ src\libs\GeoVertexBuffer.h">334 </File> 335 <File 336 RelativePath=".\ src\libs\hoja.h">288 RelativePath=".\include\GeoLodStripsConstructor.h"> 289 </File> 290 <File 291 RelativePath=".\include\GeoLodStripsLibrary.h"> 292 </File> 293 <File 294 RelativePath=".\include\GeoLodTreeConstructor.h"> 295 </File> 296 <File 297 RelativePath=".\include\GeoLodTreeLibrary.h"> 298 </File> 299 <File 300 RelativePath=".\include\GeoMesh.h"> 301 </File> 302 <File 303 RelativePath=".\include\GeoMeshSimplifier.h"> 304 </File> 305 <File 306 RelativePath=".\include\GeoMeshSimpSequence.h"> 307 </File> 308 <File 309 RelativePath=".\include\GeoMeshStripifier.h"> 310 </File> 311 <File 312 RelativePath=".\include\GeoSerializable.h"> 313 </File> 314 <File 315 RelativePath=".\include\GeoSerializer.h"> 316 </File> 317 <File 318 RelativePath=".\include\GeoSubMesh.h"> 319 </File> 320 <File 321 RelativePath=".\include\GeoTreeSimplifier.h"> 322 </File> 323 <File 324 RelativePath=".\include\GeoTreeSimpSequence.h"> 325 </File> 326 <File 327 RelativePath=".\include\GeoVector2.h"> 328 </File> 329 <File 330 RelativePath=".\include\GeoVector3.h"> 331 </File> 332 <File 333 RelativePath=".\include\GeoVertexBuffer.h"> 334 </File> 335 <File 336 RelativePath=".\include\hoja.h"> 337 337 </File> 338 338 <File -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h
r774 r829 9 9 * @file GeoLodStripsLibrary.h 10 10 /*===========================================================================*/ 11 12 #ifndef _GEOLODSTRIPSLIBRARY 13 #define _GEOLODSTRIPSLIBRARY 11 14 12 15 #include "GeoMesh.h" … … 150 153 151 154 // (New) Get the number of strips. 152 uint32 GetStripCount(); 155 uint32 GetStripCount() const; 156 uint32 GetIndexCountByStrip(uint32) const; 153 157 }; 154 158 } 155 159 160 161 #endif -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h
r774 r829 1 #include "GeoBase.h" 1 //#include <string> 2 //#include <exception> 3 //#include "vertexdata.h" 2 4 5 #ifndef _GEOLODSTREELIBRARY 6 #define _GEOLODSTREELIBRARY 7 8 #include "GeoMesh.h" 9 #include "GeoLodStripsLibrary.h" 10 11 /*class LodStrip; 12 class Arbol; 13 class Foliage; 14 class Point3D; 15 */ 3 16 namespace Geometry 4 { 5 /// LodTreeLibrary interface class. 6 /** This module contains functions that handle the levels of detail of the input multiresolution trees. 7 For Any given resolution and object this module returns two thins: a set of triangle strips representing the trunk 8 and the branches at that resolution, and a triangle list representing the leaves at the same resolution. 9 \n\n 10 11 Inputs:\n 12 - The module receives a file describing a multiresolution tree object. 13 . 14 15 Outputs:\n 16 - The module returns a strip set that represents the level of deatil demanded for the trunk and a triangle list 17 that representes the level of detail for leaves. 18 . 19 20 */ 17 { 21 18 class LodTreeLibrary 22 19 { 23 20 public: 24 /// Constructor, receives as a parameter the name of the file including the multiresolution object. 25 LodTreeLibrary (std::string); 21 /* LodTreeLibrary( const LodTreeLibrary &); 22 LodTreeLibrary(LodTreeLibrary*);*/ 23 LodTreeLibrary( std::string trunkSimpSeqFile, 24 Geometry::Mesh *treeGeoMesh 25 /*, 26 std::string foliage_verts, 27 std::string foliage_leafs, 28 std::string foliage_simpl, 29 uint32 leafSubMeshID, 30 CREATEVERTEXDATAFUNC vdfun=NULL, 31 CREATEINDEXDATAFUNC idfun=NULL, 32 CREATEMULTIINDEXDATAFUNC midfun=NULL*/); // throws a FileNotFound exception 33 ~LodTreeLibrary(void); 34 uint32 GetUniqueID(void) const { return uniqueID; } 26 35 27 /// Destructor. 28 ~LodTreeLibrary (void); 36 // funciones ya descritas en la API 37 uint32 GoToTrunkLod(uint32 newlod); 38 uint32 MinTrunkLod(void) const; 39 uint32 MaxTrunkLod(void) const; 40 /* uint32 GoToFoliageLod(uint32 newlod); 41 uint32 MinFoliageLod(void) const; 42 uint32 MaxFoliageLod(void) const;*/ 29 43 30 /// Copy constructor 31 //LodTreeLibrary(const LodTreeLibrary&); 44 // funciones nuevas propuestas 45 // uint32 Get_Trunk_VertexCount(void) const; 46 // uint32 Get_Trunk_MaxIndexCount(uint32 istrip) const; 47 uint32 CurrentLOD_Trunk_StripCount(void) const; 48 // uint32 CurrentLOD_Trunk_IndexCount(void) const; 49 uint32 CurrentLOD_Trunk_IndexCountByStrip(uint32 istrip) const; 50 /* const VertexData* Get_Trunk_VertexData(void) const; 51 // const MultiIndexData* CurrentLOD_Trunk_Indices(void) const;*/ 32 52 33 /// Assignment operator 34 //LodTreeLibrary& operator =(const LodTreeLibrary&); 53 // uint32 Get_Foliage_VertexCount(void) const; 54 // uint32 Get_Foliage_MaxIndexCount(void) const; 55 // uint32 CurrentLOD_Foliage_IndexCount(void) const; 56 /* const IndexData* CurrentLOD_Foliage_Indices(void) const; 57 const VertexData* Get_Foliage_VertexData(void) const; 58 */ 59 // Geometry::IndexData *trunk_all_indices; 60 // unsigned int *indices_offsets; 35 61 36 /// Returns the highest LOD of the foliage. 37 uint32 MaxFoliageLod(); 62 const Geometry::SmallIntVector & GetStrip(uint32 istrip) const { return trunk->mStrips[istrip]; } 38 63 39 /// Returns the highest LOD of the trunk. 40 uint32 MaxTrunkLod(); 41 42 /// Returns the lowest LOD of the foliage. 43 uint32 MinFoliageLod(); 44 45 /// Returns the lowest LOD of the trunk. 46 uint32 MinTrunkLod(); 47 48 /// Returns de current foliage LOD and changes to the specified LOD. 49 uint32 GoToFoliageLod(uint32); 50 51 /// Returns de current trunk LOD and changes to the specified LOD. 52 uint32 GoToTrunkLod(uint32); 53 54 /// Establishes the new LOD range. 55 /// Only the LODs in that range are stored and used. 56 void TrimFoliageByLod(uint32, uint32); 57 58 /// Establishes the new LOD range. 59 /// Only the LODs in that range are stored and used. 60 void TrimTrunkByLod(uint32, uint32); 61 62 /// Returns the number of triangles of the foliage at the highest LOD. 63 uint32 MaxFoliageFaces(); 64 65 /// Returns the number of triangles of the trunk at the highest LOD. 66 uint32 MaxTrunkFaces(); 67 68 /// Returns the number of triangles of the foliage at the lowest LOD. 69 uint32 MinFoliageFaces(); 70 71 /// Returns the number of triangles of the trunk at the lowest LOD. 72 uint32 MinTrunkFaces(); 73 74 /// Returns the number of vertices of the foliage at the highest LOD. 75 uint32 MaxFoliageVertices(); 76 77 /// Returns the number of vertices of the trunk at the highest LOD. 78 uint32 MaxTrunkVertices(); 79 80 /// Returns the number of vertices of the foliage at the lowest LOD. 81 uint32 MinFoliageVertices(); 82 83 /// Returns the number of vertices of the trunk at the lowest LOD. 84 uint32 MinTrunkVertices(); 64 private: 65 uint32 uniqueID; 66 Geometry::LodStripsLibrary *trunk; 67 // Arbol *arbol; 68 // Foliage *foliage; 85 69 86 70 }; 87 71 } 72 73 #endif -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp
r774 r829 406 406 } 407 407 408 uint32 LodStripsLibrary::GetStripCount() 408 uint32 LodStripsLibrary::GetStripCount() const 409 409 { 410 410 return (uint32) mTotalStrips; 411 } 412 413 uint32 LodStripsLibrary::GetIndexCountByStrip(uint32 istrip) const 414 { 415 return (uint32) mStrips[istrip].size(); 411 416 } 412 417 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp
r774 r829 1 //#include "defs.h" 2 #include <assert.h> 1 3 #include "GeoLodTreeLibrary.h" 4 //#include "ArbolesInma/Arbol.h" 5 //#include "ArbolesInma/Foliage.h" 6 7 using namespace Geometry; 8 9 uint32 uniqueIDgen = 0; 10 11 Geometry::LodTreeLibrary::LodTreeLibrary(std::string trunkSimpSeqFile, 12 Geometry::Mesh *treeGeoMesh 13 /*, 14 std::string foliage_verts, 15 std::string foliage_leafs, 16 std::string foliage_simpl, 17 uint32 leafSubMeshID, 18 CREATEVERTEXDATAFUNC vdfun, 19 CREATEINDEXDATAFUNC idfun, 20 CREATEMULTIINDEXDATAFUNC midfun*/) 21 { 22 uniqueID = uniqueIDgen++; 23 24 // Cargar el tronco 25 /* trunk=new LodStrip(vdfun,midfun); 26 trunk->ED_NUEVA=1; 27 trunk->RESVARIABLE=0; 28 trunk->MODOTEST=0; //0: No test 1: plano 2: esfera 29 trunk->bTextures=0; 30 if (trunk->RecuperarModeloEFFICIENT((char*)trunkfile.c_str())==0) 31 throw FileNotFound(trunkfile); 32 33 // trunk->LodsDisp=(int) (trunk->cVerts.size()*0.99); 34 trunk->LodsDisp=(int) (trunk->TOTALCAMBIOS*0.95); 35 trunk->CopiarVectors2ArraysNUEVAED(); 36 trunk->LodActual=0; 37 trunk->CalculaNormalesVertice();*/ 38 39 trunk = new LodStripsLibrary(trunkSimpSeqFile,treeGeoMesh); 40 41 // Cargar la copa del árbol 42 /* arbol = new Arbol(foliage_verts.c_str(),foliage_leafs.c_str(),foliage_simpl.c_str(),vdfun,idfun); 43 foliage = new Foliage(arbol);*/ 44 45 } 46 /* 47 LodTreeLibrary::LodTreeLibrary(const LodTreeLibrary &t) 48 { 49 uniqueID = uniqueIDgen++; 50 assert( 51 // trunk=new LodStrip(t.trunk); 52 arbol=new Arbol(t.arbol); 53 foliage=new Foliage(arbol); 54 } 55 56 LodTreeLibrary::LodTreeLibrary(LodTreeLibrary *t) 57 { 58 uniqueID = uniqueIDgen++; 59 trunk=new LodStrip(t->trunk); 60 arbol=new Arbol(t->arbol); 61 foliage=new Foliage(arbol); 62 } 63 */ 64 65 LodTreeLibrary::~LodTreeLibrary(void) 66 { 67 if (trunk) delete trunk; 68 // if (arbol) delete arbol; 69 // if (foliage) delete foliage; 70 /* if (trunk_all_indices) delete trunk_all_indices; 71 if (indices_offsets) delete[] indices_offsets; 72 // if (current_foliage_indices) delete[] current_foliage_indices;*/ 73 } 74 75 uint32 LodTreeLibrary::CurrentLOD_Trunk_StripCount(void) const 76 { 77 assert(trunk); 78 // return trunk->TOTALTIRAS; 79 return trunk->GetStripCount(); 80 } 81 82 83 uint32 LodTreeLibrary::CurrentLOD_Trunk_IndexCountByStrip(uint32 istrip) const 84 { 85 assert(trunk); 86 // return trunk->lStripsV[istrip].size(); 87 return trunk->GetIndexCountByStrip(istrip); 88 } 89 /* 90 uint32 LodTreeLibrary::CurrentLOD_Trunk_IndexCount(void) const 91 { 92 assert(trunk); 93 return trunk->num_indices_current_lod; 94 } 95 */ 96 97 uint32 LodTreeLibrary::GoToTrunkLod(uint32 newlod) 98 { 99 return trunk->GoToLod(newlod); 100 /* uint32 previouslod = trunk->LodActual; 101 trunk->VerModeloVBO(newlod); 102 return previouslod;*/ 103 } 104 105 uint32 LodTreeLibrary::MinTrunkLod(void) const 106 { 107 // return 3; // un polígono: preguntar a francisco 108 // return (trunk->TOTALCAMBIOS*0.95f); 109 return trunk->MinLod(); 110 } 111 uint32 LodTreeLibrary::MaxTrunkLod(void) const 112 { 113 // return (trunk->cVerts.size()*0.99); 114 // return (trunk->TOTALCAMBIOS*0.95f); 115 // return 0; 116 return trunk->MaxLod(); 117 } 118 119 /* 120 uint32 LodTreeLibrary::GoToFoliageLod(uint32 newlod) 121 { 122 foliage->AjusteHojas(newlod); 123 124 arbol->indexdata->Begin(); 125 arbol->vertexdata->Begin(); 126 int i = foliage->ppio; 127 int auxnumhojas = 0; 128 while(i!=-1) 129 { 130 auxnumhojas++; 131 i=foliage->Acth[i].next; 132 } 133 134 assert(auxnumhojas*6<=arbol->indexdata->GetNumMaxIndices()); 135 arbol->indexdata->SetNumValidIndices(auxnumhojas*6); 136 i = foliage->ppio; 137 int kkkk=0; 138 while(i!=-1) 139 { 140 unsigned int v0,v1,v2,v3; 141 v0 = arbol->Hojas[i].Vert_Hoja[0]; 142 v1 = arbol->Hojas[i].Vert_Hoja[1]; 143 v2 = arbol->Hojas[i].Vert_Hoja[2]; 144 v3 = arbol->Hojas[i].Vert_Hoja[3]; 145 146 arbol->indexdata->SetIndex(kkkk+0,v0); 147 arbol->indexdata->SetIndex(kkkk+1,v1); 148 arbol->indexdata->SetIndex(kkkk+2,v2); 149 arbol->indexdata->SetIndex(kkkk+3,v2); 150 arbol->indexdata->SetIndex(kkkk+4,v1); 151 arbol->indexdata->SetIndex(kkkk+5,v3); 152 153 arbol->vertexdata->SetVertexTexCoord(v0,0,0); 154 arbol->vertexdata->SetVertexTexCoord(v1,0,1); 155 arbol->vertexdata->SetVertexTexCoord(v2,1,0); 156 arbol->vertexdata->SetVertexTexCoord(v3,1,1); 157 158 kkkk+=6; 159 i=foliage->Acth[i].next; 160 } 161 arbol->indexdata->End(); 162 arbol->vertexdata->End(); 163 164 return 0; 165 } 166 167 uint32 LodTreeLibrary::MinFoliageLod(void) const 168 { 169 return arbol->minHojas; // una hoja: preguntar a francisco 170 } 171 uint32 LodTreeLibrary::MaxFoliageLod(void) const 172 { 173 // return arbol->TotHojas; 174 return arbol->nHojas; 175 } 176 */ 177 /*const VertexData* LodTreeLibrary::Get_Trunk_VertexData(void) const 178 { 179 return trunk->vertices; 180 } 181 const MultiIndexData* LodTreeLibrary::CurrentLOD_Trunk_Indices(void) const 182 { 183 // return (uint32*)trunk->vStrips[istrip]; 184 // return trunk->indices_x_tira[istrip]; 185 return trunk->indices; 186 }*/ 187 188 /* 189 const VertexData* LodTreeLibrary::Get_Foliage_VertexData(void) const 190 { 191 return arbol->vertexdata; 192 } 193 194 const IndexData* LodTreeLibrary::CurrentLOD_Foliage_Indices(void) const 195 { 196 // return current_foliage_indices; 197 return arbol->indexdata; 198 }*/ 199 200 201 /*void ThrowFileNotFoundError(const char *text) 202 { 203 throw Geometry::FileNotFound(text); 204 }*/ 205 /* 206 uint32 LodTreeLibrary::CurrentLOD_Foliage_IndexCount(void) const 207 { 208 // return current_foliage_indexcount; 209 return arbol->indexdata->GetNumValidIndices(); 210 } 211 212 uint32 LodTreeLibrary::Get_Trunk_VertexCount(void) const 213 { 214 return trunk->TOTALVERTS; 215 } 216 217 uint32 LodTreeLibrary::Get_Trunk_MaxIndexCount(uint32 istrip) const 218 { 219 // return trunk->indices_x_tira[istrip]->GetNumMaxIndices(); 220 return trunk->indices->GetNumMaxIndices(istrip); 221 } 222 223 uint32 LodTreeLibrary::Get_Foliage_VertexCount(void) const 224 { 225 return arbol->vertexdata->GetNumVertices(); 226 } 227 uint32 LodTreeLibrary::Get_Foliage_MaxIndexCount(void) const 228 { 229 return arbol->indexdata->GetNumMaxIndices(); 230 } 231 */ -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h
r826 r829 14 14 #include <GeoMeshSaver.h> 15 15 #include <GeoMeshViewUI.h> 16 //#include <GeoLodStripsLibrary.h> 16 17 17 //#endif 18 namespace Geometry{ class LodTreeLibrary; } 18 19 19 20 class GeoMeshView : public fltk::GlWindow … … 33 34 bool mRotate; 34 35 bool mLodStrip; 36 bool mLodTree; 35 37 36 38 GeoMeshView(int x, … … 94 96 95 97 // Counter Clockwise mode. 96 void activeCCW(){mCCW = true;} ;97 void deactiveCCW(){mCCW = false;} ;98 void activeCCW(){mCCW = true;} 99 void deactiveCCW(){mCCW = false;} 98 100 99 101 // Pan mode. 100 void activePan(){mPan = true;} ;101 void deactivePan(){mPan = false;} ;102 void activePan(){mPan = true;} 103 void deactivePan(){mPan = false;} 102 104 103 105 // Rotate mode. 104 void activeRotate(){mRotate = true;} ;105 void deactiveRotate(){mRotate = false;} ;106 void activeRotate(){mRotate = true;} 107 void deactiveRotate(){mRotate = false;} 106 108 107 109 // LodStrip mode. 108 void activeLodStrip(){mLodStrip = true;}; 109 void deactiveLodStrip(){mLodStrip = false;}; 110 void activeLodStrip(){mLodStrip = true;} 111 void deactiveLodStrip(){mLodStrip = false;} 112 113 // LodTree mode. 114 void activeLodTree(){mLodTree = true;} 115 void deactiveLodTree(){mLodTree = false;} 116 110 117 111 118 // Ilumination modes. … … 158 165 // Sets the lodstripslibrary object. 159 166 void setLodStripsLibrary(Geometry::LodStripsLibrary *lodstrips); 167 // Sets the lodtreeslibrary object. 168 void setLodTreesLibrary(Geometry::LodTreeLibrary *lodtrees); 160 169 161 170 // Change de Level of detail of the object. … … 174 183 // LodStrips library object. 175 184 Geometry::LodStripsLibrary *lodStripsLib; 185 // LodTree library object. 186 Geometry::LodTreeLibrary *lodTreeLib; 176 187 177 188 // Flag tha activate / deactivate the color strips. … … 206 217 void drawTriangleStrip(int submesh); 207 218 void drawLodStrip(); 219 void drawLodTree(); 208 220 void enableColorStrips(); 209 221 void disableColorStrips(); -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
r774 r829 42 42 #include "GeoTreeSimpSequence.h" 43 43 #include "GeoLodStripsConstructor.h" 44 #include "GeoLodTreeLibrary.h" 44 45 45 46 // About Dialog. … … 58 59 LODTREES, 59 60 SELECT_LEAVES, 60 VISUALIZE_LODSTRIPS 61 VISUALIZE_LODSTRIPS, 62 VISUALIZE_LODTREES 61 63 }; 62 64 … … 96 98 // Lod strips object. 97 99 LodStripsLibrary *lodStripsLib; 100 // Lod tree object. 101 LodTreeLibrary *lodTreeLib; 98 102 99 103 // Mesh Bounds. … … 170 174 inline void cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*); 171 175 static void cb_menuLodTreesOpenLeavesSimplification(fltk::Item*, void*); 176 inline void cb_menuLodTreesVisualize_i(fltk::Item*, void*); 177 static void cb_menuLodTreesVisualize(fltk::Item*, void*); 172 178 inline void cb_menuHelpAbout_i(fltk::Item*, void*); 173 179 static void cb_menuHelpAbout(fltk::Item*, void*); … … 206 212 207 213 // Show the LodStrips visulization panel. 208 void show VisualizeLodStrips();214 void showSlider(); 209 215 210 216 void hideStripify(); … … 218 224 219 225 // Hide the LodStrips visualization panel. 220 void hide VisualizeLodStrips();226 void hideSlider(); 221 227 222 228 // Get the number of vertices. … … 292 298 fltk::Item *menuLodStripsVisualize; 293 299 fltk::ItemGroup *menuLodTrees; 300 fltk::Item *menuLodTreesVisualize; 294 301 295 302 fltk::Item *menuSelectLeaves; … … 333 340 // Initialize the lodstripslibrary for visualization. 334 341 void setLodStripsLibrary(std::string lodfile, Mesh *geomesh); 342 // Initialize the lodtreelibrary for visualization. 343 void setLodTreesLibrary(std::string lodfile, Mesh *geomesh); 335 344 336 345 // 26-12-2005 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r826 r829 586 586 drawLodStrip(); 587 587 } 588 else if (mLodTree) 589 { 590 drawLodTree(); 591 } 588 592 else 589 593 { … … 892 896 }//End drawTriangleStrip. 893 897 898 899 //--------------------------------------------------------------------------- 900 // Paint lodtree object. 901 //--------------------------------------------------------------------------- 902 void GeoMeshView::drawLodTree() 903 { 904 SubMesh *geosubmesh; 905 Index position; 906 Vector3 vector3; 907 float x,y,z; 908 float r,g,b; 909 int color_index; 910 int current_strip; 911 912 // Initialize current strip. 913 current_strip = 0; 914 915 // For each submesh. 916 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 917 { 918 919 color_index = 0; 920 921 // Gets the actual submesh. 922 geosubmesh = &geoMesh->mSubMesh[submesh]; 923 924 // For each one of the strips. 925 for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 926 { 927 // Paint the current strip. 928 glBegin(GL_TRIANGLE_STRIP); 929 930 if (getColorStrips()) 931 { 932 // Gets the color of the strip. 933 r = mStripColors[submesh][color_index].r; 934 g = mStripColors[submesh][color_index].g; 935 b = mStripColors[submesh][color_index].b; 936 937 // Change to the next color. 938 color_index++; 939 940 // Paint a new color. 941 glColor3f(r,g,b); 942 } 943 944 // For each index of the strip. 945 for (int index = 0; index < lodTreeLib->GetStrip(current_strip).size(); index++) 946 { 947 position = lodTreeLib->GetStrip(current_strip)[index]; 948 949 // Gets the vertex normal. 950 vector3 = geosubmesh->mVertexBuffer->mNormal[position]; 951 952 x = vector3[0]; 953 y = vector3[1]; 954 z = vector3[2]; 955 956 // Sets the vertex normal. 957 glNormal3f(x,y,z); 958 959 // Gets the vertex coordinates. 960 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 961 962 x = vector3[0]; 963 y = vector3[1]; 964 z = vector3[2]; 965 966 // Sets the vertex position. 967 glVertex3f(x,y,z); 968 } 969 970 // Increments current strip. 971 current_strip++; 972 973 // A strip is generated. 974 glEnd(); 975 976 } 977 } 978 979 }//End drawTriangleStrip. 980 981 982 894 983 //--------------------------------------------------------------------------- 895 984 // Sets the lodstripslibrary object. … … 902 991 903 992 //--------------------------------------------------------------------------- 993 // Sets the lodtreeslibrary object. 994 //--------------------------------------------------------------------------- 995 void GeoMeshView::setLodTreesLibrary(LodTreeLibrary *lodtrees) 996 { 997 lodTreeLib = lodtrees; 998 activeLodTree(); 999 } 1000 1001 1002 //--------------------------------------------------------------------------- 904 1003 // Change de Level of detail of the object. 905 1004 //--------------------------------------------------------------------------- 906 1005 void GeoMeshView::GoToLod(unsigned int lod) 907 1006 { 908 lodStripsLib->GoToLod(lod); 1007 if (mLodStrip) 1008 lodStripsLib->GoToLod(lod); 1009 if (mLodTree) 1010 lodTreeLib->GoToTrunkLod(lod); 909 1011 draw(); 910 1012 } -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r826 r829 682 682 // Deactive Lod strip visualization. 683 683 geoMeshView->deactiveLodStrip(); 684 geoMeshView->deactiveLodTree(); 684 685 685 686 // Loads a mesh file. … … 717 718 718 719 // Show the Visulize LodStrips panel. 719 show VisualizeLodStrips();720 showSlider(); 720 721 721 722 // Repaint the window. … … 723 724 } 724 725 725 void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) 726 { 727 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 728 -> 729 cb_menuLodStripsVisualize_i(o,v); 730 } 731 732 //--------------------------------------------------------------------------- 733 // Open LodStrip trunk Callback 734 //--------------------------------------------------------------------------- 735 inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) 736 { 737 } 738 739 void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) 740 { 741 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 742 -> 743 cb_menuLodTreesOpenLodStripTrunk_i(o,v); 744 } 745 746 //--------------------------------------------------------------------------- 747 // Open leaves simplification Callback 748 //--------------------------------------------------------------------------- 749 inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) 750 { 726 727 inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) 728 { 729 fltk::FileChooser *fcho; 730 const char *lod_file; 731 732 // Sets menus application state to NONE. 733 mApplicationState = NONE; 734 735 // Deactive Lod strip visualization. 736 geoMeshView->deactiveLodTree(); 737 geoMeshView->deactiveLodStrip(); 738 739 // Loads a mesh file. 740 openMeshFile(); 741 742 // Show title. 743 mProcessTitle->label("Visualize LodTrees"); 744 745 // If an object is loaded. 746 if (mGeoMesh != NULL) 747 { 748 fcho = new fltk::FileChooser("", 749 "*.lod", 750 fltk::FileChooser::CREATE, 751 "Open Lod file"); 752 753 fcho->exec(); 754 755 // If a file was selected. 756 if (fcho->value()) 757 { 758 // Build lod strips library. 759 setLodTreesLibrary(string(fcho->value()), mGeoMesh); 760 761 // Sets the aplication mode. 762 mApplicationState = VISUALIZE_LODTREES; 763 } 764 765 // Free memory. 766 delete fcho; 767 } 768 751 769 // Hide the right panel. 752 770 hideRightPanel(); 753 771 772 // Show the Visulize LodTree panel. 773 showSlider(); 774 775 // Repaint the window. 776 mMainWindow->redraw(); 777 } 778 void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) 779 { 780 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 781 -> 782 cb_menuLodTreesVisualize_i(o,v); 783 } 784 785 void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) 786 { 787 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 788 -> 789 cb_menuLodStripsVisualize_i(o,v); 790 } 791 792 //--------------------------------------------------------------------------- 793 // Open LodStrip trunk Callback 794 //--------------------------------------------------------------------------- 795 inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) 796 { 797 } 798 799 void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) 800 { 801 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 802 -> 803 cb_menuLodTreesOpenLodStripTrunk_i(o,v); 804 } 805 806 //--------------------------------------------------------------------------- 807 // Open leaves simplification Callback 808 //--------------------------------------------------------------------------- 809 inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) 810 { 811 // Hide the right panel. 812 hideRightPanel(); 813 754 814 // Show the LodTrees panel. 755 815 showOpenLeavesSimplification(); … … 768 828 cb_menuLodTreesOpenLeavesSimplification_i(o,v); 769 829 } 830 831 770 832 771 833 //--------------------------------------------------------------------------- … … 1338 1400 // Show the LodStrips visulization panel 1339 1401 //--------------------------------------------------------------------------- 1340 void GeoMeshViewUI::show VisualizeLodStrips()1402 void GeoMeshViewUI::showSlider() 1341 1403 { 1342 1404 mLodSlider->set_visible(); … … 1347 1409 // Hide the LodStrips visualization panel 1348 1410 //--------------------------------------------------------------------------- 1349 void GeoMeshViewUI::hide VisualizeLodStrips()1411 void GeoMeshViewUI::hideSlider() 1350 1412 { 1351 1413 mLodSlider->hide(); 1352 1414 mLodSlider->deactivate(); 1353 1415 } 1416 1354 1417 1355 1418 //--------------------------------------------------------------------------- … … 1495 1558 hideOpenMeshSimplification(); 1496 1559 hideOpenLeavesSimplification(); 1497 hide VisualizeLodStrips();1560 hideSlider(); 1498 1561 hideMeshInfo(); 1499 1562 } … … 1914 1977 1915 1978 //--------------------------------------------------------------------------- 1979 // Initialize the lodTreelibrary for visualization. 1980 //--------------------------------------------------------------------------- 1981 void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) 1982 { 1983 // If there is no lod strips object. 1984 if (lodTreeLib) 1985 { 1986 delete lodTreeLib; 1987 } 1988 1989 // New lod strips object. 1990 lodTreeLib = new Geometry::LodTreeLibrary(lodfile, geomesh); 1991 1992 // Sets the slider range. 1993 mLodSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); 1994 1995 // Pass to geomeshview the lod strips object. 1996 geoMeshView->setLodTreesLibrary(lodTreeLib); 1997 1998 // Puts the slider in the max position. 1999 mLodSlider->value(lodTreeLib->MinTrunkLod()); 2000 } 2001 2002 //--------------------------------------------------------------------------- 1916 2003 // Open a mesh file. 1917 2004 //--------------------------------------------------------------------------- … … 2026 2113 // Initialize the lod strip object. 2027 2114 lodStripsLib = NULL; 2115 lodTreeLib = NULL; 2028 2116 2029 2117 // Identify the mesh that stores the leaves … … 2445 2533 2446 2534 // Menu LodTrees. 2447 /*2535 2448 2536 { 2449 2537 fltk::ItemGroup* o; … … 2453 2541 { 2454 2542 fltk::Item* o; 2455 o = menuLodTreesOpenLodStripTrunk = new fltk::Item("Open LodStrip trunk"); 2456 o->callback((fltk::Callback*)cb_menuLodTreesOpenLodStripTrunk); 2457 } 2458 2459 { 2460 fltk::Item* o; 2461 o = menuLodTreesOpenLeavesSimplification = new fltk::Item("Open leaves simplification"); 2462 o->callback((fltk::Callback*)cb_menuLodTreesOpenLeavesSimplification); 2463 } 2543 o = menuLodTreesVisualize = new fltk::Item("Visualize Trunk"); 2544 o->callback((fltk::Callback*)cb_menuLodTreesVisualize); 2545 } 2546 2464 2547 o->end(); 2465 2548 } 2466 */2549 2467 2550 2468 2551 {
Note: See TracChangeset
for help on using the changeset viewer.