Ignore:
Timestamp:
02/21/06 09:51:03 (18 years ago)
Author:
mattausch
Message:

added switch for loading polys as meshes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r657 r658  
    9090X3dParseHandlers::EndShape() 
    9191{ 
    92   if (mCurrentMesh->mFaces.size()) { 
    93     mCurrentMesh->Preprocess(); 
    94     // make an instance of this mesh 
    95     MeshInstance *mi = new MeshInstance(mCurrentMesh); 
    96     mCurrentNode->mGeometry.push_back(mi); 
    97         // set the object id to a unique value 
    98         //mi->SetId(mCurrentObjectId ++); 
    99   } else { 
    100     cout<<"X"; 
    101     delete mCurrentMesh; 
    102   } 
    103   mCurrentMesh = NULL; 
    104 } 
    105  
     92        if (mLoadPolygonsAsMeshes) 
     93        { 
     94                vector<VertexIndexContainer>::const_iterator it, it_end = mCurrentVertexIndices.end(); 
     95 
     96                for (it = mCurrentVertexIndices.begin(); it != it_end; ++ it) 
     97                { 
     98                        // only one face per mesh 
     99                        Mesh *mesh = new Mesh(); 
     100 
     101                        // add vertices 
     102                        for (int i = 0; i < (int)(*it).size(); ++ i) 
     103                        { 
     104                                mesh->mVertices.push_back(mCurrentVertices[(*it)[i]]); 
     105                                 
     106                        } 
     107                         
     108                        mesh->mFaces.push_back(new Face(0,1,2)); 
     109                        mesh->Preprocess(); 
     110                        // make an instance of this mesh 
     111                        MeshInstance *mi = new MeshInstance(mesh); 
     112                        mCurrentNode->mGeometry.push_back(mi); 
     113 
     114                } 
     115 
     116                delete mCurrentMesh; 
     117                mCurrentVertices.clear(); 
     118                mCurrentVertexIndices.clear(); 
     119        } 
     120        else 
     121        { 
     122  
     123                if (mCurrentMesh->mFaces.size())  
     124                { 
     125                        mCurrentMesh->Preprocess(); 
     126                        // make an instance of this mesh 
     127                        MeshInstance *mi = new MeshInstance(mCurrentMesh); 
     128                        mCurrentNode->mGeometry.push_back(mi); 
     129                        // set the object id to a unique value 
     130                        //mi->SetId(mCurrentObjectId ++); 
     131                }  
     132                else  
     133                { 
     134                        cout<<"X"; 
     135                        delete mCurrentMesh; 
     136                } 
     137                mCurrentMesh = NULL; 
     138        } 
     139} 
    106140void 
    107141X3dParseHandlers::StartIndexedFaceSet( 
     
    126160                  Face *face = new Face(vertices); 
    127161 
    128                    mCurrentMesh->mFaces.push_back(face); 
    129  
    130                    // every polygon is a mesh => store in mesh instance and create new mesh 
    131                   if (mLoadPolygonsAsMeshes) 
    132                   { 
    133                           mCurrentMesh->Preprocess(); 
    134  
    135                           // make an instance of this mesh 
    136                           MeshInstance *mi = new MeshInstance(mCurrentMesh); 
    137                           mCurrentNode->mGeometry.push_back(mi); 
    138  
    139                           mCurrentMesh = new Mesh(); 
    140                   } 
    141  
     162                   if (!mLoadPolygonsAsMeshes) 
     163                   { 
     164                           mCurrentMesh->mFaces.push_back(face); 
     165                   } 
     166                   else 
     167                   // every polygon is a mesh 
     168                   { 
     169                           mCurrentVertexIndices.push_back(vertices); 
     170                   } 
    142171          } 
     172 
    143173          vertices.clear(); 
    144174          if (ptr == endptr) 
     
    223253                                vertices.push_back(v); 
    224254                        } 
    225                         mCurrentMesh->mVertices = vertices; 
     255                        if (mLoadPolygonsAsMeshes) 
     256                        { 
     257                                mCurrentVertices = vertices; 
     258                        } 
     259                        else 
     260                        { 
     261                                mCurrentMesh->mVertices = vertices; 
     262                        } 
    226263                } 
    227264        } 
     
    243280  if (element == "Shape") { 
    244281    cout<<"+"; 
    245     mCurrentMesh = new Mesh; 
     282        mCurrentMesh = new Mesh; 
    246283  } 
    247284   
Note: See TracChangeset for help on using the changeset viewer.