Changeset 1549 for GTP/trunk/Lib
- Timestamp:
- 10/02/06 14:17:27 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool
- Files:
-
- 13 added
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h
r1058 r1549 19 19 20 20 namespace Geometry{ class LodTreeLibrary; } 21 22 using namespace Geometry; 23 using namespace std; 21 24 22 25 class GeoMeshView : public fltk::GlWindow … … 39 42 40 43 GeoMeshView(int x, 41 int y,42 int w,43 int h,44 const char *l = 0,45 GeoMeshViewUI *geoMeshViewUI = 0);44 int y, 45 int w, 46 int h, 47 const char *l = 0, 48 GeoMeshViewUI *geoMeshViewUI = 0); 46 49 47 50 /* This function is callalled by the zoom slider … … 55 58 * and the initialize button in GeoMeshViewUI. 56 59 */ 57 void v_angle(float angle){vAng =angle;};60 void v_angle(float angle){vAng = angle;}; 58 61 59 62 // Return the rotation about the vertical (y ) axis. … … 66 69 * initialize button in GeoMeshViewUI. 67 70 */ 68 void h_angle(float angle){hAng =angle;};71 void h_angle(float angle){hAng = angle;}; 69 72 70 73 // the rotation about the horizontal (x ) axis. … … 76 79 * initialize button in GeoMeshViewUI. 77 80 */ 78 void panx(float x){xshift =x;};81 void panx(float x){xshift = x;}; 79 82 80 83 /* Sets the y shift of the cube view camera. … … 83 86 * initialize button in GeoMeshViewUI. 84 87 */ 85 void pany(float y){yshift =y;};88 void pany(float y){yshift = y;}; 86 89 87 90 // Wire model. … … 116 119 void activeLodTree(){mLodTree = true;} 117 120 void deactiveLodTree(){mLodTree = false;} 118 119 121 120 122 // Ilumination modes. … … 134 136 #endif 135 137 } 138 136 139 void restoreContext() 137 140 { … … 196 199 void LoadTexture(const char *); 197 200 void LoadTextureSubMesh(int isubmesh, const char *); 201 void addTexFile(const char *); 202 void changeTexFile(int isubmesh, const char *); 198 203 199 204 int getSubMeshCount(void) const { return mSubMeshCount; } … … 294 299 // Idetifier of Visualization List. 295 300 GLuint mIdVisualList; 301 302 // List of texture files of the mesh. 303 vector<string> mMeshTexFiles; 296 304 }; 297 305 -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
r1543 r1549 435 435 int numSubMeshNames; 436 436 char **SubMeshNames; 437 438 437 }; 439 438 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r1543 r1549 451 451 void GeoMeshView::setMesh(Mesh *geomesh) 452 452 { 453 GLfloat color_blanco[] = {1.0f,1.0f,1.0f,1.0f};453 GLfloat white_color[] = {1.0f,1.0f,1.0f,1.0f}; 454 454 455 455 this->geoMesh = geomesh; … … 461 461 refreshVertices(geomesh); 462 462 463 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE, color_blanco);463 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,white_color); 464 464 465 465 if (current_texture_submesh) … … 470 470 current_texture_submesh = new GLuint[getSubMeshCount()]; 471 471 472 for (int i =0; i<getSubMeshCount(); i++)472 for (int i = 0; i < getSubMeshCount(); i++) 473 473 { 474 474 current_texture_submesh[i] = 0; 475 476 LoadTextureSubMesh(i, mMeshTexFiles[i].c_str()); 475 477 } 476 478 } … … 709 711 // The end of the index array. 710 712 indexEnd = &geosubmesh->mIndex[geosubmesh->mIndexCount]; 711 713 size= indexEnd - indexBegin; 712 714 } 713 715 else … … 716 718 indexEnd = geosubmesh->mStrip[strip + 1]; 717 719 718 for (index = indexBegin; index < indexEnd; index++)719 {720 size++;721 }720 for (index = indexBegin; index < indexEnd; index++) 721 { 722 size++; 723 } 722 724 // Remove degenerated 723 725 //indexEnd--; … … 744 746 745 747 746 //VERTEX ARRAYS 747 glEnableClientState(GL_VERTEX_ARRAY); 748 glEnableClientState(GL_NORMAL_ARRAY); 749 if (usetex) 750 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 751 else 752 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 748 //VERTEX ARRAYS 749 glEnableClientState(GL_VERTEX_ARRAY); 750 glEnableClientState(GL_NORMAL_ARRAY); 751 752 if (usetex) 753 { 754 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 755 } 756 else 757 { 758 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 759 } 753 760 754 761 glVertexPointer(3, GL_FLOAT, 0, geosubmesh->mVertexBuffer->mPosition); 755 762 glNormalPointer(GL_FLOAT, 0, geosubmesh->mVertexBuffer->mNormal); 763 756 764 if (usetex) 765 { 757 766 glTexCoordPointer(2, GL_FLOAT, 0, geosubmesh->mVertexBuffer->mTexCoords); 767 } 758 768 759 769 glDrawElements( GL_TRIANGLE_STRIP, 760 size 761 , 762 GL_UNSIGNED_INT, 763 indexBegin 764 ); 765 766 if (submesh==leavesSubMesh) 767 { 768 glDisable(GL_ALPHA_TEST); 769 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0); 770 } 771 772 } 773 770 size, 771 GL_UNSIGNED_INT, 772 indexBegin); 773 774 if (submesh == leavesSubMesh) 775 { 776 glDisable(GL_ALPHA_TEST); 777 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0); 778 } 779 } 774 780 }//End drawTriangleStrip. 775 781 … … 1221 1227 { 1222 1228 disableColorStrips(); 1229 1223 1230 //glDisable(GL_LIGHTING); 1224 glColor3d(0.0, 0.0, 0.0); 1225 1226 GLfloat color[] = {0.0f,0.0f,0.0f,1.0f}; 1231 1232 GLfloat color[4]; 1233 1234 if (mSolid) 1235 { 1236 glColor3d(0.0, 0.0, 0.0); 1237 color[0] = 0.0f; 1238 color[1] = 0.0f; 1239 color[2] = 0.0f; 1240 color[3] = 1.0f; 1241 } 1242 else 1243 { 1244 glColor3d(1.0, 1.0, 1.0); 1245 color[0] = 1.0f; 1246 color[1] = 1.0f; 1247 color[2] = 1.0f; 1248 color[3] = 1.0f; 1249 } 1227 1250 1228 1251 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color); … … 1282 1305 } 1283 1306 1307 // Add texture file name to the list of texture files of mesh. 1308 void GeoMeshView::addTexFile(const char *imgfile) 1309 { 1310 mMeshTexFiles.push_back(string(imgfile)); 1311 } 1312 1313 // Change texture file of a given submesh. 1314 void GeoMeshView::changeTexFile(int isubmesh, const char *imgfile) 1315 { 1316 mMeshTexFiles[isubmesh] = string(imgfile); 1317 } 1318 1284 1319 void GeoMeshView::resetTextures(void) 1285 1320 { 1321 // Clears texture files list. 1322 mMeshTexFiles.clear(); 1323 1286 1324 if (current_texture) 1287 1325 { -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r1543 r1549 42 42 strcpy(filename,fcho->value()); 43 43 geoMeshView->LoadTexture(filename); 44 45 // For each submesh. 46 for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 47 { 48 geoMeshView->changeTexFile(i,filename); 49 } 50 51 // Refresh mesh. 52 geoMeshView->setMesh(mGeoMesh); 44 53 } 45 54 } … … 53 62 54 63 55 inline void GeoMeshViewUI::cb_menuFileLoadTextureSubMesh_i(fltk::Item *item, void *) 56 { 64 inline void GeoMeshViewUI::cb_menuFileLoadTextureSubMesh_i( fltk::Item *item, 65 void *) 66 { 67 fltk::FileChooser *fcho; 68 57 69 static char pattern[] = "*.{jpg|tga|png|bmp}"; 58 70 59 const char * label = item->label(); 60 int isubmesh = label[strlen(label)-1]-48; 61 62 fltk::FileChooser *fcho = new fltk::FileChooser("",pattern,fltk::FileChooser::CREATE,"Open image file"); 71 const char *label = item->label(); 72 int isubmesh = label[strlen(label)-1]-48; 73 74 fcho = new fltk::FileChooser("", 75 pattern, 76 fltk::FileChooser::CREATE, 77 "Open image file"); 63 78 fcho->exec(); 64 char filename[256]=""; 79 80 char filename[256] = ""; 81 65 82 if (fcho->value()) 66 83 { 67 84 strcpy(filename,fcho->value()); 68 geoMeshView->LoadTextureSubMesh(isubmesh,filename); 69 } 85 86 geoMeshView->changeTexFile(isubmesh,filename); 87 88 // Refresh mesh. 89 geoMeshView->setMesh(mGeoMesh); 90 } 91 70 92 } 71 93 … … 957 979 } 958 980 959 VertexBuffer *origSubMeshVB =NULL;960 int orig_numindices =0;961 Index *orig_indices =NULL;981 VertexBuffer *origSubMeshVB = NULL; 982 int orig_numindices = 0; 983 Index *orig_indices = NULL; 962 984 963 985 //--------------------------------------------------------------------------- … … 973 995 mProcessBar->position(0); 974 996 975 origSubMeshVB =NULL;997 origSubMeshVB = NULL; 976 998 977 999 // Initialize error flag. … … 982 1004 { 983 1005 // Choose between aplication state. 984 switch (mApplicationState)1006 switch (mApplicationState) 985 1007 { 986 1008 // Stripify state. … … 1148 1170 // Refresh geometry attributes. 1149 1171 refreshApplicationBar(); 1150 1151 // Set textures.1152 geoMeshView->resetTextures();1153 setTextures();1154 1172 } 1155 1173 … … 1198 1216 { 1199 1217 // Choose between aplication state. 1200 if (mApplicationState==LODSTRIPS_AUTO || mApplicationState==LODTREES_AUTO) 1218 if (mApplicationState == LODSTRIPS_AUTO 1219 || 1220 mApplicationState == LODTREES_AUTO) 1201 1221 { 1202 1222 file_name = fltk::file_chooser("Build LOD","*.mesh",""); … … 1215 1235 1216 1236 // Simplification sequence. 1217 //oMeshSimpSequence = new MeshSimplificationSequence();1218 1219 // Loads a simplification sequence file.1220 //oMeshSimpSequence->Load(Serializer("SimplifSequence.txt",Serializer::READ));1221 1222 // Simplification sequence.1223 1237 oMeshSimpSequence = mMeshSimplifier->GetSimplificationSequence(); 1224 1238 … … 1226 1240 if (oMeshSimpSequence && mGeoMesh) 1227 1241 { 1228 oLodStrip 1229 oMeshSimpSequence,1230 idMeshLeaves,1231 progress_function);1242 oLodStrip = new LodStripsConstructor( mGeoMesh, 1243 oMeshSimpSequence, 1244 idMeshLeaves, 1245 progress_function); 1232 1246 1233 1247 oLodStrip->UpdateMesh(); … … 1248 1262 1249 1263 mesh_saver = new GeoMeshSaver(); 1250 // file_name[strlen(file_name) - 4] = '\0'; 1251 1252 mesh_saver->leaves SubMesh=idMeshLeaves;1253 mesh_saver-> leavesVB=origSubMeshVB;1254 mesh_saver-> numindices=orig_numindices;1255 mesh_saver->indices=orig_indices; 1264 1265 mesh_saver->leavesSubMesh = idMeshLeaves; 1266 mesh_saver->leavesVB = origSubMeshVB; 1267 mesh_saver->numindices = orig_numindices; 1268 mesh_saver->indices = orig_indices; 1269 1256 1270 mesh_saver->save(mGeoMesh,file_name); 1271 1257 1272 delete mesh_saver; 1273 1258 1274 oLodStrip->Save(file_name); 1259 1275 1260 1276 // Delete simplified mesh. 1261 1277 delete mMeshSimplifier; 1262 // Close file.1263 // delete oSerializer;1264 1278 } 1265 1279 else … … 1269 1283 } 1270 1284 1271 // Deletes the siplification sequence object. 1272 //delete oMeshSimpSequence; 1273 1274 if (mApplicationState==LODTREES_AUTO) 1275 { 1276 // Open file chooser dialog. 1277 /* file_name = fltk::file_chooser("Build LOD","*",""); 1278 1279 if (!file_name) 1280 { 1281 break; 1282 }*/ 1283 1284 std::cout << "Creando secuencia de simplificacion de hojas..."; 1285 1285 if (mApplicationState == LODTREES_AUTO) 1286 { 1286 1287 createLeavesSequence(file_name); 1287 1288 std::cout << "OK!" << std::endl;1289 1288 } 1290 1289 } … … 1293 1292 // Refresh data aplication. 1294 1293 refreshApplicationBar(); 1295 1296 // Set textures.1297 geoMeshView->resetTextures();1298 setTextures();1299 1294 } 1300 1295 } … … 2278 2273 // Repaint the window. 2279 2274 mMainWindow->redraw(); 2280 2281 // Set textures.2282 geoMeshView->resetTextures();2283 setTextures();2284 2275 } 2285 2276 } … … 2447 2438 mMB->label(char_value); 2448 2439 2440 // Set textures. 2441 geoMeshView->resetTextures(); 2442 setTextures(); 2443 2449 2444 // Visualize mesh. 2450 2445 geoMeshView->setMesh(mGeoMesh); 2451 2446 2452 // Set textures.2453 geoMeshView->resetTextures();2454 setTextures();2455 2456 2447 // Hide right panel. 2457 2448 hideRightPanel(); … … 2511 2502 material = string(mGeoMesh->mSubMesh[submesh].mMaterialName); 2512 2503 2504 // If exists material. 2513 2505 if (loader->existsMaterial(material)) 2514 { 2506 { 2507 // Gets file name. 2515 2508 filename = loader->getTextureFileName(material); 2516 2509 2517 geoMeshView->LoadTextureSubMesh(submesh, filename.c_str()); 2510 geoMeshView->addTexFile(filename.c_str()); 2511 } 2512 // If not exists material. 2513 else 2514 { 2515 // File name empty. 2516 filename = string(); 2517 2518 geoMeshView->addTexFile(filename.c_str()); 2518 2519 } 2519 2520 }
Note: See TracChangeset
for help on using the changeset viewer.