Changeset 878


Ignore:
Timestamp:
05/02/06 16:47:50 (18 years ago)
Author:
bittner
Message:

mesh inntersection bug fixed

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Camera.cpp

    r863 r878  
    6060    cout<<"+"; 
    6161    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)) 
    6474                if (ray.intersections.size()) { 
    6575                  sort(ray.intersections.begin(), ray.intersections.end()); 
     
    7989          //      if (exportRays && ( 1||(x==222) && (y==97))) { 
    8090          //      if (exportRays && ((x%4==0) && (y%4==0))) { 
    81           if (exportRays && ray.intersections.empty()) { 
     91 
     92          //      if (exportRays && ray.intersections.empty()) { 
     93          if (debug) { 
    8294                Ray *nray = new Ray(ray); 
    8395                rays.push_back(nray); 
     
    104116  if (1) { 
    105117    exporter = Exporter::GetExporter(filename + "-rays" + ".x3d"); 
    106     exporter->SetFilled(); 
    107         if (sceneGraph) 
     118    //exporter->SetFilled(); 
     119 
     120        exporter->SetWireframe(); 
     121 
     122        if (sceneGraph)  
    108123          exporter->ExportScene(sceneGraph->mRoot); 
    109124         
     
    111126        //exporter->ExportBspTree(*bsptree); 
    112127    exporter->ExportRays(rays, 2000); 
    113     exporter->SetFilled(); 
    114128    int k =0; 
    115129    for (int j=0; j < rays.size(); j++) 
     
    117131                Ray *ray = rays[j]; 
    118132                int i; 
    119                 if (0) 
     133                exporter->SetWireframe(); 
     134 
     135                if (1) 
    120136                  for (i= 0; i < ray->kdLeaves.size(); i++) 
    121137                        exporter->ExportBox(tree->GetBox(ray->kdLeaves[i])); 
    122                 if (0) 
     138 
     139                exporter->SetFilled(); 
     140                 
     141                if (1) 
    123142                  for (i= 0; i < ray->testedObjects.size(); i++) 
    124143                        exporter->ExportIntersectable(ray->testedObjects[i]); 
    125                  
    126144      } 
    127145         
     
    142160  ray.Clear(); 
    143161  ray.Init(mPosition, target, Ray::LOCAL_RAY); 
    144    
     162  ray.mFlags &= ~Ray::CULL_BACKFACES; 
    145163} 
    146164 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Camera.h

    r863 r878  
    2828    mWidth = 1400; 
    2929    mHeight = 1000; 
    30     mFovy = 60.0f*(float)M_PI/180.0f; 
     30    mFovy = 90.0f*(float)M_PI/180.0f; 
    3131  } 
    3232   
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r871 r878  
    16881688                                   "true"); 
    16891689 
     1690        RegisterOption("Preprocessor.visibilityFilterWidth", 
     1691                                   optFloat, 
     1692                                   "preprocessor_visibility_filter_width=", 
     1693                                   "0.02"); 
     1694 
     1695         
    16901696 
    16911697 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r871 r878  
    5555  mViewPoint = mSceneGraph->GetBox().Center(); 
    5656  mViewDirection = Vector3(0,0,1); 
     57 
     58  mViewPoint = Vector3(991.7, 187.8, -271); 
     59  mViewDirection = Vector3(0.9, 0, -0.4); 
    5760 
    5861  //  timerId = startTimer(10); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r863 r878  
    2424KdTree::KdTree() 
    2525{ 
     26 
     27   
    2628  mRoot = new KdLeaf(NULL, 0); 
    2729  environment->GetIntValue("KdTree.Termination.maxNodes", mTermMaxNodes); 
     
    585587                  if (ray.mFlags & Ray::STORE_TESTED_OBJECTS) 
    586588                        ray.testedObjects.push_back(object); 
     589 
     590                  static int oi=1; 
     591                  if (MeshDebug)  
     592                        cout<<"Object "<<oi++; 
     593                   
    587594                  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                   
    588603                } 
    589604          } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r860 r878  
    201201/** KdTree for indexing scene entities - occluders/occludees/viewcells */ 
    202202class KdTree { 
    203  
     203   
    204204protected: 
    205205  struct TraversalData 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r871 r878  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: út 2. V 11:07:44 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: út 2. V 11:18:23 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r873 r878  
    66namespace GtpVisibilityPreprocessor { 
    77 
     8bool MeshDebug = false; 
    89 
    910int Intersectable::sMailId = 21843194198; 
     
    158159int 
    159160Mesh::CastRayToFace( 
    160                                                                                 const int faceIndex, 
    161                                                                                 Ray &ray, 
    162                                                                                 float &nearestT, 
    163                                                                                 int &nearestFace, 
    164                                                                                 Intersectable *instance 
    165                                                                                 ) 
     161                                        const int faceIndex, 
     162                                        Ray &ray, 
     163                                        float &nearestT, 
     164                                        int &nearestFace, 
     165                                        Intersectable *instance 
     166                                        ) 
    166167{ 
    167168  float t; 
     
    180181    case Ray::LINE_SEGMENT: 
    181182      if (t <= 1.0f) { 
    182                                 ray.intersections.push_back(Ray::Intersection(t, instance, faceIndex)); 
    183                                 hit++; 
     183                ray.intersections.push_back(Ray::Intersection(t, instance, faceIndex)); 
     184                hit++; 
    184185      } 
    185186      break; 
     
    243244 
    244245  for ( fi = faces.begin(); 
    245                                 fi != faces.end(); 
    246                                 fi++) { 
     246                fi != faces.end(); 
     247                fi++) { 
    247248    hits += CastRayToFace(*fi, ray, nearestT, nearestFace, instance); 
    248249    if (mIsConvex && nearestFace != -1) 
     
    296297 
    297298  double thresh; 
     299 
    298300  if (ydiff < 0.0f) 
    299         thresh = -1e20; 
     301        thresh = -1e-20; 
    300302  else 
    301         thresh = 1e20; 
     303        thresh = 1e-20; 
    302304 
    303305   
     
    319321  Plane3 plane = GetFacePlane(faceIndex); 
    320322  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         
    322331  // Watch for near-zero denominator 
    323332  // ONLY single sided polygons!!!!! 
     
    332341   
    333342  t = (-plane.mD - DotProd(plane.mNormal, ray.GetLoc())) / dot; 
    334    
     343 
     344  if (MeshDebug) 
     345        cout<<"t="<<t<<endl; 
     346 
    335347  if (t <= Limits::Small) 
    336348    return Ray::INTERSECTION_OUT_OF_LIMITS; 
     
    346358  int paxis = plane.mNormal.DrivingAxis(); 
    347359 
     360   
    348361  // Project the intersection point onto the coordinate plane 
    349362  // specified by which. 
     
    353366  int size = (int)face->mVertexIndices.size(); 
    354367 
     368  if (MeshDebug) 
     369        cout<<"size="<<size<<endl; 
     370   
    355371  mVertices[face->mVertexIndices[size - 1]]. 
    356372    ExtractVerts(&u1, &v1, paxis ); 
     
    362378      mVertices[face->mVertexIndices[i]].ExtractVerts(&u2, &v2, paxis); 
    363379      // 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; 
    365383                return Ray::NO_INTERSECTION; 
     384          } 
    366385      u1 = u2; 
    367386      v1 = v2; 
     
    381400    v1 = v2; 
    382401  } 
     402 
     403  if (MeshDebug) 
     404        cout<<"count="<<count<<endl; 
    383405 
    384406  // We hit polygon if number of intersections is odd. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h

    r870 r878  
    1313 
    1414namespace GtpVisibilityPreprocessor { 
     15 
     16extern bool MeshDebug; 
    1517 
    1618struct Triangle3; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r871 r878  
    132132        environment->GetStringValue("Preprocessor.visibilityFile",  buffer); 
    133133        mVisibilityFileName = buffer; 
    134         environment->GetBoolValue("Preprocessor.visibilityFile", mApplyVisibilityFilter ); 
    135          
     134        environment->GetBoolValue("Preprocessor.applyVisibilityFilter", mApplyVisibilityFilter ); 
     135        environment->GetFloatValue("Preprocessor.visibilityFilterWidth", mVisibilityFilterWidth); 
     136 
    136137        Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 
    137138        Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl; 
     
    274275  if (mApplyVisibilityFilter) { 
    275276        cout<<"Applying visibility filter..."; 
     277        cout<<"filyter width = "<<mVisibilityFilterWidth<<endl; 
     278 
    276279        mViewCellsManager->ApplyFilter(mKdTree, 
    277                                                                    0.05f, 
    278                                                                    0.05f); 
     280                                                                   mVisibilityFilterWidth, 
     281                                                                   mVisibilityFilterWidth); 
    279282        cout<<"done."; 
    280283  } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r871 r878  
    171171   
    172172  bool mApplyVisibilityFilter; 
     173 
     174  float mVisibilityFilterWidth; 
    173175   
    174176  GlRendererBuffer *GetRenderer() { return renderer;} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorThread.cpp

    r871 r878  
    2323{ 
    2424   
    25   if (mPreprocessor->mComputeVisibility) { 
    26     mPreprocessor->ComputeVisibility(); 
    27         //      mPreprocessor->ExportPreprocessedData("scene.vis"); 
    28         mPreprocessor->PostProcessVisibility(); 
    29   } 
    30    
    3125  Camera camera; 
    3226 
    3327  if (0) { 
    34     // camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); 
    35         //      camera.LookInBox(mPreprocessor->mKdTree->GetBox()); 
     28        // camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); 
     29         //     camera.LookInBox(mPreprocessor->mKdTree->GetBox()); 
    3630        camera.SetPosition(Vector3(3473, 6.778, -1699)); 
    3731        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 
    3835    camera.SnapImage("camera.jpg", mPreprocessor->mKdTree, mPreprocessor->mSceneGraph); 
    39   } 
     36  }  
     37 
    4038  if (0) { 
    4139    camera.LookInBox(mPreprocessor->mKdTree->GetBox()); 
     
    5048  } 
    5149 
     50  if (mPreprocessor->mComputeVisibility) { 
     51    mPreprocessor->ComputeVisibility(); 
     52        //      mPreprocessor->ExportPreprocessedData("scene.vis"); 
     53        mPreprocessor->PostProcessVisibility(); 
     54  } 
     55   
     56 
    5257 
    5358  cerr << "Preprocessor main finished...\n"; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r871 r878  
    49154915 
    49164916  pvs.Merge(nPvs); 
    4917  
    49184917} 
    49194918 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r871 r878  
    99#       filename vienna.x3d 
    1010# filename ../data/vienna/vienna-simple.x3d 
    11 filename ../data/vienna/vienna-buildings.x3d 
     11#filename ../data/vienna/vienna-buildings.x3d 
     12filename ../data/vienna/city1500_flat_1.x3d 
    1213#filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-plane.x3d;../data/vienna/vienna-roads.x3d 
    1314# filename ../data/vienna/viewcells-25-sel.x3d 
     
    3940        quitOnFinish false 
    4041        computeVisibility true 
     42        applyVisibilityFilter   true 
     43        visibilityFilterWidth   0.01 
     44        visibilityFile visibility.xml 
    4145} 
    4246 
     
    160164                maxCostRatio 1.0 
    161165                ct_div_ci 0.5 
    162                 maxNodes 500000  
     166                maxNodes 100000 
     167 
     168#500000  
    163169        } 
    164170 
     
    170176MeshKdTree { 
    171177        Termination { 
    172                 minCost 40 
     178                minCost 8 
    173179                maxDepth 18 
    174180                maxCostRatio 0.9 
     
    276282#       filename ../data/atlanta/viewcells_atlanta3.xml 
    277283        filename ../data/vienna/viewcells_vienna.xml 
     284#       filename ../data/vienna/viewcells_vienna2.xml 
     285#       filename ../data/vienna/vienna_simple-21-04-avs2-viewCells.xml 
    278286#       filename ../data/PowerPlant/power_plant_viewcells_all3.xml 
    279287} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r871 r878  
    1414#include "SceneGraph.h" 
    1515#include "PreprocessorThread.h" 
    16 //#include "RenderSampler.h" 
     16#include "RenderSampler.h" 
    1717 
    1818#include <QApplication> 
     
    135135  } 
    136136   
     137 
     138  if (app) 
     139        return app->exec(); 
     140 
    137141  // clean up 
    138142  DEL_PTR(p); 
    139143  DEL_PTR(environment); 
    140144 
    141   if (app) 
    142         return app->exec(); 
    143    
    144145  return 0; 
    145146} 
Note: See TracChangeset for help on using the changeset viewer.