Ignore:
Timestamp:
02/20/06 19:06:03 (18 years ago)
Author:
mattausch
Message:

added ogre dependencies and patched ogre sources

File:
1 edited

Legend:

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

    r508 r657  
    6161//  StdInParseHandlers: Constructors and Destructor 
    6262// --------------------------------------------------------------------------- 
    63 X3dParseHandlers::X3dParseHandlers(SceneGraphNode *root) : 
     63X3dParseHandlers::X3dParseHandlers(SceneGraphNode *root, const bool loadPolygonsAsMeshes): 
    6464  mElementCount(0) 
    6565  , mAttrCount(0) 
    6666  , mCharacterCount(0) 
    6767  , mSpaceCount(0) 
    68  // , mCurrentObjectId(0) 
     68  , mLoadPolygonsAsMeshes(loadPolygonsAsMeshes) 
    6969{ 
    7070  mCurrentNode = root; 
     
    124124        if (ptr == endptr || index == -1) { 
    125125          if (vertices.size() > 2) { 
    126             Face *face = new Face(vertices); 
    127             mCurrentMesh->mFaces.push_back(face); 
     126                  Face *face = new Face(vertices); 
     127 
     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 
    128142          } 
    129143          vertices.clear(); 
     
    163177                                  AttributeList&  attributes) 
    164178{ 
    165   int len = attributes.getLength(); 
    166   int i; 
    167   VertexContainer vertices; 
    168   for (i=0; i < len; i++) { 
    169     string attrName(StrX(attributes.getName(i)).LocalForm()); 
    170     if (attrName == "point") { 
    171       StrX attrValue(attributes.getValue(i)); 
    172       const char *ptr = attrValue.LocalForm(); 
    173       char *endptr; 
    174       while(1) { 
    175         float x = (float)strtod(ptr, &endptr); 
    176         if (ptr == endptr) 
    177           break; 
    178         ptr = endptr; 
    179         float y = (float)strtod(ptr, &endptr); 
    180         if (ptr == endptr) 
    181           break; 
    182         ptr = endptr; 
    183         float z = (float)strtod(ptr, &endptr); 
    184         if (ptr == endptr) 
    185           break; 
    186         ptr = endptr; 
    187         if (*ptr == ',') 
    188           ptr++; 
    189         Vector3 v(x, y, z); 
    190         vertices.push_back(v); 
    191       } 
    192       mCurrentMesh->mVertices = vertices; 
    193     } 
    194   } 
     179        int len = attributes.getLength(); 
     180         
     181        int i; 
     182        VertexContainer vertices; 
     183         
     184        for (i=0; i < len; i++)  
     185        { 
     186                string attrName(StrX(attributes.getName(i)).LocalForm()); 
     187           
     188                if (attrName == "point")  
     189                { 
     190                        StrX attrValue(attributes.getValue(i)); 
     191                   
     192 
     193                        const char *ptr = attrValue.LocalForm(); 
     194                        char *endptr; 
     195 
     196 
     197                        while(1)  
     198                        { 
     199                                float x = (float)strtod(ptr, &endptr); 
     200                 
     201                                if (ptr == endptr) 
     202                                  break; 
     203                           
     204                                ptr = endptr; 
     205                                 
     206                                float y = (float)strtod(ptr, &endptr); 
     207                           
     208                                if (ptr == endptr) 
     209                                        break; 
     210 
     211                                ptr = endptr; 
     212                           
     213                                float z = (float)strtod(ptr, &endptr); 
     214                                if (ptr == endptr) 
     215                                        break; 
     216                           
     217                                ptr = endptr; 
     218                           
     219                                if (*ptr == ',') 
     220                                        ptr ++; 
     221 
     222                                Vector3 v(x, y, z); 
     223                                vertices.push_back(v); 
     224                        } 
     225                        mCurrentMesh->mVertices = vertices; 
     226                } 
     227        } 
    195228} 
    196229 
     
    284317bool 
    285318X3dParser::ParseFile(const string filename, 
    286                      SceneGraphNode **root) 
     319                                         SceneGraphNode **root, 
     320                                         const bool loadPolygonsAsMeshes) 
    287321{ 
    288322  // Initialize the XML4C system 
     
    317351  // 
    318352  *root = new SceneGraphNode; 
    319   X3dParseHandlers handler(*root); 
     353  X3dParseHandlers handler(*root, loadPolygonsAsMeshes); 
    320354  parser->setDocumentHandler(&handler); 
    321355  parser->setErrorHandler(&handler); 
     
    389423// --------------------------------------------------------------------------- 
    390424X3dViewCellsParseHandlers::X3dViewCellsParseHandlers(ViewCellsManager *viewCellsManager,  
    391                                                                                                          float viewCellHeight): 
     425                                                                                                         const float viewCellHeight): 
    392426mElementCount(0),  
    393427mAttrCount(0),  
Note: See TracChangeset for help on using the changeset viewer.