Changeset 1583


Ignore:
Timestamp:
10/08/06 14:41:41 (18 years ago)
Author:
bittner
Message:

ray casting issue partially solved

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

Legend:

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

    r1582 r1583  
    4242  int y; 
    4343 
    44   bool exportRays = true; 
     44  bool exportRays = false; 
    4545 
    4646   
     
    6262      SetupRay(ray, mWidth - (x + 1), mHeight - (y + 1)); 
    6363 
    64           bool debug = false; 
     64          bool debug = true; 
    6565          //      (y == mHeight/2) && (x== mWidth/3); 
    6666          //      MeshDebug = debug; 
     
    7171                ray.mFlags &= ~(Ray::STORE_TESTED_OBJECTS|Ray::STORE_KDLEAVES); 
    7272           
    73           if (tree->CastRay(ray))  
     73          if (tree->CastRay(ray)) { 
     74                //              cout<<"I1"; 
     75 
    7476                if (ray.intersections.size()) { 
    75                   cout<<"I"; 
    7677                  sort(ray.intersections.begin(), ray.intersections.end()); 
    7778                  MeshInstance *mesh = (MeshInstance*)ray.intersections[0].mObject; 
     
    8687                   
    8788                } 
     89          } 
    8890      pbuffer+=components; 
    8991       
  • GTP/trunk/Lib/Vis/Preprocessing/src/Camera.h

    r878 r1583  
    2626   
    2727  Camera() { 
    28     mWidth = 1400; 
    29     mHeight = 1000; 
     28    mWidth = 100; 
     29    mHeight = 100; 
    3030    mFovy = 90.0f*(float)M_PI/180.0f; 
    3131  } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp

    r1551 r1583  
    2828                                                           ) 
    2929{ 
    30         //cout << "internal ray" << endl; 
    31         int hits = 0; 
    32         static Ray ray; 
    33         Intersection hitA(simpleRay.mOrigin), hitB(simpleRay.mOrigin); 
    34          
    35         mPreprocessor.SetupRay(ray, simpleRay.mOrigin, simpleRay.mDirection); 
    36         ray.mFlags &= ~Ray::CULL_BACKFACES; 
    37  
    38         if (mKdTree->CastRay(ray))  
     30  //cout << "internal ray" << endl; 
     31  int hits = 0; 
     32  static Ray ray; 
     33  Intersection hitA(simpleRay.mOrigin), hitB(simpleRay.mOrigin); 
     34   
     35  mPreprocessor.SetupRay(ray, simpleRay.mOrigin, simpleRay.mDirection); 
     36  ray.mFlags &= ~Ray::CULL_BACKFACES; 
     37   
     38  if (mKdTree->CastRay(ray))  
    3939        { 
    40                 hitA.mObject = ray.intersections[0].mObject; 
    41                 hitA.mPoint = ray.Extrap(ray.intersections[0].mT); 
    42                 hitA.mNormal = ray.intersections[0].mNormal;  
    43         //      cout << "hita: " << hitA.mPoint << " !obj: " << hitA.mObject << endl; 
     40          hitA.mObject = ray.intersections[0].mObject; 
     41          hitA.mPoint = ray.Extrap(ray.intersections[0].mT); 
     42          hitA.mNormal = ray.intersections[0].mNormal;  
     43          //    cout << "hita: " << hitA.mPoint << " !obj: " << hitA.mObject << endl; 
    4444        } 
    45          
    46         mPreprocessor.SetupRay(ray, simpleRay.mOrigin, -simpleRay.mDirection); 
    47         ray.mFlags &= ~Ray::CULL_BACKFACES; 
    48  
    49         if (castDoubleRay && mKdTree->CastRay(ray))  
     45   
     46  mPreprocessor.SetupRay(ray, simpleRay.mOrigin, -simpleRay.mDirection); 
     47  ray.mFlags &= ~Ray::CULL_BACKFACES; 
     48   
     49  if (castDoubleRay && mKdTree->CastRay(ray))  
    5050        { 
    51                 hitB.mObject = ray.intersections[0].mObject; 
    52                 hitB.mPoint = ray.Extrap(ray.intersections[0].mT); 
    53                 hitB.mNormal = ray.intersections[0].mNormal; 
     51          hitB.mObject = ray.intersections[0].mObject; 
     52          hitB.mPoint = ray.Extrap(ray.intersections[0].mT); 
     53          hitB.mNormal = ray.intersections[0].mNormal; 
    5454        } 
    55                  
    56         return ProcessRay( 
    57                 simpleRay, 
    58                 hitA, 
    59                 hitB, 
    60         vssRays, 
    61                 box, 
    62                 castDoubleRay, 
    63                 pruneInvalidRays 
    64                 ); 
     55   
     56  return ProcessRay( 
     57                                        simpleRay, 
     58                                        hitA, 
     59                                        hitB, 
     60                                        vssRays, 
     61                                        box, 
     62                                        castDoubleRay, 
     63                                        pruneInvalidRays 
     64                                        ); 
    6565} 
    6666 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r1551 r1583  
    607607  float maxt = 1e6; 
    608608  float mint = 0; 
    609   
     609 
     610  ray.ComputeInvertedDir(); 
     611 
    610612  Intersectable::NewMail(); 
    611613 
  • GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorThread.cpp

    r1581 r1583  
    2424  Camera camera; 
    2525   
    26   if (1) 
     26  if (0) 
    2727        { 
    2828                // camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); 
     
    3636        }  
    3737   
    38   if (2) { 
     38  if (0) { 
    3939        camera.LookInBox(mPreprocessor->mKdTree->GetBox()); 
    4040        camera.SetPosition(camera.mPosition + Vector3(-250,0,-550)); 
     
    4242  } 
    4343 
    44   if (3) { 
     44  if (0) { 
    4545        camera.SetPosition( mPreprocessor->mKdTree->GetBox().Center() - Vector3(0,-100,0) ); 
    4646        camera.SetDirection(Vector3(1, 0, 0)); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Ray.cpp

    r1199 r1583  
    3636{ 
    3737  // initialize inverted dir 
    38   invDir.SetValue(0.0); 
     38  invDir.SetValue(0.0, 0.0, 0.0); 
    3939   
    4040  SetId(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r1551 r1583  
    2626                                                   const bool castDoubleRay) 
    2727{ 
    28         VssRayContainer rays; 
    29         CastRay(simpleRay, rays, box, castDoubleRay); 
    30  
    31         if (!rays.empty()) 
    32                 return rays.back(); 
    33         else 
    34                 return NULL; 
     28  VssRayContainer rays; 
     29  CastRay(simpleRay, rays, box, castDoubleRay); 
     30   
     31  if (!rays.empty()) 
     32        return rays.back(); 
     33  else 
     34        return NULL; 
    3535} 
    3636 
     
    123123        if (validSample)  
    124124        { 
    125                 if (!pruneInvalidRays || hitA.mObject)  
     125          if (!pruneInvalidRays || hitA.mObject)  
    126126                { 
    127                         VssRay *vssRay = new VssRay( 
    128                                 hitB.mPoint, 
    129                                 hitA.mPoint, 
    130                                 hitB.mObject, 
    131                                 hitA.mObject, 
    132                                 mPreprocessor.mPass, 
    133                                 simpleRay.mPdf 
    134                                 ); 
    135                          
    136                         vssRays.push_back(vssRay); 
    137                         ++ hits; 
    138                         //cout << "vssray 1: " << *vssRay << " " << vssRay->mTermination - vssRay->mOrigin << endl; 
     127                  VssRay *vssRay = new VssRay( 
     128                                                                          hitB.mPoint, 
     129                                                                          hitA.mPoint, 
     130                                                                          hitB.mObject, 
     131                                                                          hitA.mObject, 
     132                                                                          mPreprocessor.mPass, 
     133                                                                          simpleRay.mPdf 
     134                                                                          ); 
     135                   
     136                  vssRays.push_back(vssRay); 
     137                  ++ hits; 
     138                  //cout << "vssray 1: " << *vssRay << " " << vssRay->mTermination - vssRay->mOrigin << endl; 
    139139                } 
    140  
    141                 if (castDoubleRay && (!pruneInvalidRays || hitB.mObject)) 
     140           
     141          if (castDoubleRay && (!pruneInvalidRays || hitB.mObject)) 
    142142                { 
    143                         VssRay *vssRay = new VssRay( 
    144                                 hitA.mPoint, 
    145                                 hitB.mPoint, 
    146                                 hitA.mObject, 
    147                                 hitB.mObject, 
    148                                 mPreprocessor.mPass, 
    149                                 simpleRay.mPdf 
    150                                 ); 
    151                          
    152                         vssRays.push_back(vssRay); 
    153                         ++ hits; 
    154                         //cout << "vssray 2: " << *vssRay << endl; 
     143                  VssRay *vssRay = new VssRay( 
     144                                                                          hitA.mPoint, 
     145                                                                          hitB.mPoint, 
     146                                                                          hitA.mObject, 
     147                                                                          hitB.mObject, 
     148                                                                          mPreprocessor.mPass, 
     149                                                                          simpleRay.mPdf 
     150                                                                          ); 
     151                   
     152                  vssRays.push_back(vssRay); 
     153                  ++ hits; 
     154                  //cout << "vssray 2: " << *vssRay << endl; 
    155155                } 
    156156        } 
    157  
     157         
    158158        return hits; 
    159159} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1581 r1583  
    9090 
    9191 
    92 #if 0 //matt: this moved up into preprocessor 
    93 int 
    94 RssPreprocessor::CastRay( 
    95                                                  Vector3 &viewPoint, 
    96                                                  Vector3 &direction, 
    97                                                  const float probability, 
    98                                                  VssRayContainer &vssRays 
    99                                                  ) 
    100 { 
    101   int hits = 0; 
    102   static Ray ray; 
    103   Intersectable *objectA, *objectB; 
    104   Vector3 pointA, pointB; 
    105  
    106   //  AxisAlignedBox3 box = Union(mKdTree->GetBox(), mViewCellsManager->GetViewSpaceBox()); 
    107    
    108   AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox(); 
    109  
    110   AxisAlignedBox3 sbox = box; 
    111   sbox.Enlarge(Vector3(-Limits::Small)); 
    112   if (!sbox.IsInside(viewPoint)) 
    113         return 0; 
    114          
    115   SetupRay(ray, viewPoint, direction); 
    116   ray.mFlags &= ~Ray::CULL_BACKFACES; 
    117  
    118   // cast ray to KD tree to find intersection with other objects 
    119   float bsize = Magnitude(box.Size()); 
    120    
    121    
    122   if (mKdTree->CastRay(ray)) { 
    123         objectA = ray.intersections[0].mObject; 
    124         pointA = ray.Extrap(ray.intersections[0].mT); 
    125         if (mDetectEmptyViewSpace) 
    126           if (DotProd(ray.intersections[0].mNormal, direction) >= 0) { 
    127                 // discard the sample 
    128                 return 0; 
    129           } 
    130          
    131   } else { 
    132         objectA = NULL; 
    133         // compute intersection with the scene bounding box 
    134         float tmin, tmax; 
    135         if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 
    136           pointA = ray.Extrap(tmax); 
    137         else 
    138           return 0; 
    139   } 
    140  
    141    
    142   SetupRay(ray, viewPoint, -direction); 
    143   ray.mFlags &= ~Ray::CULL_BACKFACES; 
    144    
    145   if (mKdTree->CastRay(ray)) { 
    146         objectB = ray.intersections[0].mObject; 
    147         pointB = ray.Extrap(ray.intersections[0].mT); 
    148         if (mDetectEmptyViewSpace) 
    149           if (DotProd(ray.intersections[0].mNormal, direction) <= 0) { 
    150                 // discard the sample 
    151                 return 0; 
    152           } 
    153   } else { 
    154         objectB = NULL; 
    155         float tmin, tmax; 
    156         if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 
    157           pointB = ray.Extrap(tmax); 
    158         else 
    159           return 0; 
    160   } 
    161    
    162    
    163   VssRay *vssRay  = NULL; 
    164   bool validSample = (objectA != objectB); 
    165   if (validSample) { 
    166         if (objectA) { 
    167           vssRay = new VssRay(pointB, 
    168                                                   pointA, 
    169                                                   objectB, 
    170                                                   objectA, 
    171                                                   mPass, 
    172                                                   probability 
    173                                                   ); 
    174           vssRays.push_back(vssRay); 
    175           hits ++; 
    176         } 
    177          
    178         if (objectB) { 
    179           vssRay = new VssRay(pointA, 
    180                                                   pointB, 
    181                                                   objectA, 
    182                                                   objectB, 
    183                                                   mPass, 
    184                                                   probability 
    185                                                   ); 
    186           vssRays.push_back(vssRay); 
    187           hits ++; 
    188         } 
    189   } 
    190    
    191   return hits; 
    192 } 
    193 #endif 
    19492 
    19593void 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r1581 r1583  
    4444        type rss 
    4545#       type render 
    46         detectEmptyViewSpace false 
     46        detectEmptyViewSpace true 
    4747#       pvsRenderErrorSamples 0 
    4848        pvsRenderErrorSamples 5000 
     
    5353        visibilityFilterWidth   0.01 
    5454        visibilityFile visibility.xml 
    55         loadMeshes true 
     55        loadMeshes false 
    5656        loadKdTree      false 
    5757        exportKdTree false 
    58  
    5958} 
    6059 
     
    344343#               minGlobalCostRatio      0.0001 
    345344# $$MAXVIEWCELLS 
    346                 maxViewCells            1000 
     345                maxViewCells            5000 
    347346         
    348347 
Note: See TracChangeset for help on using the changeset viewer.