Changeset 321
- Timestamp:
- 10/12/05 18:29:46 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r320 r321 9 9 # filename vienna.x3d 10 10 # filename ../data/vienna/vienna-simple.x3d 11 filename ../data/vienna/vienna-buildings.x3d11 # filename ../data/vienna/vienna-buildings.x3d 12 12 # filename ../data/vienna/viewcells-25-sel.x3d 13 #filename ../data/atlanta/atlanta2.x3d13 filename ../data/atlanta/atlanta2.x3d 14 14 # filename ../data/soda/soda.dat 15 15 # filename ../data/soda/soda5.dat … … 56 56 57 57 Sampling { 58 totalSamples 50000059 samplesPerPass 1058 totalSamples 100 59 samplesPerPass 20 60 60 } 61 61 62 62 ViewCells { 63 63 hierarchyType bspTree 64 height 7.064 height 5.0 65 65 maxViewCells 0 66 66 #hierarchyType kdTree 67 67 #hierarchyType sceneDependent 68 68 # filename ../data/atlanta/atlanta_viewcells_large.x3d 69 filename ../data/vienna/viewcells-25-sel.x3d70 #filename ../data/vienna/viewcells-25.x3d69 # filename ../data/vienna/viewcells-25-sel.x3d 70 filename ../data/vienna/viewcells-25.x3d 71 71 # filename ../data/vienna/viewcells-large-sel.x3d 72 72 } … … 74 74 BspTree { 75 75 # constructionMethod fromRays 76 constructionMethod fromViewCells77 #constructionMethod fromSceneGeometry76 # constructionMethod fromViewCells 77 constructionMethod fromSceneGeometry 78 78 79 # next polygon= 179 # random polygon = 1 80 80 # axis aligned = 2 81 81 # least splits = 4 … … 101 101 #splitPlaneStrategy 72 102 102 103 splitPlaneStrategy 66103 splitPlaneStrategy 72 104 104 105 105 maxCandidates 50 … … 107 107 Termination { 108 108 maxPolysForAxisAligned 100 109 maxPolygons 0110 maxDepth 200109 maxPolygons 30 110 maxDepth 100 111 111 } 112 # if split polys are stored for visualization 113 storeSplitPolys false 114 # x3d visualization of the split planes 115 exportSplits true 112 116 } -
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
r318 r321 1657 1657 bool operator<(const VertexData &b) const 1658 1658 { 1659 return mAngle <b.mAngle;1659 return mAngle > b.mAngle; 1660 1660 } 1661 1661 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r313 r321 1185 1185 "100"); 1186 1186 1187 RegisterOption("BspTree.storeSplitPolys", 1188 optBool, 1189 "-bsp_store_split_polys=", 1190 "false"); 1191 1187 1192 RegisterOption("BspTree.splitPlaneStrategy", 1188 1193 optString, … … 1199 1204 "-view_cells_max_viewcells=", 1200 1205 "0"); 1206 1207 RegisterOption("BspTree.exportSplits", 1208 optBool, 1209 "-bsp_exportSplits", 1210 "false"); 1201 1211 } 1202 1212 -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r319 r321 35 35 Plane3 Polygon3::GetSupportingPlane() const 36 36 { 37 Vector3 v1 = mVertices[0] - mVertices[1];38 Vector3 v2 = mVertices[2] - mVertices[1];39 #ifdef _DEBUG40 Debug << "plane spanned by " << v1 << ", " << v2 << endl;41 #endif42 37 return Plane3(mVertices[0], mVertices[1], mVertices[2]); 43 38 } … … 45 40 Vector3 Polygon3::GetNormal() const 46 41 { 47 return Normalize(CrossProd(mVertices[ 0] - mVertices[1],48 mVertices[ 2] - mVertices[1]));42 return Normalize(CrossProd(mVertices[2] - mVertices[1], 43 mVertices[0] - mVertices[1])); 49 44 } 50 45 … … 130 125 131 126 //Debug << "area2: " << 0.5f * fabs(DotProd(GetNormal(), v)) << endl; 132 133 127 return 0.5f * fabs(DotProd(GetNormal(), v)); 134 128 } … … 170 164 } 171 165 // 3 vertices enough to decide coincident 172 else if (((++ count) >= 3) && !onFrontSide && !onBackSide) 166 else if (((++ count) >= 3) && !onFrontSide && !onBackSide) 167 // && (DotProd(GetSupportingPlane().mNormal, plane.mNormal) > 0)) 168 { 173 169 return COINCIDENT; 170 } 174 171 } 175 172 … … 182 179 return FRONT_SIDE; 183 180 } 184 181 //if (DotProd(GetNormal(), plane.mNormal) < 0) return FRONT_SIDE; 185 182 return COINCIDENT; // plane and polygon are coincident 186 183 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h
r319 r321 77 77 /** Returns the surface normal. 78 78 */ 79 Vector3 GetNormal() const;79 inline Vector3 GetNormal() const; 80 80 81 81 /** Includes polygons to axis aligned box. -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r319 r321 10 10 mKdTree(NULL), 11 11 mBspTree(NULL), 12 mRootViewCell(NULL),13 12 mViewCellsType(BSP_VIEW_CELLS) 14 13 { … … 21 20 DEL_PTR(mBspTree); 22 21 DEL_PTR(mKdTree); 23 DEL_PTR(mRootViewCell);24 22 } 25 23 … … 150 148 { 151 149 DEL_PTR(mBspTree); 152 DEL_PTR(mRootViewCell); 153 mRootViewCell = new ViewCell(NULL); 154 mBspTree = new BspTree(mRootViewCell); 150 151 mBspTree = new BspTree(&mUnbounded); 155 152 156 153 ObjectContainer objects; -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r310 r321 8 8 #include "KdTree.h" 9 9 #include "ViewCellBsp.h" 10 #include "ViewCell.h" 10 11 //#include "SceneGraph.h" 11 12 … … 112 113 BspTree *mBspTree; 113 114 114 /// the root view cell of the bsp tree115 ViewCell *mRootViewCell;115 /// the view cell corresponding to unbounded space 116 ViewCell mUnbounded; 116 117 117 118 /// view cell hierarchy types -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r320 r321 66 66 int j; 67 67 68 // add object to view cell68 // object can be seen from the view cell => add to view cell pvs 69 69 for (j=0; j < ray.viewCells.size(); ++ j) 70 { 71 ViewCell *vc = ray.viewCells[j]; 72 73 contributingSamples += vc->GetPvs().AddSample(obj); 70 { // if ray not in unbounded space 71 if (ray.viewCells[j] != &mUnbounded) 72 contributingSamples += ray.viewCells[j]->GetPvs().AddSample(obj); 74 73 } 75 74 75 // rays passing through this viewcell 76 76 if (mPass > 1) 77 77 for (j=1; j < ((int)ray.viewCells.size() - 1); ++ j) 78 78 { 79 ray.viewCells[j]->AddPassingRay(ray, contributingSamples ? 1 : 0); 79 if (ray.viewCells[j] != &mUnbounded) 80 ray.viewCells[j]->AddPassingRay(ray, contributingSamples ? 1 : 0); 80 81 } 81 82 … … 103 104 int sampleContributions = 0; 104 105 106 // cast ray to KD tree to find intersection with other objects 107 mKdTree->CastRay(ray); 108 105 109 if (mViewCellsType == BSP_VIEW_CELLS) 106 110 { 107 // cast ray to KD tree to find intersection with other objects108 mKdTree->CastRay(ray);109 110 111 // cast ray to BSP tree to get intersection with view cells 111 112 mBspTree->CastRay(ray); … … 121 122 else 122 123 { 123 mKdTree->CastRay(ray);124 125 124 if (ray.leaves.size()) { 126 125 sampleContributions += AddNodeSamples(object, ray); … … 233 232 int vcPvsOut = Min((int)mViewCells.size(), 5); 234 233 234 ViewCellContainer pvsViewCells; 235 236 // some random view cells for output 237 for (int j = 0; j < vcPvsOut; ++ j) 238 { 239 int idx = Random((int)mViewCells.size()); 240 Debug << "output view cell no. " << idx << endl; 241 pvsViewCells.push_back(mViewCells[Random((int)mViewCells.size())]); 242 } 243 235 244 vector<Ray> rays[10]; 236 245 vector<Ray> vcRays[5]; … … 245 254 int index = 0; 246 255 256 Debug << "starting new loop " << totalSamples << endl; 257 247 258 // construct Bsp tree if not 248 259 if ((mViewCellsType == Preprocessor::BSP_VIEW_CELLS) && … … 251 262 BuildBspTree(); 252 263 } 253 264 Debug << "here" << totalSamples << endl; 254 265 for (i = 0; i < objects.size(); i++) { 255 266 KdNode *nodeToSample = NULL; … … 351 362 // check whether we can add this to the rays 352 363 for (int k = 0; k < ray.viewCells.size(); ++ k) 353 for (int j = 0; j < vcPvsOut; ++ j)354 if ( mViewCells[j] == ray.viewCells[k])364 for (int j = 0; j < (int)pvsViewCells.size(); ++ j) 365 if (pvsViewCells[j] == ray.viewCells[k]) 355 366 { 356 367 vcRays[j].push_back(ray); … … 465 476 if (mViewCellsType == BSP_VIEW_CELLS) 466 477 { 467 for (int j = 0; j < vcPvsOut; ++ j)478 for (int j = 0; j < pvsViewCells.size(); ++ j) 468 479 { 469 ViewCell *vc = mViewCells[j];480 ViewCell *vc = pvsViewCells[j]; 470 481 471 482 Intersectable::NewMail(); … … 491 502 exporter->SetForcedMaterial(m); 492 503 493 exporter->ExportBspTree(*mBspTree); 504 if (1) 505 { 506 exporter->ExportViewCells(mViewCells); 507 } 508 509 // export rays piercing this view cell 494 510 exporter->ExportRays(vcRays[j], 1000, RgbColor(0, 1, 0)); 495 511 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r319 r321 524 524 /// Strategies for choosing next split plane. 525 525 enum {NO_STRATEGY = 0, 526 NEXT_POLYGON = 1,526 RANDOM_POLYGON = 1, 527 527 AXIS_ALIGNED = 2, 528 528 LEAST_SPLITS = 4, … … 536 536 /// box around the whole view domain 537 537 AxisAlignedBox3 mBox; 538 539 /// if polygons should be stored in the tree540 bool mStoreSplitPolys;541 538 542 539 /// view cell corresponding to unbounded space … … 571 568 static float sLargestPolyAreaFactor; 572 569 static float sBlockedRaysFactor; 570 571 /// if polygons should be stored in the tree 572 static bool sStoreSplitPolys; 573 573 574 574 private: -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r319 r321 10 10 #include "X3dExporter.h" // delete later 11 11 #include "ViewCell.h" 12 #include "SceneGraph.h" 12 13 13 14 #define USE_EXE_PATH false … … 59 60 p->BspTreeStatistics(Debug); 60 61 p->Export("vc_bsptree2.x3d", false, false, true); 62 63 bool exportSplits = false; 64 environment->GetBoolValue("BspTree.exportSplits", exportSplits); 65 61 66 // export the bsp splits 62 Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d"); 67 if (exportSplits) 68 { 69 Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d"); 63 70 64 if (exporter)65 {66 67 m.mDiffuseColor = RgbColor(1, 0, 0);68 exporter->SetForcedMaterial(m);69 exporter->SetWireframe();//exporter->SetFilled();70 exporter->ExportBspSplits(*p->mBspTree);71 if (exporter) 72 { 73 Material m; 74 m.mDiffuseColor = RgbColor(1, 0, 0); 75 exporter->SetForcedMaterial(m); 76 exporter->SetWireframe(); 77 exporter->ExportBspSplits(*p->mBspTree); 71 78 72 //m.mDiffuseColor = RgbColor(0, 1, 0); 73 //exporter->SetForcedMaterial(m); 74 exporter->SetFilled(); 79 // take forced material because does not load for big scenes otherwise 80 m.mDiffuseColor = RgbColor(0, 1, 0); 81 exporter->SetForcedMaterial(m); 82 exporter->SetFilled(); 75 83 76 exporter->ResetForcedMaterial(); 77 exporter->ExportViewCells(p->mViewCells); 84 exporter->ResetForcedMaterial(); 78 85 79 delete exporter; 86 if (1) 87 { 88 ObjectContainer objects; 89 p->mSceneGraph->CollectObjects(&objects); 90 Material m;//= RandomMaterial(); 91 m.mDiffuseColor = RgbColor(0, 0, 1); 92 exporter->SetForcedMaterial(m); 93 94 for (int j = 0; j < objects.size(); ++ j) 95 exporter->ExportIntersectable(objects[j]); 96 97 delete exporter; 98 } 99 } 80 100 } 81 101 #if 0
Note: See TracChangeset
for help on using the changeset viewer.