Ignore:
Timestamp:
01/15/06 04:23:51 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r535 r540  
    12421242void X3dExporter::ExportBeam(const Beam &beam, const AxisAlignedBox3 &box) 
    12431243{ 
     1244        if (beam.mMesh) 
     1245        { 
     1246                ExportMesh(beam.mMesh); 
     1247                return; 
     1248        } 
     1249 
    12441250        PolygonContainer polys; 
    12451251        //ExportBox(beam.mBox); 
    12461252 
    1247         for (int i = 0; i < beam.mPlanes.size(); ++ i) 
    1248         { 
    1249                 Polygon3 *poly = box.CrossSection(beam.mPlanes[i]); 
     1253        const float zfar = 2.0f * Magnitude(box.Diagonal()); 
     1254 
     1255        // box should not never remove part of beam polygons 
     1256        Vector3 bmin = beam.mBox.Min() - Vector3(zfar * 2.0); 
     1257        Vector3 bmax = beam.mBox.Max() + Vector3(zfar * 2.0); 
     1258 
     1259        AxisAlignedBox3 bbox(bmin, bmax); 
     1260        Plane3 fplane; 
     1261        fplane.mNormal = -beam.mPlanes[0].mNormal; 
     1262 
     1263        fplane.mD = beam.mPlanes[0].mD - zfar - 1.0f;  
     1264         
     1265        vector<Plane3> planes = beam.mPlanes; 
     1266        planes.push_back(fplane); 
     1267 
     1268        for (int i = 0; i < planes.size(); ++ i) 
     1269        { 
     1270                Polygon3 *poly = bbox.CrossSection(planes[i]); 
     1271                if (!poly->Valid(Limits::Small)) 
     1272                        DEL_PTR(poly); 
    12501273                 
    1251                 for (int j = 0; (j < beam.mPlanes.size()) && poly; ++ j) 
     1274                for (int j = 0; (j < planes.size()) && poly; ++ j) 
    12521275                { 
    12531276                        if (j != i) 
     
    12561279                                Polygon3 *back = new Polygon3(); 
    12571280                                 
    1258                                 poly->Split(beam.mPlanes[j], *front, *back, Limits::Small); 
     1281                                poly->Split(planes[j], *front, *back, Limits::Small); 
    12591282                                DEL_PTR(poly); 
    12601283                                DEL_PTR(front); 
     
    12691292        } 
    12701293 
    1271  
    12721294        ExportPolygons(polys); 
    12731295        CLEAR_CONTAINER(polys); 
Note: See TracChangeset for help on using the changeset viewer.