Changeset 176 for trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
- Timestamp:
- 07/15/05 18:21:11 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r162 r176 23 23 } 24 24 25 25 26 bool 26 X3dExporter::ExportRays(const vector<Ray> &rays, const float length) 27 X3dExporter::ExportRays(const vector<Ray> &rays, 28 const float length, 29 const RgbColor &color) 27 30 { 28 31 vector<Ray>::const_iterator ri = rays.begin(); 29 32 stream<<"<Shape>"<<endl; 33 stream<<"<Appearance>"<<endl; 34 stream<<"<Material ambientColor=\""<<color.r<<" "<<color.g<<" "<<color.b<< 35 "\" />"<<endl; 36 stream<<"</Appearance>"<<endl; 37 30 38 stream<<"<IndexedLineSet ccw=\"TRUE\" coordIndex=\""<<endl; 31 39 … … 43 51 for (; ri != rays.end(); ri++) { 44 52 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); 46 62 47 63 stream<<a.x<<" "<<a.y<<" "<<a.z<<" ,"; … … 66 82 67 83 68 MeshContainer::const_iterator mi = node->mGeometry.begin();84 ObjectContainer::const_iterator mi = node->mGeometry.begin(); 69 85 for (; mi != node->mGeometry.end(); mi++) { 70 86 // export the transform... 71 Export Mesh((*mi)->GetMesh());87 ExportIntersectable(*mi); 72 88 } 73 89 74 90 stream<<"</Group>"<<endl; 75 91 92 } 93 void 94 X3dExporter::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 107 void 108 X3dExporter::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()); 76 114 } 77 115 … … 82 120 stream<<"<Shape>"<<endl; 83 121 stream<<"<Appearance>"<<endl; 84 122 85 123 // $$ tmp -> random material 86 124 87 125 float r, g, b; 88 126 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 } 98 142 stream<<"<Material diffuseColor=\""<<r<<" "<<g<<" "<<b<< 99 143 "\" specularColor=\"0.0 0.0 0.0\"/>"<<endl; … … 205 249 206 250 207 void208 X3dExporter::ExportMeshInstance(MeshInstance *mi)209 {210 ExportMesh(mi->GetMesh());211 }
Note: See TracChangeset
for help on using the changeset viewer.