Ignore:
Timestamp:
08/03/05 11:15:30 (19 years ago)
Author:
bittner
Message:

basic sampling strategies

File:
1 edited

Legend:

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

    r176 r191  
    145145 
    146146 
    147   if (wireframe) 
     147  if (mWireframe) 
    148148    stream<<"<IndexedLineSet ccw=\"TRUE\" coordIndex=\""<<endl; 
    149149  else 
     
    174174  stream<<"</Coordinate>"<<endl; 
    175175 
    176   if (wireframe) 
     176  if (mWireframe) 
    177177    stream<<"</IndexedLineSet>"<<endl; 
    178178  else 
     
    211211X3dExporter::ExportKdTree(const KdTree &tree) 
    212212{ 
     213  if (mExportRayDensity) { 
     214    return ExportKdTreeRayDensity(tree); 
     215  } 
     216   
    213217  stack<KdNode *> tStack; 
    214218 
     
    249253 
    250254 
     255bool 
     256X3dExporter::ExportKdTreeRayDensity(const KdTree &tree) 
     257{ 
     258  stack<KdNode *> tStack; 
     259 
     260  tStack.push(tree.GetRoot()); 
     261 
     262  bool fm = mUseForcedMaterial; 
     263  mUseForcedMaterial = true; 
     264  mForcedMaterial.mDiffuseColor.g = 1.0f; 
     265  mForcedMaterial.mDiffuseColor.b = 1.0f; 
     266  while (!tStack.empty()) { 
     267    KdNode *node = tStack.top(); 
     268    tStack.pop(); 
     269    if (node->IsLeaf()) { 
     270      AxisAlignedBox3 box = tree.GetBox(node); 
     271      Mesh *mesh = new Mesh; 
     272       
     273      // add 6 vertices of the box 
     274      int index = mesh->mVertices.size(); 
     275      for (int i=0; i < 8; i++) { 
     276        Vector3 v; 
     277        box.GetVertex(i, v); 
     278        mesh->mVertices.push_back(v); 
     279      } 
     280      mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 
     281      mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 
     282      mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 
     283       
     284      mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 
     285      mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 
     286      mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 
     287 
     288 
     289      // set the mesh material according to the ray density 
     290      KdLeaf *leaf = (KdLeaf *) node; 
     291      if (leaf->mPassingRays.mRays) { 
     292        float importance = leaf->mPassingRays.mContributions/(float)leaf->mPassingRays.mRays; 
     293        //      float importance = leaf->mPassingRays.mContributions/1000.0f; 
     294        //      float importance = leaf->mPassingRays.mRays/1000.0f; 
     295        ///(float)leaf->mPassingRays.mRays; 
     296        // mForcedMaterial.mDiffuseColor.r = log10(leaf->mPassingRays.mRays)/3.0f; 
     297        mForcedMaterial.mDiffuseColor.r = importance; 
     298        mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 
     299        ExportMesh(mesh); 
     300      } 
     301      delete mesh; 
     302    } else { 
     303      KdInterior *interior = (KdInterior *)node; 
     304      tStack.push(interior->mFront); 
     305      tStack.push(interior->mBack); 
     306    } 
     307  } 
     308  // restore the state of forced material 
     309  mUseForcedMaterial = fm; 
     310  return true; 
     311} 
Note: See TracChangeset for help on using the changeset viewer.