Ignore:
Timestamp:
07/15/05 18:21:11 (19 years ago)
Author:
bittner
Message:

cosine sampling bug fixed

File:
1 edited

Legend:

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

    r162 r176  
    2323} 
    2424 
     25 
    2526bool 
    26 X3dExporter::ExportRays(const vector<Ray> &rays, const float length) 
     27X3dExporter::ExportRays(const vector<Ray> &rays, 
     28                        const float length, 
     29                        const RgbColor &color) 
    2730{ 
    2831  vector<Ray>::const_iterator ri = rays.begin(); 
    2932  stream<<"<Shape>"<<endl; 
     33  stream<<"<Appearance>"<<endl; 
     34  stream<<"<Material ambientColor=\""<<color.r<<" "<<color.g<<" "<<color.b<< 
     35    "\" />"<<endl; 
     36  stream<<"</Appearance>"<<endl; 
     37   
    3038  stream<<"<IndexedLineSet ccw=\"TRUE\" coordIndex=\""<<endl; 
    3139 
     
    4351  for (; ri != rays.end(); ri++) { 
    4452    Vector3 a = (*ri).GetLoc(); 
    45     Vector3 b = (*ri).GetLoc() + length*(*ri).GetDir(); 
     53     
     54    Vector3 b; 
     55    if (length < 0) 
     56      b = (*ri).GetLoc() - length*(*ri).GetDir(); 
     57    else 
     58      if ((*ri).intersections.size()==0) 
     59        b = (*ri).GetLoc() + length*(*ri).GetDir(); 
     60      else 
     61        b = (*ri).Extrap((*ri).intersections[0].mT); 
    4662     
    4763    stream<<a.x<<" "<<a.y<<" "<<a.z<<" ,"; 
     
    6682   
    6783   
    68   MeshContainer::const_iterator mi = node->mGeometry.begin(); 
     84  ObjectContainer::const_iterator mi = node->mGeometry.begin(); 
    6985  for (; mi != node->mGeometry.end(); mi++) { 
    7086    // export the transform... 
    71     ExportMesh((*mi)->GetMesh()); 
     87    ExportIntersectable(*mi); 
    7288  } 
    7389   
    7490  stream<<"</Group>"<<endl; 
    7591 
     92} 
     93void 
     94X3dExporter::ExportIntersectable(Intersectable *object) 
     95{ 
     96  switch (object->Type()) { 
     97  case Intersectable::MESH_INSTANCE: 
     98  case Intersectable::TRANSFORMED_MESH_INSTANCE: 
     99    ExportMeshInstance((MeshInstance *)object); 
     100    break; 
     101  default: 
     102    cerr<<"Sorry the export for object not yet defined"<<endl; 
     103    break; 
     104  } 
     105} 
     106 
     107void 
     108X3dExporter::ExportMeshInstance(MeshInstance *object) 
     109{ 
     110  // $$JB$$ 
     111  // in the future check whether the mesh was not already exportet 
     112  // and use a reference to the that mesh instead 
     113  ExportMesh(object->GetMesh()); 
    76114} 
    77115 
     
    82120  stream<<"<Shape>"<<endl; 
    83121  stream<<"<Appearance>"<<endl; 
    84  
     122   
    85123  // $$ tmp -> random material 
    86124   
    87125  float r, g, b; 
    88126 
    89   if (mesh->mMaterial) { 
    90     r = mesh->mMaterial->mDiffuseColor.r; 
    91     g = mesh->mMaterial->mDiffuseColor.g; 
    92     b = mesh->mMaterial->mDiffuseColor.b; 
    93   } else { 
    94     r = RandomValue(0.5, 1.0); 
    95     g = RandomValue(0.5, 1.0); 
    96     b = RandomValue(0.5, 1.0); 
    97   } 
     127  if (mUseForcedMaterial) { 
     128    r = mForcedMaterial.mDiffuseColor.r; 
     129    g = mForcedMaterial.mDiffuseColor.g; 
     130    b = mForcedMaterial.mDiffuseColor.b; 
     131     
     132  } else 
     133    if (mesh->mMaterial) { 
     134      r = mesh->mMaterial->mDiffuseColor.r; 
     135      g = mesh->mMaterial->mDiffuseColor.g; 
     136      b = mesh->mMaterial->mDiffuseColor.b; 
     137    } else { 
     138      r = RandomValue(0.5, 1.0); 
     139      g = RandomValue(0.5, 1.0); 
     140      b = RandomValue(0.5, 1.0); 
     141    } 
    98142  stream<<"<Material diffuseColor=\""<<r<<" "<<g<<" "<<b<< 
    99143    "\" specularColor=\"0.0 0.0 0.0\"/>"<<endl; 
     
    205249 
    206250 
    207 void 
    208 X3dExporter::ExportMeshInstance(MeshInstance *mi) 
    209 { 
    210   ExportMesh(mi->GetMesh()); 
    211 } 
Note: See TracChangeset for help on using the changeset viewer.