Changeset 1526 for GTP/trunk/Lib/Geom/shared/GeoTool
- Timestamp:
- 09/28/06 17:49:37 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
r1090 r1526 87 87 using namespace Geometry; 88 88 89 class GeoToolIndexData : public Geometry::IndexData 90 { 91 public: 92 GeoToolIndexData(unsigned int submeshes):Geometry::IndexData(){ 93 submeshcount = submeshes; 94 indices=new unsigned int*[submeshcount]; 95 indexCount=new unsigned int[submeshcount]; 96 for (int i=0; i<submeshcount; i++) 97 { 98 indices[i]=NULL; 99 indexCount[i]=0; 100 } 101 } 102 virtual ~GeoToolIndexData(void){ 103 for (int i=0; i<submeshcount; i++) 104 if (indices[i]) 105 delete[] indices[i]; 106 delete[] indices; 107 delete[] indexCount; 108 } 109 110 virtual void Begin(unsigned int submesh, unsigned int numinds){ 111 if (indices[submesh]) 112 delete[] indices[submesh]; 113 indices[submesh] = new unsigned int[numinds]; 114 indexCount[submesh] = numinds; 115 modifySubmesh=submesh; 116 } 117 118 virtual void SetIndex(unsigned int i, unsigned int index){ 119 indices[modifySubmesh][i] = index; 120 } 121 122 virtual void End(void){} 123 virtual void BorrowIndexData(const IndexData *){} 124 125 unsigned int submeshcount; 126 unsigned int **indices; 127 unsigned int *indexCount; 128 unsigned int modifySubmesh; 129 }; 130 89 131 class GeoMeshViewUI 90 132 { … … 109 151 // Lod tree object. 110 152 LodTreeLibrary *lodTreeLib; 111 153 112 154 MeshSimplifier *mMeshSimplifier; 113 155 TreeSimplifier *mTreeSimplifier; … … 117 159 118 160 MeshSimplificationSequence *oMeshSimpSequence; 119 LodStripsConstructor *oLodStrip;120 GeoMeshLoader *geoMeshLoader;161 LodStripsConstructor *oLodStrip; 162 GeoMeshLoader *geoMeshLoader; 121 163 122 164 inline void cb_menuFileOpen_i(fltk::Item*, void*); … … 288 330 289 331 public: 332 333 // the indexdata for the LOD models 334 GeoToolIndexData *lod_index_data; 290 335 291 336 GeoMeshView *geoMeshView; -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r1090 r1526 594 594 // For each strip. 595 595 // MultiIndexData *dataInterface = lodStripsLib->dataRetrievalInterface; 596 IndexData *dataInterface = lodStripsLib->dataRetrievalInterface;596 /* IndexData *dataInterface = lodStripsLib->dataRetrievalInterface; 597 597 size_t triangle_count = dataInterface->GetNumValidIndices() - 2; 598 /* for (int strip = 0; strip < dataInterface->GetNumPrims(); strip++) 599 { 600 // triangle_count += lodStripsLib->mStrips[strip].size() - 2; 601 triangle_count += dataInterface->GetNumValidIndices(strip) - 2; 602 }*/ 603 604 return triangle_count; 598 599 return triangle_count;*/ 600 601 return lodStripsLib->GetCurrentTriangleCount(); 605 602 } 606 603 … … 716 713 i = 0; 717 714 718 /*if (getColorStrips())715 if (getColorStrips()) 719 716 { 720 717 // Gets the color of the strip. … … 728 725 // Paint a new color. 729 726 glColor3f(r,g,b); 730 }*/ 727 GLfloat color[] = {r,g,b,1.0f}; 728 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color); 729 } 731 730 732 731 … … 904 903 905 904 // For each one of the strips. 906 /* for (int strip = 0; strip < geosubmesh->mStripCount; strip++)907 {908 // Paint the current strip.909 glBegin(GL_TRIANGLE_STRIP);910 911 if (getColorStrips())912 {913 // Gets the color of the strip.914 r = mStripColors[submesh][color_index].r;915 g = mStripColors[submesh][color_index].g;916 b = mStripColors[submesh][color_index].b;917 918 // Change to the next color.919 color_index++;920 921 // Paint a new color.922 glColor3f(r,g,b);923 }924 925 // For each index of the strip.926 for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(current_strip); index++)927 {928 position = lodStripsLib->dataRetrievalInterface->GetIndex(current_strip,index);929 930 // Gets the vertex normal.931 vector3 = geosubmesh->mVertexBuffer->mNormal[position];932 933 x = vector3[0];934 y = vector3[1];935 z = vector3[2];936 937 // Sets the vertex normal.938 glNormal3f(x,y,z);939 940 // set the texture coordinates if needed941 if (usetex)942 {943 vector2 = geosubmesh->mVertexBuffer->mTexCoords[position];944 x = vector2[0];945 y = vector2[1];946 glTexCoord2f(x,y);947 }948 949 // Gets the vertex coordinates.950 vector3 = geosubmesh->mVertexBuffer->mPosition[position];951 952 x = vector3[0];953 y = vector3[1];954 z = vector3[2];955 956 // Sets the vertex position.957 glVertex3f(x,y,z);958 }959 960 // Increments current strip.961 current_strip++;962 963 // A strip is generated.964 glEnd();965 966 }*/967 968 905 int indices_to_render = lodStripsLib->GetValidIndexCount(submesh); 969 906 int offset = lodStripsLib->GetValidOffset(submesh); 970 907 971 908 glBegin(GL_TRIANGLE_STRIP); 972 //for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(); index ++) 973 for (int index = offset; index < indices_to_render+offset; index ++) 974 { 975 position = lodStripsLib->dataRetrievalInterface->GetIndex(index); 909 // for (int index = offset; index < indices_to_render+offset; index ++) 910 for (int index = 0; index < mGeoMeshViewUI->lod_index_data->indexCount[submesh]; index ++) 911 { 912 // position = lodStripsLib->dataRetrievalInterface->GetIndex(index); 913 position = mGeoMeshViewUI->lod_index_data->indices[submesh][index]; 976 914 977 915 // Gets the vertex normal. … … 1045 983 1046 984 // For each one of the strips. 1047 /* for (int strip = 0; strip < geosubmesh->mStripCount; strip++)1048 {1049 // Paint the current strip.1050 glBegin(GL_TRIANGLE_STRIP);1051 1052 if (getColorStrips())1053 {1054 // Gets the color of the strip.1055 r = mStripColors[submesh][color_index].r;1056 g = mStripColors[submesh][color_index].g;1057 b = mStripColors[submesh][color_index].b;1058 1059 // Change to the next color.1060 color_index++;1061 1062 // Paint a new color.1063 glColor3f(r,g,b);1064 }1065 1066 // For each index of the strip.1067 for (int index = 0; index < lodTreeLib->CurrentLOD_Trunk_IndexCountByStrip(current_strip); index++)1068 {1069 position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(current_strip,index);1070 1071 // Gets the vertex normal.1072 vector3 = geosubmesh->mVertexBuffer->mNormal[position];1073 1074 x = vector3[0];1075 y = vector3[1];1076 z = vector3[2];1077 1078 // Sets the vertex normal.1079 glNormal3f(x,y,z);1080 1081 // set the texture coordinates if needed1082 if (usetex)1083 {1084 vector2 = geosubmesh->mVertexBuffer->mTexCoords[position];1085 x = vector2[0];1086 y = vector2[1];1087 glTexCoord2f(x,y);1088 }1089 1090 // Gets the vertex coordinates.1091 vector3 = geosubmesh->mVertexBuffer->mPosition[position];1092 1093 x = vector3[0];1094 y = vector3[1];1095 z = vector3[2];1096 1097 // Sets the vertex position.1098 glVertex3f(x,y,z);1099 }1100 1101 // Increments current strip.1102 current_strip++;1103 1104 // A strip is generated.1105 glEnd();1106 1107 }*/1108 1109 // int indices_to_render = lodTreeLib->trunk->GetValidIndexCount(submesh);1110 985 int indices_to_render = lodTreeLib->GetValidTrunkIndexCount(submesh); 1111 986 int begin_index = lodTreeLib->GetValidTrunkOffset(submesh); 1112 987 1113 988 glBegin(GL_TRIANGLE_STRIP); 1114 for (int index = begin_index; index < indices_to_render+begin_index; index ++) 1115 { 1116 position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(index); 989 // for (int index = begin_index; index < indices_to_render+begin_index; index ++) 990 for (int index = 0; index < mGeoMeshViewUI->lod_index_data->indexCount[submesh]; index ++) 991 { 992 // position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(index); 993 position = mGeoMeshViewUI->lod_index_data->indices[submesh][index]; 1117 994 1118 995 // Gets the vertex normal. … … 1157 1034 1158 1035 glBegin(GL_TRIANGLES); 1159 const Geometry::VertexData *foliage_verts = lodTreeLib->Get_Foliage_VertexData();1160 const Geometry::IndexData *foliage_inds = lodTreeLib->CurrentLOD_Foliage_Indices();1161 for (int j=0; j< lodTreeLib->CurrentLOD_Foliage_IndexCount(); j++)1162 { 1163 float vx,vy,vz;1036 Geometry::SubMesh & foliageSubMesh = geoMesh->mSubMesh[lodTreeLib->GetLeavesSubMesh()]; 1037 Geometry::Vector3 auxv; 1038 for (int j=0; j<mGeoMeshViewUI->lod_index_data->indexCount[lodTreeLib->GetLeavesSubMesh()]; j++) 1039 { 1040 int k = mGeoMeshViewUI->lod_index_data->indices[lodTreeLib->GetLeavesSubMesh()][j]; 1164 1041 if (usetex) 1165 1042 { 1166 foliage_verts->GetVertexTexCoord(foliage_inds->GetIndex(j),vx,vy);1167 glTexCoord2f( vx,vy);1168 } 1169 foliage_verts->GetVertexNormal(foliage_inds->GetIndex(j),vx,vy,vz);1170 glNormal3f( vx,vy,vz);1171 foliage_verts->GetVertexCoord(foliage_inds->GetIndex(j),vx,vy,vz);1172 glVertex3f( vx,vy,vz);1043 Geometry::Vector2 tc = foliageSubMesh.mVertexBuffer->mTexCoords[k]; 1044 glTexCoord2f(tc.x,tc.y); 1045 } 1046 auxv = foliageSubMesh.mVertexBuffer->mNormal[k]; 1047 glNormal3f(auxv.x,auxv.y,auxv.z); 1048 auxv = foliageSubMesh.mVertexBuffer->mPosition[k]; 1049 glVertex3f(auxv.x,auxv.y,auxv.z); 1173 1050 } 1174 1051 glEnd(); … … 1253 1130 1254 1131 glEnable (GL_POLYGON_OFFSET_LINE); 1255 glPolygonOffset(- 1,-1);1132 glPolygonOffset(-0.5,1); 1256 1133 glEnable(GL_DEPTH_TEST); 1257 1134 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 1269 1146 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 1270 1147 1271 glClearColor(0 ,0,0,0);1148 glClearColor(0.3,0.3,0.3,0); 1272 1149 1273 1150 if (mCW) … … 1292 1169 { 1293 1170 enableColorStrips(); 1294 glDisable(GL_LIGHTING);1171 //glDisable(GL_LIGHTING); 1295 1172 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); 1296 1173 drawGeoMesh(false); … … 1304 1181 { 1305 1182 disableColorStrips(); 1306 glDisable(GL_LIGHTING); 1307 glColor3d(0.0, 0.0, 1.0); 1183 //glDisable(GL_LIGHTING); 1184 glColor3d(0.0, 0.0, 0.0); 1185 GLfloat color[] = {0.0f,0.0f,0.0f,1.0f}; 1186 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color); 1187 1308 1188 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); 1309 1189 drawGeoMesh(true); … … 1313 1193 if (!mSolid) 1314 1194 { 1315 enableColorStrips();1316 glEnable(GL_LIGHTING);1195 disableColorStrips(); 1196 //glEnable(GL_LIGHTING); 1317 1197 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 1318 1198 drawGeoMesh(false); -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r1098 r1526 1075 1075 { 1076 1076 // Create the simplification sequence. 1077 createSimplificationSequence();1077 //createSimplificationSequence(); 1078 1078 1079 1079 // Show build process. … … 1120 1120 { 1121 1121 // Create the simplification sequence. 1122 createSimplificationSequence();1122 //createSimplificationSequence(); 1123 1123 1124 delete mMeshSimplifier;1124 //delete mMeshSimplifier; 1125 1125 geoMeshView->restoreContext(); 1126 1126 … … 1211 1211 1212 1212 // Simplification sequence. 1213 oMeshSimpSequence = new MeshSimplificationSequence();1213 //oMeshSimpSequence = new MeshSimplificationSequence(); 1214 1214 1215 1215 // Loads a simplification sequence file. 1216 oMeshSimpSequence->Load(Serializer("SimplifSequence.txt",Serializer::READ)); 1216 //oMeshSimpSequence->Load(Serializer("SimplifSequence.txt",Serializer::READ)); 1217 1218 // Simplification sequence. 1219 oMeshSimpSequence = mMeshSimplifier->GetSimplificationSequence(); 1217 1220 1218 1221 // If the simplification sequence and the mesh exist. … … 1224 1227 progress_function); 1225 1228 1226 // oSerializer = new Serializer(file_name,Serializer::Mode::WRITE); 1227 1228 oLodStrip->UpdateMesh(); 1229 oLodStrip->UpdateMesh(); 1229 1230 1230 1231 // Deletes the previous mesh. … … 1243 1244 1244 1245 mesh_saver = new GeoMeshSaver(); 1245 // file_name[strlen(file_name) - 4] = '\0';1246 1246 // file_name[strlen(file_name) - 4] = '\0'; 1247 1247 1248 mesh_saver->leavesSubMesh=idMeshLeaves; 1248 1249 mesh_saver->leavesVB=origSubMeshVB; … … 1252 1253 delete mesh_saver; 1253 1254 oLodStrip->Save(file_name); 1255 1256 // Delete simplified mesh. 1257 delete mMeshSimplifier; 1254 1258 // Close file. 1255 // delete oSerializer;1259 // delete oSerializer; 1256 1260 } 1257 1261 else … … 1262 1266 1263 1267 // Deletes the siplification sequence object. 1264 delete oMeshSimpSequence;1268 //delete oMeshSimpSequence; 1265 1269 1266 1270 if (mApplicationState==LODTREES_AUTO) … … 2145 2149 2146 2150 secsimpl = mMeshSimplifier->GetSimplificationSequence(); 2147 2148 secsimpl->putMeshName(nombremesh); // Nombre del mesh para guardar la secuencia de simplificación 2151 2152 // Nombre del mesh para guardar la secuencia de simplificación. 2153 secsimpl->putMeshName(nombremesh); 2149 2154 secsimpl->Save(Geometry::Serializer("SimplifSequence.txt",Serializer::WRITE)); 2150 2151 //delete secsimpl;2152 2155 } 2153 2156 … … 2325 2328 { 2326 2329 delete lodStripsLib; 2330 delete lod_index_data; 2327 2331 } 2328 2332 2329 2333 // New lod strips object. 2330 lodStripsLib = new LodStripsLibrary(loddata, geomesh); 2334 lod_index_data = new GeoToolIndexData(geomesh->mSubMeshCount); 2335 lodStripsLib = new LodStripsLibrary(loddata, geomesh, lod_index_data); 2331 2336 2332 2337 // Sets the slider range. … … 2348 2353 // If there is no lod strips object. 2349 2354 if (lodTreeLib) 2355 { 2350 2356 delete lodTreeLib; 2357 delete lod_index_data; 2358 } 2351 2359 2352 2360 // New lod strips object. 2353 2361 2354 lodTreeLib = new Geometry::LodTreeLibrary(lodstripsdata,treesimpseq,geomesh/*,ileafSubMesh*/); 2362 lod_index_data = new GeoToolIndexData(geomesh->mSubMeshCount); 2363 lodTreeLib = new Geometry::LodTreeLibrary(lodstripsdata,treesimpseq,geomesh,lod_index_data); 2355 2364 2356 2365 // Sets the slider range. … … 2669 2678 2670 2679 { 2671 mMetricLabel = new fltk::Output(26, 28, 5, 25, "Metric");2680 mMetricLabel = new fltk::Output(26, 28, 0, 25, "Metric"); 2672 2681 fltk::Output* o = mMetricLabel; 2673 2682 o->set_vertical(); … … 2715 2724 2716 2725 { 2717 mMeshReductionLabel = new fltk::Output(26, 124, 5, 25, "Mesh Reduction");2726 mMeshReductionLabel = new fltk::Output(26, 124, 0, 25, "Mesh Reduction"); 2718 2727 fltk::Output* o = mMeshReductionLabel; 2719 2728 o->set_vertical();
Note: See TracChangeset
for help on using the changeset viewer.