| 319 | } |
| 320 | |
| 321 | void ObjLoader::load() const |
| 322 | { |
| 323 | if( mOutputCached ) |
| 324 | return; |
| 325 | |
| 326 | mOutputVertices.clear(); |
| 327 | mOutputNormals.clear(); |
| 328 | mOutputTexCoords.clear(); |
| 329 | mOutputColors.clear(); |
| 330 | mOutputIndices.clear(); |
| 331 | |
| 332 | bool hasGroupIndex = ( mGroupIndex != numeric_limits<size_t>::max() ); |
| 333 | |
| 334 | bool texCoords; |
| 335 | if( hasGroupIndex ) { |
| 336 | texCoords = mGroups[mGroupIndex].mHasTexCoords; |
| 337 | } |
| 338 | else { |
| 339 | texCoords = false; |
| 340 | for( vector<Group>::const_iterator groupIt = mGroups.begin(); groupIt != mGroups.end(); ++groupIt ) { |
| 341 | if( groupIt->mHasTexCoords ) { |
| 342 | texCoords = true; |
| 343 | break; |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | bool normals; |
| 349 | if( hasGroupIndex ) { |
| 350 | normals = mGroups[mGroupIndex].mHasNormals; |
| 351 | } |
| 352 | else { |
| 353 | normals = false; |
| 354 | for( vector<Group>::const_iterator groupIt = mGroups.begin(); groupIt != mGroups.end(); ++groupIt ) { |
| 355 | if( groupIt->mHasNormals ) { |
| 356 | normals = true; |
| 357 | break; |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | if( normals && texCoords ) { |
| 363 | if( hasGroupIndex ) { |
| 364 | map<VertexTriple,int> uniqueVerts; |
| 365 | loadGroupNormalsTextures( mGroups[mGroupIndex], uniqueVerts ); |
| 366 | } |
| 367 | else { |
| 368 | map<VertexTriple,int> uniqueVerts; |
| 369 | for( vector<Group>::const_iterator groupIt = mGroups.begin(); groupIt != mGroups.end(); ++groupIt ) |
| 370 | loadGroupNormalsTextures( *groupIt, uniqueVerts ); |
| 371 | } |
| 372 | } |
| 373 | else if( normals ) { |
| 374 | if( hasGroupIndex ) { |
| 375 | map<VertexPair,int> uniqueVerts; |
| 376 | loadGroupNormals( mGroups[mGroupIndex], uniqueVerts ); |
| 377 | } |
| 378 | else { |