- Timestamp:
- 01/03/09 17:32:10 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.cpp
r3243 r3244 24 24 while (!node->IsLeaf()) 25 25 { 26 //cout << "pt: " << point[node->mAxis] << " " << node->mPosition << endl; 26 27 if (point[node->mAxis] < node->mPosition) 27 28 node = node->mBack; … … 29 30 node = node->mFront; 30 31 } 32 33 //cout << "vc: " << node->mViewCell->GetBox() << " pvs " << node->mViewCell->mPvs.Size() << endl; 31 34 32 35 return node->mViewCell; … … 36 39 bool ViewCellsTree::LoadFromFile(const std::string &filename) 37 40 { 38 cout << " Info:Loading view cells from file '" + filename + "'";41 cout << "Loading view cells from file '" + filename + "'"; 39 42 40 43 FILE *fr = fopen(filename.c_str(), "rb"); … … 48 51 bool result = _LoadFromFile(fr); 49 52 50 cout << " Info: done. " << endl;53 cout << "finished loading view cells. " << endl; 51 54 fclose(fr); 52 55 … … 58 61 { 59 62 int buffer[256]; 60 fread(buffer, sizeof(int), 3, fr);63 fread(buffer, sizeof(int), 2, fr); 61 64 62 65 if (buffer[0] != MAGIC) … … 75 78 fread(&mBox, sizeof(AxisAlignedBox3), 1, fr); 76 79 80 Vector3 v1(mBox.Min().x, -mBox.Min().z, mBox.Min().y); 81 Vector3 v2(mBox.Max().x, -mBox.Max().z, mBox.Max().y); 82 83 Vector3 newMin = v1; 84 Vector3 newMax = v2; 85 86 Minimize(newMin, v2); 87 Maximize(newMax, v1); 88 89 mBox.SetMin(newMin); 90 mBox.SetMax(newMax); 91 77 92 stack<ViewCellsTreeNode **> nodeStack; 93 nodeStack.push(&mRoot); 78 94 79 nodeStack.push(&mRoot); 95 cout << "view cells bounds " << mBox << endl; 96 97 int numViewCells = 0; 80 98 81 99 while (!nodeStack.empty()) … … 85 103 node = new ViewCellsTreeNode(); 86 104 87 fread(&node->mAxis, sizeof(int), 1, fr); 105 ++ numViewCells; 106 107 int axis; 108 fread(&axis, sizeof(int), 1, fr); 109 110 // exchange y and z axis like we have to do for the scene 111 if (axis == 2) axis = 1; 112 else if (axis == 1) axis = 2; 113 114 node->mAxis = axis; 115 116 if (node->mAxis > 2 || node->mAxis < -1) cout << "a " << node->mAxis << " "; 88 117 89 118 if (!node->IsLeaf()) 90 119 { 91 fread(&node->mPosition, sizeof(float), 1, fr); 120 float pos; 121 fread(&pos, sizeof(float), 1, fr); 122 123 if (axis == 1) pos = -pos; 124 node->mPosition = pos; 125 92 126 nodeStack.push(&node->mFront); 93 127 nodeStack.push(&node->mBack); … … 95 129 } 96 130 131 cout << "loaded " << numViewCells << " view cells" << endl; 97 132 return true; 98 133 }
Note: See TracChangeset
for help on using the changeset viewer.