Changeset 878 for GTP/trunk/Lib
- Timestamp:
- 05/02/06 16:47:50 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Camera.cpp
r863 r878 60 60 cout<<"+"; 61 61 for (x = 0; x < mWidth; x++) { 62 SetupRay(ray, x, mHeight - (y + 1)); 63 if (tree->CastRay(ray)) 62 SetupRay(ray, mWidth - (x + 1), mHeight - (y + 1)); 63 64 bool debug = false; 65 // (y == mHeight/2) && (x== mWidth/3); 66 // MeshDebug = debug; 67 68 if (debug) 69 ray.mFlags = (Ray::STORE_TESTED_OBJECTS | Ray::STORE_KDLEAVES); 70 else 71 ray.mFlags &= ~(Ray::STORE_TESTED_OBJECTS|Ray::STORE_KDLEAVES); 72 73 if (tree->CastRay(ray)) 64 74 if (ray.intersections.size()) { 65 75 sort(ray.intersections.begin(), ray.intersections.end()); … … 79 89 // if (exportRays && ( 1||(x==222) && (y==97))) { 80 90 // if (exportRays && ((x%4==0) && (y%4==0))) { 81 if (exportRays && ray.intersections.empty()) { 91 92 // if (exportRays && ray.intersections.empty()) { 93 if (debug) { 82 94 Ray *nray = new Ray(ray); 83 95 rays.push_back(nray); … … 104 116 if (1) { 105 117 exporter = Exporter::GetExporter(filename + "-rays" + ".x3d"); 106 exporter->SetFilled(); 107 if (sceneGraph) 118 //exporter->SetFilled(); 119 120 exporter->SetWireframe(); 121 122 if (sceneGraph) 108 123 exporter->ExportScene(sceneGraph->mRoot); 109 124 … … 111 126 //exporter->ExportBspTree(*bsptree); 112 127 exporter->ExportRays(rays, 2000); 113 exporter->SetFilled();114 128 int k =0; 115 129 for (int j=0; j < rays.size(); j++) … … 117 131 Ray *ray = rays[j]; 118 132 int i; 119 if (0) 133 exporter->SetWireframe(); 134 135 if (1) 120 136 for (i= 0; i < ray->kdLeaves.size(); i++) 121 137 exporter->ExportBox(tree->GetBox(ray->kdLeaves[i])); 122 if (0) 138 139 exporter->SetFilled(); 140 141 if (1) 123 142 for (i= 0; i < ray->testedObjects.size(); i++) 124 143 exporter->ExportIntersectable(ray->testedObjects[i]); 125 126 144 } 127 145 … … 142 160 ray.Clear(); 143 161 ray.Init(mPosition, target, Ray::LOCAL_RAY); 144 162 ray.mFlags &= ~Ray::CULL_BACKFACES; 145 163 } 146 164 -
GTP/trunk/Lib/Vis/Preprocessing/src/Camera.h
r863 r878 28 28 mWidth = 1400; 29 29 mHeight = 1000; 30 mFovy = 60.0f*(float)M_PI/180.0f;30 mFovy = 90.0f*(float)M_PI/180.0f; 31 31 } 32 32 -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r871 r878 1688 1688 "true"); 1689 1689 1690 RegisterOption("Preprocessor.visibilityFilterWidth", 1691 optFloat, 1692 "preprocessor_visibility_filter_width=", 1693 "0.02"); 1694 1695 1690 1696 1691 1697 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r871 r878 55 55 mViewPoint = mSceneGraph->GetBox().Center(); 56 56 mViewDirection = Vector3(0,0,1); 57 58 mViewPoint = Vector3(991.7, 187.8, -271); 59 mViewDirection = Vector3(0.9, 0, -0.4); 57 60 58 61 // timerId = startTimer(10); -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r863 r878 24 24 KdTree::KdTree() 25 25 { 26 27 26 28 mRoot = new KdLeaf(NULL, 0); 27 29 environment->GetIntValue("KdTree.Termination.maxNodes", mTermMaxNodes); … … 585 587 if (ray.mFlags & Ray::STORE_TESTED_OBJECTS) 586 588 ray.testedObjects.push_back(object); 589 590 static int oi=1; 591 if (MeshDebug) 592 cout<<"Object "<<oi++; 593 587 594 hits += object->CastRay(ray); 595 596 if (MeshDebug) { 597 if (ray.intersections.size()) 598 cout<<"nearest t="<<ray.intersections[0].mT<<endl; 599 else 600 cout<<"nearest t=-INF"<<endl; 601 } 602 588 603 } 589 604 } -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r860 r878 201 201 /** KdTree for indexing scene entities - occluders/occludees/viewcells */ 202 202 class KdTree { 203 203 204 204 protected: 205 205 struct TraversalData -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r871 r878 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: út 2. V 11: 07:4420063 # Generated by qmake (2.00a) (Qt 4.1.2) on: út 2. V 11:18:23 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r873 r878 6 6 namespace GtpVisibilityPreprocessor { 7 7 8 bool MeshDebug = false; 8 9 9 10 int Intersectable::sMailId = 21843194198; … … 158 159 int 159 160 Mesh::CastRayToFace( 160 161 162 163 164 165 161 const int faceIndex, 162 Ray &ray, 163 float &nearestT, 164 int &nearestFace, 165 Intersectable *instance 166 ) 166 167 { 167 168 float t; … … 180 181 case Ray::LINE_SEGMENT: 181 182 if (t <= 1.0f) { 182 183 183 ray.intersections.push_back(Ray::Intersection(t, instance, faceIndex)); 184 hit++; 184 185 } 185 186 break; … … 243 244 244 245 for ( fi = faces.begin(); 245 246 246 fi != faces.end(); 247 fi++) { 247 248 hits += CastRayToFace(*fi, ray, nearestT, nearestFace, instance); 248 249 if (mIsConvex && nearestFace != -1) … … 296 297 297 298 double thresh; 299 298 300 if (ydiff < 0.0f) 299 thresh = -1e 20;301 thresh = -1e-20; 300 302 else 301 thresh = 1e 20;303 thresh = 1e-20; 302 304 303 305 … … 319 321 Plane3 plane = GetFacePlane(faceIndex); 320 322 float dot = DotProd(plane.mNormal, ray.GetDir()); 321 323 324 if (MeshDebug) { 325 cout<<endl<<endl; 326 cout<<"normal="<<plane.mNormal<<endl; 327 cout<<"dot="<<dot<<endl; 328 } 329 330 322 331 // Watch for near-zero denominator 323 332 // ONLY single sided polygons!!!!! … … 332 341 333 342 t = (-plane.mD - DotProd(plane.mNormal, ray.GetLoc())) / dot; 334 343 344 if (MeshDebug) 345 cout<<"t="<<t<<endl; 346 335 347 if (t <= Limits::Small) 336 348 return Ray::INTERSECTION_OUT_OF_LIMITS; … … 346 358 int paxis = plane.mNormal.DrivingAxis(); 347 359 360 348 361 // Project the intersection point onto the coordinate plane 349 362 // specified by which. … … 353 366 int size = (int)face->mVertexIndices.size(); 354 367 368 if (MeshDebug) 369 cout<<"size="<<size<<endl; 370 355 371 mVertices[face->mVertexIndices[size - 1]]. 356 372 ExtractVerts(&u1, &v1, paxis ); … … 362 378 mVertices[face->mVertexIndices[i]].ExtractVerts(&u2, &v2, paxis); 363 379 // line u1, v1, u2, v2 364 if ((v1 - v2)*(u - u1) + (u2 - u1)*(v - v1) > 0) 380 if ((v1 - v2)*(u - u1) + (u2 - u1)*(v - v1) > 0) { 381 if (MeshDebug) 382 cout<<"exit on "<<i<<endl; 365 383 return Ray::NO_INTERSECTION; 384 } 366 385 u1 = u2; 367 386 v1 = v2; … … 381 400 v1 = v2; 382 401 } 402 403 if (MeshDebug) 404 cout<<"count="<<count<<endl; 383 405 384 406 // We hit polygon if number of intersections is odd. -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r870 r878 13 13 14 14 namespace GtpVisibilityPreprocessor { 15 16 extern bool MeshDebug; 15 17 16 18 struct Triangle3; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r871 r878 132 132 environment->GetStringValue("Preprocessor.visibilityFile", buffer); 133 133 mVisibilityFileName = buffer; 134 environment->GetBoolValue("Preprocessor.visibilityFile", mApplyVisibilityFilter ); 135 134 environment->GetBoolValue("Preprocessor.applyVisibilityFilter", mApplyVisibilityFilter ); 135 environment->GetFloatValue("Preprocessor.visibilityFilterWidth", mVisibilityFilterWidth); 136 136 137 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 137 138 Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl; … … 274 275 if (mApplyVisibilityFilter) { 275 276 cout<<"Applying visibility filter..."; 277 cout<<"filyter width = "<<mVisibilityFilterWidth<<endl; 278 276 279 mViewCellsManager->ApplyFilter(mKdTree, 277 0.05f,278 0.05f);280 mVisibilityFilterWidth, 281 mVisibilityFilterWidth); 279 282 cout<<"done."; 280 283 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r871 r878 171 171 172 172 bool mApplyVisibilityFilter; 173 174 float mVisibilityFilterWidth; 173 175 174 176 GlRendererBuffer *GetRenderer() { return renderer;} -
GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorThread.cpp
r871 r878 23 23 { 24 24 25 if (mPreprocessor->mComputeVisibility) {26 mPreprocessor->ComputeVisibility();27 // mPreprocessor->ExportPreprocessedData("scene.vis");28 mPreprocessor->PostProcessVisibility();29 }30 31 25 Camera camera; 32 26 33 27 if (0) { 34 35 // camera.LookInBox(mPreprocessor->mKdTree->GetBox());28 // camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); 29 // camera.LookInBox(mPreprocessor->mKdTree->GetBox()); 36 30 camera.SetPosition(Vector3(3473, 6.778, -1699)); 37 31 camera.SetDirection(Vector3(-0.2432, 0, 0.97)); 32 // camera.SetPosition(Vector3(991.7, 187.8, -271)); 33 // camera.SetDirection(Vector3(0.9, 0, -0.4)); 34 38 35 camera.SnapImage("camera.jpg", mPreprocessor->mKdTree, mPreprocessor->mSceneGraph); 39 } 36 } 37 40 38 if (0) { 41 39 camera.LookInBox(mPreprocessor->mKdTree->GetBox()); … … 50 48 } 51 49 50 if (mPreprocessor->mComputeVisibility) { 51 mPreprocessor->ComputeVisibility(); 52 // mPreprocessor->ExportPreprocessedData("scene.vis"); 53 mPreprocessor->PostProcessVisibility(); 54 } 55 56 52 57 53 58 cerr << "Preprocessor main finished...\n"; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r871 r878 4915 4915 4916 4916 pvs.Merge(nPvs); 4917 4918 4917 } 4919 4918 -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r871 r878 9 9 # filename vienna.x3d 10 10 # filename ../data/vienna/vienna-simple.x3d 11 filename ../data/vienna/vienna-buildings.x3d 11 #filename ../data/vienna/vienna-buildings.x3d 12 filename ../data/vienna/city1500_flat_1.x3d 12 13 #filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-plane.x3d;../data/vienna/vienna-roads.x3d 13 14 # filename ../data/vienna/viewcells-25-sel.x3d … … 39 40 quitOnFinish false 40 41 computeVisibility true 42 applyVisibilityFilter true 43 visibilityFilterWidth 0.01 44 visibilityFile visibility.xml 41 45 } 42 46 … … 160 164 maxCostRatio 1.0 161 165 ct_div_ci 0.5 162 maxNodes 500000 166 maxNodes 100000 167 168 #500000 163 169 } 164 170 … … 170 176 MeshKdTree { 171 177 Termination { 172 minCost 40178 minCost 8 173 179 maxDepth 18 174 180 maxCostRatio 0.9 … … 276 282 # filename ../data/atlanta/viewcells_atlanta3.xml 277 283 filename ../data/vienna/viewcells_vienna.xml 284 # filename ../data/vienna/viewcells_vienna2.xml 285 # filename ../data/vienna/vienna_simple-21-04-avs2-viewCells.xml 278 286 # filename ../data/PowerPlant/power_plant_viewcells_all3.xml 279 287 } -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r871 r878 14 14 #include "SceneGraph.h" 15 15 #include "PreprocessorThread.h" 16 //#include "RenderSampler.h"16 #include "RenderSampler.h" 17 17 18 18 #include <QApplication> … … 135 135 } 136 136 137 138 if (app) 139 return app->exec(); 140 137 141 // clean up 138 142 DEL_PTR(p); 139 143 DEL_PTR(environment); 140 144 141 if (app)142 return app->exec();143 144 145 return 0; 145 146 }
Note: See TracChangeset
for help on using the changeset viewer.