Changeset 3242 for GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
- Timestamp:
- 01/02/09 17:29:48 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
r3241 r3242 246 246 247 247 // update bvh bounding boxes with loaded geometry 248 UpdateNodeBox(mRoot); 248 UpdateBvh(mRoot); 249 250 cout << "bvh: " << mRoot->first << " " << mRoot->last << " bb: " << mRoot->box << endl; 249 251 250 252 cout << "writing scene" << endl; … … 331 333 default: 332 334 sscanf(str + 1, "%f %f %f", &x, &y, &z); 333 //const float scale = 5e-3f;334 const float scale = 0.1f;335 const float scale = 1.0f; 336 //const float scale = 0.1f; 335 337 tempVertices.push_back(CHCDemoEngine::Vector3(x * scale, y * scale, z * scale)); 336 338 //cout <<"v " << x << " " << y << " "<< z << " "; … … 395 397 396 398 sscanf(str + 1, "%f %f %f", &x, &y, &z); 397 const float scale = 0.1f;399 const float scale = 1.0f; 398 400 vertices.push_back(CHCDemoEngine::Vector3(x * scale, y * scale, z * scale)); 399 401 break; … … 558 560 vector<TexCoord> _texCoords; 559 561 562 CHCDemoEngine::AxisAlignedBox3 testBox; 563 testBox.Initialize(); 564 565 for (int i = 0; i < vertices.size(); ++ i) 566 { 567 testBox.Include(vertices[i]); 568 } 569 570 cout << "testbox: " << testBox << endl; 571 560 572 mGeometry.reserve(mBvhLeaves.size()); 561 573 … … 580 592 LoadShape(_vertices, _normals, _texCoords); 581 593 582 node->geometry = mGeometry.back(); 594 // we store geometry in our bvh => change first and last pointer 595 // fromt triangles to geometry 596 node->first = (int)mGeometry.size() - 1; 597 node->last = (int)mGeometry.size() - 1; 583 598 584 599 _vertices.clear(); … … 639 654 leaf->box.Initialize(); 640 655 641 Geometry *geom = leaf->geometry;656 Geometry *geom = mGeometry[leaf->first]; 642 657 643 658 for (size_t i = 0; i < geom->mVertexCount; ++ i) … … 842 857 int nodeType; 843 858 844 if ( !node->IsLeaf())859 if (node->IsLeaf()) 845 860 nodeType = TYPE_LEAF; 846 861 else … … 856 871 857 872 stream.write(reinterpret_cast<char *>(&bMin), sizeof(CHCDemoEngine::Vector3)); 858 stream.write(reinterpret_cast<char *>(&bM in), sizeof(CHCDemoEngine::Vector3));859 } 860 861 862 void VisibilitySolutionConverter::Update NodeBox(BvhNode *node)873 stream.write(reinterpret_cast<char *>(&bMax), sizeof(CHCDemoEngine::Vector3)); 874 } 875 876 877 void VisibilitySolutionConverter::UpdateBvh(BvhNode *node) 863 878 { 864 879 if (!node->IsLeaf()) 865 880 { 866 881 BvhInterior *interior = (BvhInterior *)node; 882 883 UpdateBvh(interior->front); 884 UpdateBvh(interior->back); 885 886 interior->first = min(interior->front->first, interior->back->first); 887 interior->last = max(interior->front->last, interior->back->last); 888 867 889 node->box = Union(interior->front->box, interior->back->box); 868 869 UpdateNodeBox(interior->front);870 UpdateNodeBox(interior->back);871 890 } 872 891 else 873 892 { 874 893 UpdateLeafBox((BvhLeaf *)node); 894 //cout << "bb: " << node->box << endl; 875 895 } 876 896 } … … 883 903 884 904 if (!stream.is_open()) return NULL; 885 886 cout << "loading bvh" << endl;887 905 888 906 WriteNextNode(stream, mRoot);
Note: See TracChangeset
for help on using the changeset viewer.