Changeset 3239
- Timestamp:
- 01/02/09 10:24:19 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
r3238 r3239 4 4 #include "gzstream.h" 5 5 #include <iostream> 6 #include <queue> 6 7 7 8 … … 15 16 #define BVH_VERSION 2.1 16 17 17 const int maxVertices = 20000000; 18 #define TYPE_INTERIOR -2 19 #define TYPE_LEAF -3 20 21 //const int maxVertices = 20000000; 18 22 19 23 … … 246 250 } 247 251 248 /*if (!WriteBvh(bvhOutputFilename))249 { 250 cerr << "could not write file" << endl;252 if (!WriteBvh(bvhOutputFilename)) 253 { 254 cerr << "could not write bvh!" << endl; 251 255 return false; 252 } */256 } 253 257 254 258 return true; … … 578 582 579 583 580 bool VisibilitySolutionConverter::WriteBvh(const string &filename)581 {582 583 return true;584 }585 586 587 584 bool VisibilitySolutionConverter::ReadBvh(FILE *fr) 588 585 { … … 653 650 back = LoadNode(fr, depth + 1); 654 651 655 // front->parent = (BvhNode *)interior; 656 // back->parent = (BvhNode *)interior; 652 front->parent = interior; 653 back->parent = interior; 654 657 655 interior->front = front; 658 656 interior->back = back; 659 657 660 //interior->box = Union(front->box, back->box); 658 //interior->bmin = Minimize(front->bmin, back->bmin); 659 //interior->bmax = Maximize(front->bmax, back->bmax); 661 660 662 661 return (BvhNode *)interior; … … 667 666 //Debug << "Info: Loading leaf (id: " << numberOfNodes << ", depth: " << depth << ")" << endl; 668 667 BvhLeaf *leaf = new BvhLeaf(); 668 669 669 leaf->first = buffer[0]; 670 670 leaf->last = buffer[1]; 671 671 leaf->axis = buffer[2]; 672 leaf->id = buffer[3];672 leaf->id = buffer[3]; 673 673 674 674 leaf->depth = depth; … … 676 676 677 677 mBvhNodes.push_back(leaf); 678 // leaf->id = numberOfNodes;678 679 679 return (BvhNode *)leaf; 680 680 } … … 820 820 return true; 821 821 } 822 823 824 void VisibilitySolutionConverter::WriteNextNode(ogzstream &stream, 825 BvhNode *node) 826 { 827 int nodeType; 828 829 if (!node->IsLeaf()) 830 nodeType = TYPE_LEAF; 831 else 832 nodeType = TYPE_INTERIOR; 833 834 cerr << "error: wrong node type: " << nodeType << endl; 835 836 stream.write(reinterpret_cast<char *>(&nodeType), sizeof(int)); 837 838 SimpleVec bMin, bMax; 839 840 stream.write(reinterpret_cast<char *>(&(node->first)), sizeof(int)); 841 stream.write(reinterpret_cast<char *>(&(node->last)), sizeof(int)); 842 843 stream.write(reinterpret_cast<char *>(&node->bmin), sizeof(SimpleVec)); 844 stream.write(reinterpret_cast<char *>(&node->bmax), sizeof(SimpleVec)); 845 } 846 847 848 bool VisibilitySolutionConverter::WriteBvh(const string &filename) 849 { 850 std::queue<BvhNode *> tQueue; 851 ogzstream stream(filename.c_str()); 852 853 if (!stream.is_open()) return NULL; 854 855 cout << "loading bvh" << endl; 856 857 WriteNextNode(stream, mRoot); 858 859 tQueue.push(mRoot); 860 861 while (!tQueue.empty()) 862 { 863 BvhNode *node = tQueue.front(); 864 tQueue.pop(); 865 866 if (!node->IsLeaf()) 867 { 868 BvhInterior *interior = static_cast<BvhInterior *>(node); 869 870 BvhNode *front = interior->front; 871 BvhNode *back = interior->back; 872 873 WriteNextNode(stream, front); 874 WriteNextNode(stream, back); 875 876 tQueue.push(front); 877 tQueue.push(back); 878 } 879 } 880 881 return true; 882 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h
r3238 r3239 14 14 class ogzstream; 15 15 16 struct BvhInterior; 16 17 17 18 struct BvhNode … … 35 36 int Count() const { return last - first + 1; } 36 37 38 SimpleVec bmin; 39 SimpleVec bmax; 40 41 BvhInterior *parent; 37 42 std::vector<int> mTriangleIds; 38 43 }; … … 71 76 const std::string &bvhOutputFilename); 72 77 73 74 78 75 79 protected: … … 124 128 float scale); 125 129 130 bool WriteBinObj(const std::string &filename, 131 const VertexArray &vertices); 132 126 133 bool ExportBinObj(const std::string &filename, 127 const VertexArray &vertices); 134 const VertexArray &vertices); 135 136 void WriteNextNode(ogzstream &stream, 137 BvhNode *parent); 138 139 128 140 129 141 ////////////////////////////////// -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
r3123 r3239 84 84 tQueue.push(root); 85 85 86 while (!tQueue.empty())86 while (!tQueue.empty()) 87 87 { 88 88 BvhNode *node = tQueue.front();
Note: See TracChangeset
for help on using the changeset viewer.