Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10307 in orxonox.OLD for branches/mount_points


Ignore:
Timestamp:
Jan 23, 2007, 10:36:12 PM (18 years ago)
Author:
patrick
Message:

new mount point interpretation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/mount_points/src/lib/graphics/importer/static_model.cc

    r10304 r10307  
    119119
    120120    // now check if it is a mount point identifier
    121     if( (*groupIt)._faces.size() != 6)
     121    if( (*groupIt)._faces.size() != 9)
    122122    {
    123123      PRINTF(1)("the face count of %s is wrong, perhaps you missnamed this object or used the wrong mount point object (got %i faces)\n",
     
    125125    }
    126126
    127     // now extract the direction from the length:
     127    // now iterate through all faces
    128128    std::vector<StaticModelData::Face>::const_iterator faceIt = (*groupIt)._faces.begin();
    129129    for( ; faceIt < (*groupIt)._faces.end(); faceIt++)
    130130    {
    131       // now go through all modelfaceelements
    132       std::vector<StaticModelData::FaceElement>::const_iterator faceElementIt = (*faceIt)._elements.begin();
    133       for( ; faceElementIt < (*faceIt)._elements.end(); faceElementIt++)
     131      if( (*faceIt)._elements.size() == 3)
    134132      {
    135         int vert = (*faceElementIt).vertexNumber;
    136         vertices.push_back(Vector(this->data->getVertices()[vert*3],
    137                                   this->data->getVertices()[vert*3 + 1],
    138                                   this->data->getVertices()[vert*3 + 2]));
     133        printf("got triangle\n");
    139134      }
    140135    }
    141136
    142     // vertex with the max surrounding faces is the up-point (pyramid like object)
    143     std::vector<Vector>::const_iterator it = vertices.begin();
    144     Vector tmpPoint;
    145     int tmpCount;
    146     Vector up;
    147     int maxCount = 0;
    148     for( ; it < vertices.end(); it++)
    149     {
    150       tmpCount = 0;
    151       tmpPoint = (*it);
    152       //
    153       std::vector<Vector>::const_iterator it2 = vertices.begin();
    154       for( ; it2 < vertices.end(); it2++)
    155         if( tmpPoint == *it2)
    156           tmpCount++;
    157 
    158       // if this is the vertex with the most surrounding vertices
    159       if( tmpCount > maxCount)
    160       {
    161         up = tmpPoint;
    162         maxCount = tmpCount;
    163       }
    164     }
    165 
    166     Vector forward;
    167     Vector side1 = vertices[0] - vertices[1];
    168     Vector side2 = vertices[1] - vertices[2];
    169     Vector side3 = vertices[2] - vertices[3];
    170 
    171     if( fabs(side1.len()) > fabs(side2.len()) && fabs(side1.len()) > fabs(side3.len()))
    172       forward = side1;
    173     else if( fabs(side2.len()) > fabs(side1.len()) && fabs(side2.len()) > fabs(side3.len()))
    174       forward = side2;
    175     else if( fabs(side3.len()) > fabs(side1.len()) && fabs(side3.len()) > fabs(side2.len()))
    176       forward = side3;
    177 
    178 
    179     // now get the center of the object
    180     Vector center;
    181     it = vertices.begin();
    182     for( ; it < vertices.end(); it++)
    183       center += (*it);
    184     // scale
    185     center /= vertices.size();
    186 
    187     //     PRINTF(0)("Up Point\n");
    188     //     up.debug();
    189     //
    190     //     PRINTF(0)("Center\n");
    191     //     center.debug();
    192     //
    193     //     PRINTF(0)("Forward\n");
    194     //     forward.debug();
    195 
    196137    // now add the mount point
    197     this->addMountPoint( up, forward, center, groupName);
     138//     this->addMountPoint( up, forward, center, groupName);
    198139  }
    199140}
Note: See TracChangeset for help on using the changeset viewer.