Changeset 3236
- Timestamp:
- 12/26/08 03:40:45 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
r3235 r3236 363 363 str.write(reinterpret_cast<char *>(geom->mNormals), sizeof(SimpleVec) * vertexCount); 364 364 365 int texCoordCount = geom->mTexcoordCount;365 int texCoordCount = 0;//geom->mTexcoordCount; 366 366 str.write(reinterpret_cast<char *>(&texCoordCount), sizeof(int)); 367 367 … … 374 374 //-- texture 375 375 376 #ifdef USE_TEXTURE377 int texId = 0;378 #else379 376 int texId = -1; 380 #endif381 382 377 str.write(reinterpret_cast<char *>(&texId), sizeof(int)); 383 378 384 379 bool alphaTestEnabled = false; 385 //bool cullFaceEnabled = false;386 380 bool cullFaceEnabled = true; 387 381 … … 391 385 // material 392 386 bool hasMaterial = true; 393 //bool hasMaterial = false;387 394 388 str.write(reinterpret_cast<char *>(&hasMaterial), sizeof(bool)); 395 389 … … 425 419 426 420 427 /////////428 //-- write textures429 430 #ifdef USE_TEXTURE431 int textureCount = 1;432 #else433 421 int textureCount = 0; 434 #endif435 422 ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int)); 436 437 if (textureCount > 0)438 {439 // hack440 const string texName("wood.jpg");441 442 int texnameSize = (int)texName.length() + 1;443 ofile.write(reinterpret_cast<char *>(&texnameSize), sizeof(int));444 445 ofile.write(texName.c_str(), sizeof(char) * texnameSize);446 447 int boundS = 1, boundT = 1;448 449 ofile.write(reinterpret_cast<char *>(&boundS), sizeof(int));450 ofile.write(reinterpret_cast<char *>(&boundT), sizeof(int));451 }452 423 453 424 … … 455 426 //-- write shapes 456 427 457 ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 428 int numShapes = (int)mGeometry.size(); 429 ofile.write(reinterpret_cast<char *>(&numShapes), sizeof(int)); 458 430 459 431 vector<Geometry *>::const_iterator it, it_end = mGeometry.end(); … … 465 437 466 438 467 int entityCount = 1;439 int entityCount = numShapes; 468 440 ofile.write(reinterpret_cast<char *>(&entityCount), sizeof(int)); 469 441 470 442 471 443 ////////// 472 //-- write single scene entity 473 474 // no transformation 475 bool hasTrafo = false; 476 ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 477 478 // a dummy lod 479 int numLODs = 1; 480 ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int)); 481 482 float dist = 0; 483 ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 484 485 ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 444 //-- write single scene entity for each shape 486 445 487 446 // all shapes belong to this scene entity 488 for (int i = 0; i < mNumShapes; ++ i) 489 { 447 for (int i = 0; i < numShapes; ++ i) 448 { 449 // no transformation 450 bool hasTrafo = false; 451 ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 452 453 // a dummy lod 454 int numLODs = 1; 455 ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int)); 456 457 float dist = 0; 458 ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 459 460 int shapesPerEnt = 1; 461 ofile.write(reinterpret_cast<char *>(&shapesPerEnt), sizeof(int)); 462 490 463 int shapeId = i; 491 464 ofile.write(reinterpret_cast<char *>(&shapeId), sizeof(int)); … … 501 474 { 502 475 cout << "vtx: " << vertices.size() << endl; 503 /* BvhNode n; 504 505 mGlobalTriangleIds.clear(); 506 for (size_t i = 0; i < vertices.size() / 3; ++ i) 507 { 508 mGlobalTriangleIds.push_back((int)i); 509 } 510 511 for (size_t i = 0; i < vertices.size() / 3; ++ i) 512 n.mTriangleIds.push_back((int)i); 513 514 mBvhNodes.push_back(n); 515 */ 476 516 477 for (size_t i = 0; i < mBvhNodes.size(); ++ i) 517 478 { … … 540 501 } 541 502 542 LoadShape(_vertices, _normals, _texCoords); 503 if (!_vertices.empty()) 504 { 505 ++ mNumShapes; 506 LoadShape(_vertices, _normals, _texCoords); 507 } 543 508 } 544 509 } … … 547 512 bool VisibilitySolutionConverter::WriteBvh(const string &filename) 548 513 { 549 ogzstream ofile(filename.c_str()); 550 551 if (!ofile.is_open()) 552 return false; 553 554 555 ///////// 556 //-- write textures 557 558 #ifdef USE_TEXTURE 559 int textureCount = 1; 560 #else 561 int textureCount = 0; 562 #endif 563 ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int)); 564 565 if (textureCount > 0) 566 { 567 // hack 568 const string texName("wood.jpg"); 569 570 int texnameSize = (int)texName.length() + 1; 571 ofile.write(reinterpret_cast<char *>(&texnameSize), sizeof(int)); 572 573 ofile.write(texName.c_str(), sizeof(char) * texnameSize); 574 575 int boundS = 1, boundT = 1; 576 577 ofile.write(reinterpret_cast<char *>(&boundS), sizeof(int)); 578 ofile.write(reinterpret_cast<char *>(&boundT), sizeof(int)); 579 } 580 581 582 /////////// 583 //-- write shapes 584 585 ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 586 587 vector<Geometry *>::const_iterator it, it_end = mGeometry.end(); 588 589 for (it = mGeometry.begin(); it != it_end; ++ it) 590 { 591 WriteGeometry(ofile, *it); 592 } 593 594 595 int entityCount = 1; 596 ofile.write(reinterpret_cast<char *>(&entityCount), sizeof(int)); 597 598 599 ////////// 600 //-- write single scene entity 601 602 // no transformation 603 bool hasTrafo = false; 604 ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 605 606 // a dummy lod 607 int numLODs = 1; 608 ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int)); 609 610 float dist = 0; 611 ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 612 613 ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 614 615 // all shapes belong to this scene entity 616 for (int i = 0; i < mNumShapes; ++ i) 617 { 618 int shapeId = i; 619 ofile.write(reinterpret_cast<char *>(&shapeId), sizeof(int)); 620 } 621 514 622 515 return true; 623 516 } … … 648 541 int id; 649 542 fread(&id, sizeof(int), 1, fr); 650 mGlobalTriangleIds [i] = id;543 mGlobalTriangleIds.push_back(id); 651 544 //triangles[i] = scene->triangles[id]; 652 545 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3235 r3236 267 267 mVboId = -1; 268 268 // bound the maximal depth of the dynamic branch 269 mMaxDepthForDynamicBranch = 1 0;269 mMaxDepthForDynamicBranch = 1; 270 270 } 271 271 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r3226 r3236 109 109 int shapeId; 110 110 str.read(reinterpret_cast<char *>(&shapeId), sizeof(int)); 111 cout<<"x"; 111 112 112 113 Geometry *geom = mGeometryTable[shapeId]; 114 cout<<"y"; 115 113 116 Material *mat = mMaterialTable[shapeId]; 114 117 cout<<"z"; 115 118 // create shape 116 119 Shape *shape = new Shape(geom, mat); 120 cout<<"w"; 121 117 122 mShapes.push_back(shape); 118 123 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
r3114 r3236 15 15 mGeometry(geometry), 16 16 mMaterial(mat) 17 { 17 { std::cout<<"i"; 18 18 mCenter = GetBoundingBox().Center(); 19 std::cout<<"R"; 19 20 } 20 21 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3235 r3236 578 578 579 579 580 //LoadModel("vienna_full_hp.dem", dynamicObjects);581 //dynamicObjects.back()->GetTransform()->SetMatrix(transl);580 LoadModel("vienna_full_hp.dem", dynamicObjects); 581 dynamicObjects.back()->GetTransform()->SetMatrix(transl); 582 582 583 583
Note: See TracChangeset
for help on using the changeset viewer.