Changeset 223 for trunk/VUT


Ignore:
Timestamp:
08/08/05 23:44:02 (19 years ago)
Author:
bittner
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/MutualVisibility.cpp

    r209 r223  
    2727  Vector3 origin, direction; 
    2828  GetRay(rayIndex, origin, direction); 
    29   return origin + direction*mIntersections[rayIndex][depth].mT; 
     29  return origin + direction*mSamples[rayIndex].mIntersections[depth].mT; 
    3030} 
    3131 
     
    7676  switch (axis) { 
    7777  case 0: 
    78     sample1.mIntersections[0] = sample.mIntersections[0]; 
    79     sample1.mIntersections[3] = sample.mIntersections[3]; 
    80      
    81     sample2.mIntersections[1] = sample.mIntersections[1]; 
    82     sample2.mIntersections[2] = sample.mIntersections[2]; 
     78    sample1.mSamples[0].mIntersections = sample.mSamples[0].mIntersections; 
     79    sample1.mSamples[3].mIntersections = sample.mSamples[3].mIntersections; 
     80     
     81    sample2.mSamples[1].mIntersections = sample.mSamples[1].mIntersections; 
     82    sample2.mSamples[2].mIntersections = sample.mSamples[2].mIntersections; 
    8383    break; 
    8484 
    8585  case 1: 
    86     sample1.mIntersections[0] = sample.mIntersections[0]; 
    87     sample1.mIntersections[1] = sample.mIntersections[1]; 
    88  
    89     sample2.mIntersections[2] = sample.mIntersections[2]; 
    90     sample2.mIntersections[2] = sample.mIntersections[3]; 
     86    sample1.mSamples[0].mIntersections = sample.mSamples[0].mIntersections; 
     87    sample1.mSamples[1].mIntersections = sample.mSamples[1].mIntersections; 
     88 
     89    sample2.mSamples[2].mIntersections = sample.mSamples[2].mIntersections; 
     90    sample2.mSamples[3].mIntersections = sample.mSamples[3].mIntersections; 
    9191    break; 
    9292  } 
     
    148148                                                 ) 
    149149{ 
    150   Vector3 normal = target.Center() - source.Center(); 
    151  
     150  Vector3 sourceCenter = source.Center(); 
     151  Vector3 targetCenter = target.Center(); 
     152  Vector3 normal = Normalize(sourceCenter - targetCenter ); 
     153   
    152154  Plane3 sourcePlane(normal, source.GetVertex(0)); 
    153155  int i; 
     
    158160  } 
    159161   
    160   Plane3 targetPlane(-normal, target.GetVertex(0)); 
     162  Plane3 targetPlane(normal, target.GetVertex(0)); 
    161163  for (i=1; i < 8; i++) { 
    162164    Vector3 v = target.GetVertex(i); 
    163     if (targetPlane.Distance(v) > 0) 
    164       targetPlane = Plane3(-normal, v); 
     165    if (targetPlane.Distance(v) < 0) 
     166      targetPlane = Plane3(normal, v); 
    165167  } 
    166168 
     
    175177 
    176178  Vector3 yBasis = Normalize( CrossProd(normal, xBasis) ); 
    177    
    178   Plane3 bottomPlane(xBasis, source.Center()); 
    179   Plane3 sidePlane(yBasis, source.Center()); 
    180    
    181   // cast rays between corresponding vertices of the boxes 
    182   for (i=0; i < 8; i++) { 
    183      
    184      
    185   } 
     179  // cast rays between the centers of the boxes 
     180  Vector3 targetRCenter = targetPlane.FindIntersection(sourceCenter, 
     181                                                       targetCenter); 
     182   
     183  Vector3 sourceRCenter = sourcePlane.FindIntersection(sourceCenter, 
     184                                                       targetCenter); 
     185   
     186 
     187  Rectangle3 sourceRect; 
     188  Rectangle3 targetRect; 
     189 
     190   
     191  float scale = Magnitude(source.Size())*0.7f; 
     192  sourceRect.mVertices[0] = sourceRCenter - scale*xBasis - scale*yBasis; 
     193  sourceRect.mVertices[1] = sourceRCenter + scale*xBasis - scale*yBasis; 
     194  sourceRect.mVertices[2] = sourceRCenter + scale*xBasis + scale*yBasis; 
     195  sourceRect.mVertices[3] = sourceRCenter - scale*xBasis + scale*yBasis; 
     196 
     197  scale = Magnitude(target.Size())*0.7f; 
     198  targetRect.mVertices[0] = targetRCenter - scale*xBasis - scale*yBasis; 
     199  targetRect.mVertices[1] = targetRCenter + scale*xBasis - scale*yBasis; 
     200  targetRect.mVertices[2] = targetRCenter + scale*xBasis + scale*yBasis; 
     201  targetRect.mVertices[3] = targetRCenter - scale*xBasis + scale*yBasis; 
     202 
     203  AddInitialSamples(sourceRect, targetRect, samples); 
     204 
     205  //    Plane3 bottomPlane(xBasis, source.Center()); 
     206  //    Plane3 sidePlane(yBasis, source.Center()); 
     207   
     208  //    // cast rays between corresponding vertices of the boxes 
     209  //    for (i=0; i < 8; i++) { 
     210  //      Vector3 v; 
     211  //      bool coplanar; 
     212  //      v = sourcePlane.FindIntersection(source.GetVertex(i), 
     213  //                                 target.GetVertex(i), 
     214  //                                 NULL, 
     215  //                                 &coplanar); 
     216  //      if (!coplanar) { 
     217  //        // evaluate source and  
     218   
     219  //      } 
     220  //    } 
    186221   
    187222  //  AddInitialSamples(sourceRectangle, targetRectangle, samples); 
     
    213248    sprintf(filename, "samples%04d-%02d.x3d", id++, i); 
    214249    Exporter *exporter = Exporter::GetExporter(filename); 
     250 
     251    exporter->SetWireframe(); 
     252    exporter->ExportBox(mSource); 
     253    exporter->ExportBox(mTarget); 
     254 
    215255    exporter->SetFilled(); 
    216256 
     
    238278 
    239279int 
     280MutualVisibilitySampler::CastRays(RayShaft &shaft) 
     281{ 
     282  Ray ray; 
     283  int i; 
     284 
     285  for (i=0; i < 4; i++) { 
     286    Vector3 origin, direction; 
     287    shaft.GetRay(i, origin, direction); 
     288    // determine intersections with the boxes 
     289    ray.Init(origin, direction, Ray::LINE_SEGMENT); 
     290    float stmin, stmax, ttmin, ttmax; 
     291    if ( mSource.GetMinMaxT(ray, &stmin, &stmax) && mTarget.GetMinMaxT(ray, &ttmin, &ttmax) ) { 
     292      shaft.mSamples[i].mMinT = stmax; 
     293      shaft.mSamples[i].mMaxT = ttmin; 
     294      origin = ray.Extrap(stmax); 
     295      direction = ray.Extrap(ttmin) - origin; 
     296      // reinit the ray 
     297      ray.Init(origin, direction, Ray::LINE_SEGMENT); 
     298      if (!mKdTree->CastRay(ray)) 
     299        return VISIBLE; 
     300    } else { 
     301      shaft.mSamples[i].mMaxT = -1.0; 
     302    } 
     303  } 
     304  return INVISIBLE; 
     305} 
     306 
     307int 
    240308MutualVisibilitySampler::ComputeVisibility() 
    241309{ 
    242310 
    243   vector<RayShaft *> samples; 
    244   ConstructInitialSamples(mSource, mTarget, samples); 
    245   ExportSamples(samples); 
    246  
    247   stack<RayShaft *> sampleStack; 
     311  vector<RayShaft *> shafts; 
     312  ConstructInitialSamples(mSource, mTarget, shafts); 
     313  ExportSamples(shafts); 
     314 
     315  stack<RayShaft *> shaftStack; 
    248316   
    249317   
    250318   
    251319  Ray ray; 
    252   // now process the samples as long as we have something to do 
    253   while (!sampleStack.empty()) { 
    254     RayShaft *sample = sampleStack.top(); 
    255     sampleStack.pop(); 
     320  // now process the shafts as long as we have something to do 
     321  while (!shaftStack.empty()) { 
     322    RayShaft *shaft = shaftStack.top(); 
     323    shaftStack.pop(); 
    256324     
    257325//      // cast a new ray 
    258326//      int triangleSplitEdge = SetupExtremalRay(sample, source, ray); 
    259327     
    260 //      if (!kdTree->CastRay(ray)) 
    261 //        return VISIBLE; 
    262      
    263 //      // generate 2 new samples 
    264 //      RayShaft newSamples[2]; 
    265 //      sample.Split(triangleSplitEdge, ray, newSamples[0], newSamples[1]); 
    266 //      for (i=0; i < 2; i++) { 
    267 //        newSamples[i].ComputeError(); 
    268 //        if (newSamples[i].mError > solidAngleThreshold) { 
    269 //      sampleStack.push(newSamples[i]); 
    270 //        } 
    271 //      } 
    272 //    } 
    273   } 
    274  
    275   for (int i=0; i < samples.size(); i++) 
    276     delete samples[i]; 
     328    if (CastRays(*shaft) == VISIBLE) 
     329      return VISIBLE; 
     330     
     331    //      // generate 2 new samples 
     332    //      RayShaft newSamples[2]; 
     333    //      sample.Split(triangleSplitEdge, ray, newSamples[0], newSamples[1]); 
     334    //      for (i=0; i < 2; i++) { 
     335    //        newSamples[i].ComputeError(); 
     336    //        if (newSamples[i].mError > solidAngleThreshold) { 
     337    //          sampleStack.push(newSamples[i]); 
     338    //        } 
     339    //      } 
     340    //    } 
     341  } 
     342 
     343  for (int i=0; i < shafts.size(); i++) 
     344    delete shafts[i]; 
    277345  return INVISIBLE; 
    278346} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/MutualVisibility.h

    r209 r223  
    1313}; 
    1414 
     15struct RaySample { 
     16  /// true if the sample really intersects both boxes 
     17  float mMinT; 
     18  float mMaxT; 
     19  /// intersections of the sample with the scene 
     20  vector<Ray::Intersection> mIntersections; 
     21  bool IsValid() const { return mMaxT > 0.0; } 
     22}; 
    1523 
    1624struct RayShaft { 
     
    2533  Rectangle3 mTarget; 
    2634   
    27   /// intersections with the scene 
    28   vector<Ray::Intersection> mIntersections[4]; 
     35  RaySample mSamples[4]; 
    2936   
    3037  void ComputeError(); 
     
    112119                  ); 
    113120 
     121  int 
     122  CastRays(RayShaft &shaft); 
     123 
    114124  void 
    115125  ComputeError(RayShaft &sample); 
    116  
     126   
    117127  void 
    118128  ExportSamples(vector<RayShaft *> &samples); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Rectangle3.h

    r221 r223  
    3838        Rectangle3 &r1, 
    3939        Rectangle3 &r2 
    40         ) const 
    41  
    42   {//TODO 
    43   } 
     40        ) const; 
    4441   
    4542}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r218 r223  
    9191   
    9292  while (totalSamples < mTotalSamples) 
    93   { 
    94           int passContributingSamples = 0; 
    95           int passSampleContributions = 0; 
    96           int passSamples = 0; 
    97           int index = 0; 
    98  
    99           for (i =0; i < objects.size(); i++) { 
    100                   KdNode *nodeToSample = NULL; 
    101                   Intersectable *object = objects[i]; 
    102                    
    103                   int pvsSize = object->mKdPvs.GetSize(); 
    104        
    105                   if (0 && pvsSize) { 
    106                           // mail all nodes from the pvs 
    107                           Intersectable::NewMail(); 
    108                           KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 
     93    { 
     94      int passContributingSamples = 0; 
     95      int passSampleContributions = 0; 
     96      int passSamples = 0; 
     97      int index = 0; 
     98 
     99      for (i =0; i < objects.size(); i++) { 
     100        KdNode *nodeToSample = NULL; 
     101        Intersectable *object = objects[i]; 
     102                   
     103        int pvsSize = object->mKdPvs.GetSize(); 
     104       
     105        if (0 && pvsSize) { 
     106          // mail all nodes from the pvs 
     107          Intersectable::NewMail(); 
     108          KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 
    109109                           
    110                           for (; i != object->mKdPvs.mEntries.end(); i++) { 
    111                                   KdNode *node = (*i).first; 
    112                                   node->Mail(); 
    113                           } 
    114  
    115                           int maxTries = 2*pvsSize; 
    116          
    117                           for (int tries = 0; tries < 10; tries++) { 
    118                                   index = RandomValue(0, pvsSize - 1); 
    119                                   KdPvsData data; 
    120                                   KdNode *node; 
    121                                   object->mKdPvs.GetData(index, node, data); 
    122                                   nodeToSample = mKdTree->FindRandomNeighbor(node, true); 
    123                                   if (nodeToSample) 
    124                                           break; 
    125                           } 
    126                   } 
    127        
    128               if (0 && pvsSize && pass == 50)  { 
    129                           // mail all nodes from the pvs 
    130                           Intersectable::NewMail(); 
    131                           KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 
    132                           for (; i != object->mKdPvs.mEntries.end(); i++) { 
    133                                   KdNode *node = (*i).first; 
    134                                   node->Mail(); 
    135                           } 
    136  
    137                           vector<KdNode *> invisibleNeighbors; 
    138                           // get all neighbors of all PVS nodes 
    139                           i = object->mKdPvs.mEntries.begin(); 
    140  
    141                           for (; i != object->mKdPvs.mEntries.end(); i++) { 
    142                                   KdNode *node = (*i).first; 
    143                                   mKdTree->FindNeighbors(node, invisibleNeighbors, true); 
    144                                   AxisAlignedBox3 box = object->GetBox(); 
    145                                    
    146                                   for (int j=0; j < invisibleNeighbors.size(); j++)  
    147                                   { 
    148                                           int visibility = ComputeBoxVisibility(mKdTree, 
    149                                                                                                                         box, 
    150                                                                                                                         mKdTree->GetBox(invisibleNeighbors[j]), 
    151                                                                                                                         1.0f); 
    152                                   } 
    153                                   // now rank all the neighbors according to probability that a new 
    154                                   // sample creates some contribution 
    155                           } 
    156                   } 
    157  
    158                   for (int k=0; k < mSamplesPerPass; k++) { 
    159                           object->GetRandomSurfacePoint(point, normal); 
    160                            
    161                           if (nodeToSample) { 
    162                                   int maxTries = 5; 
    163                                    
    164                                   for (int tries = 0; tries < maxTries; tries++) { 
    165                                           direction = mKdTree->GetBox(nodeToSample).GetRandomPoint() - point; 
    166  
    167                                           if (DotProd(direction, normal) > Limits::Small) 
    168                                                   break; 
    169                                   } 
    170                  
    171                                   if (tries == maxTries) 
    172                                           direction = UniformRandomVector(normal); 
    173                           }  
    174                           else 
    175                                   direction = UniformRandomVector(normal); 
    176          
    177                           // construct a ray 
    178                           SetupRay(ray, point, direction); 
    179                           mKdTree->CastRay(ray); 
    180  
    181                           if (i < pvsOut) 
    182                                   rays[i].push_back(ray); 
    183          
    184                           int sampleContributions = 0; 
    185          
    186                    
    187                           if (ray.leaves.size()) { 
    188                                   sampleContributions += AddNodeSamples(object, ray, pass); 
    189            
    190                                   if (ray.intersections.size()) { 
    191                                           sampleContributions += AddNodeSamples(ray.intersections[0].mObject, ray, pass); 
    192                                           // check whether we can add this to the rays 
    193                                           for (int j = 0; j < pvsOut; j++) { 
    194                                                   if (objects[j] == ray.intersections[0].mObject) { 
    195                                                           rays[j].push_back(ray); 
    196                                                   } 
    197                                           } 
    198                                   } 
    199  
    200                                   passSamples++; 
     110          for (; i != object->mKdPvs.mEntries.end(); i++) { 
     111            KdNode *node = (*i).first; 
     112            node->Mail(); 
     113          } 
     114 
     115          int maxTries = 2*pvsSize; 
     116         
     117          for (int tries = 0; tries < 10; tries++) { 
     118            index = RandomValue(0, pvsSize - 1); 
     119            KdPvsData data; 
     120            KdNode *node; 
     121            object->mKdPvs.GetData(index, node, data); 
     122            nodeToSample = mKdTree->FindRandomNeighbor(node, true); 
     123            if (nodeToSample) 
     124              break; 
     125          } 
     126        } 
     127 
     128         
     129        if (pvsSize && pass == 50 ) { 
     130          // mail all nodes from the pvs 
     131          Intersectable::NewMail(); 
     132          KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 
     133          for (; i != object->mKdPvs.mEntries.end(); i++) { 
     134            KdNode *node = (*i).first; 
     135            node->Mail(); 
     136          } 
     137         
     138          vector<KdNode *> invisibleNeighbors; 
     139          // get all neighbors of all PVS nodes 
     140          i = object->mKdPvs.mEntries.begin(); 
     141          for (; i != object->mKdPvs.mEntries.end(); i++) { 
     142            KdNode *node = (*i).first; 
     143            mKdTree->FindNeighbors(node, invisibleNeighbors, true); 
     144            AxisAlignedBox3 box = object->GetBox(); 
     145            for (int j=0; j < invisibleNeighbors.size(); j++) { 
     146              int visibility = ComputeBoxVisibility(mKdTree, 
     147                                                    box, 
     148                                                    mKdTree->GetBox(invisibleNeighbors[j]), 
     149                                                    1.0f); 
     150             
     151            } 
     152            // now rank all the neighbors according to probability that a new 
     153            // sample creates some contribution 
     154          } 
     155        } 
     156 
     157       
     158        for (int k=0; k < mSamplesPerPass; k++) { 
     159          object->GetRandomSurfacePoint(point, normal); 
     160         
     161          if (nodeToSample) { 
     162            int maxTries = 5; 
     163           
     164            for (int tries = 0; tries < maxTries; tries++) { 
     165              direction = mKdTree->GetBox(nodeToSample).GetRandomPoint() - point; 
     166             
     167              if (DotProd(direction, normal) > Limits::Small) 
     168                break; 
     169            } 
     170           
     171            if (tries == maxTries) 
     172              direction = UniformRandomVector(normal); 
     173          }  
     174          else 
     175            direction = UniformRandomVector(normal); 
     176         
     177          // construct a ray 
     178          SetupRay(ray, point, direction); 
     179          mKdTree->CastRay(ray); 
     180 
     181          if (i < pvsOut) 
     182            rays[i].push_back(ray); 
     183         
     184          int sampleContributions = 0; 
     185         
     186                   
     187          if (ray.leaves.size()) { 
     188            sampleContributions += AddNodeSamples(object, ray, pass); 
     189           
     190            if (ray.intersections.size()) { 
     191              sampleContributions += AddNodeSamples(ray.intersections[0].mObject, ray, pass); 
     192              // check whether we can add this to the rays 
     193              for (int j = 0; j < pvsOut; j++) { 
     194                if (objects[j] == ray.intersections[0].mObject) { 
     195                  rays[j].push_back(ray); 
     196                } 
     197              } 
     198            } 
     199 
     200            passSamples++; 
    201201                         
    202                                   if (sampleContributions) { 
    203                                           passContributingSamples++; 
    204                                           passSampleContributions += sampleContributions; 
    205                                   } 
    206                           } 
    207                   } 
     202            if (sampleContributions) { 
     203              passContributingSamples++; 
     204              passSampleContributions += sampleContributions; 
     205            } 
     206          } 
    208207        } 
    209  
    210     totalSamples += passSamples; 
    211  
    212     //    if (pass>10) 
    213     //      HoleSamplingPass(); 
    214      
    215  
    216     pass++; 
    217      
    218     int pvsSize = 0; 
    219     for (i=0; i < objects.size(); i++) { 
    220                 Intersectable *object = objects[i]; 
    221                 pvsSize += object->mKdPvs.GetSize(); 
     208      } 
     209 
     210      totalSamples += passSamples; 
     211 
     212      //    if (pass>10) 
     213      //      HoleSamplingPass(); 
     214     
     215 
     216      pass++; 
     217     
     218      int pvsSize = 0; 
     219      for (i=0; i < objects.size(); i++) { 
     220        Intersectable *object = objects[i]; 
     221        pvsSize += object->mKdPvs.GetSize(); 
     222      } 
     223     
     224      cout << "pass " << pass<<" : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
     225      cout << "#totalSamples=" << totalSamples/1000  
     226           << "k   #sampleContributions=" << passSampleContributions << " ("  
     227           << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 
     228           << pvsSize/(float)objects.size() << endl  
     229           << "avg ray contrib=" << passSampleContributions/(float)passContributingSamples << endl; 
    222230    } 
    223      
    224         cout << "pass " << pass<<" : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    225         cout << "#totalSamples=" << totalSamples/1000  
    226                  << "k   #sampleContributions=" << passSampleContributions << " ("  
    227                  << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 
    228                  << pvsSize/(float)objects.size() << endl  
    229                  << "avg ray contrib=" << passSampleContributions/(float)passContributingSamples << endl; 
    230   } 
    231231 
    232232  int totalPvsSize = mKdTree->CollectLeafPvs(); 
     
    235235  //  HoleSamplingPass(); 
    236236  if (1) { 
    237           Exporter *exporter = Exporter::GetExporter("ray-density.x3d"); 
    238           exporter->SetExportRayDensity(true); 
    239           exporter->ExportKdTree(*mKdTree); 
    240           delete exporter; 
     237    Exporter *exporter = Exporter::GetExporter("ray-density.x3d"); 
     238    exporter->SetExportRayDensity(true); 
     239    exporter->ExportKdTree(*mKdTree); 
     240    delete exporter; 
    241241  } 
    242242   
    243243  bool exportRays = false; 
    244244  if (exportRays) { 
    245           Exporter *exporter = NULL; 
    246           exporter = Exporter::GetExporter("sample-rays.x3d"); 
    247           exporter->SetWireframe(); 
    248           exporter->ExportKdTree(*mKdTree); 
    249  
    250           for (i=0; i < pvsOut; i++)  
    251                   exporter->ExportRays(rays[i], 1000, RgbColor(1, 0, 0)); 
    252           exporter->SetFilled(); 
    253            
    254           delete exporter; 
     245    Exporter *exporter = NULL; 
     246    exporter = Exporter::GetExporter("sample-rays.x3d"); 
     247    exporter->SetWireframe(); 
     248    exporter->ExportKdTree(*mKdTree); 
     249 
     250    for (i=0; i < pvsOut; i++)  
     251      exporter->ExportRays(rays[i], 1000, RgbColor(1, 0, 0)); 
     252    exporter->SetFilled(); 
     253           
     254    delete exporter; 
    255255  } 
    256256 
    257257  if (1) { 
    258           for (int k=0; k < pvsOut; k++) { 
    259                   Intersectable *object = objects[k]; 
    260                   char s[64]; 
    261                   sprintf(s, "sample-pvs%04d.x3d", k); 
    262                   Exporter *exporter = Exporter::GetExporter(s); 
    263                   exporter->SetWireframe(); 
    264                   KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 
    265                    
    266                   Intersectable::NewMail(); 
    267                    
    268                   // avoid adding the object to the list 
    269                   object->Mail(); 
    270                   ObjectContainer visibleObjects; 
    271                   for (; i != object->mKdPvs.mEntries.end(); i++) { 
    272                           KdNode *node = (*i).first; 
    273                           exporter->ExportBox(mKdTree->GetBox(node)); 
    274                           mKdTree->CollectObjects(node, visibleObjects); 
    275                   } 
    276        
    277                   exporter->ExportRays(rays[k], 1000, RgbColor(0, 1, 0)); 
    278                   exporter->SetFilled(); 
    279  
    280                   for (int j = 0; j < visibleObjects.size(); j++) 
    281                           exporter->ExportIntersectable(visibleObjects[j]); 
    282          
    283                   Material m; 
    284                   m.mDiffuseColor = RgbColor(1, 0, 0); 
    285                   exporter->SetForcedMaterial(m); 
    286                   exporter->ExportIntersectable(object); 
    287        
    288                   delete exporter; 
    289           } 
     258    for (int k=0; k < pvsOut; k++) { 
     259      Intersectable *object = objects[k]; 
     260      char s[64]; 
     261      sprintf(s, "sample-pvs%04d.x3d", k); 
     262      Exporter *exporter = Exporter::GetExporter(s); 
     263      exporter->SetWireframe(); 
     264      KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 
     265                   
     266      Intersectable::NewMail(); 
     267                   
     268      // avoid adding the object to the list 
     269      object->Mail(); 
     270      ObjectContainer visibleObjects; 
     271      for (; i != object->mKdPvs.mEntries.end(); i++) { 
     272        KdNode *node = (*i).first; 
     273        exporter->ExportBox(mKdTree->GetBox(node)); 
     274        mKdTree->CollectObjects(node, visibleObjects); 
     275      } 
     276       
     277      exporter->ExportRays(rays[k], 1000, RgbColor(0, 1, 0)); 
     278      exporter->SetFilled(); 
     279 
     280      for (int j = 0; j < visibleObjects.size(); j++) 
     281        exporter->ExportIntersectable(visibleObjects[j]); 
     282         
     283      Material m; 
     284      m.mDiffuseColor = RgbColor(1, 0, 0); 
     285      exporter->SetForcedMaterial(m); 
     286      exporter->ExportIntersectable(object); 
     287       
     288      delete exporter; 
     289    } 
    290290  } 
    291291   
Note: See TracChangeset for help on using the changeset viewer.