MCPcopy Create free account
hub / github.com/assimp/assimp / ConvertObjectSection

Method ConvertObjectSection

code/AssetLib/AC/ACLoader.cpp:420–775  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Converts the loaded data to the internal verbose representation

Source from the content-addressed store, hash-verified

418// ------------------------------------------------------------------------------------------------
419// Converts the loaded data to the internal verbose representation
420aiNode *AC3DImporter::ConvertObjectSection(Object &object,
421 std::vector<aiMesh *> &meshes,
422 std::vector<aiMaterial *> &outMaterials,
423 const std::vector<Material> &materials,
424 aiNode *parent) {
425 aiNode *node = new aiNode();
426 node->mParent = parent;
427 if (object.vertices.size()) {
428 if (!object.surfaces.size() || !object.numRefs) {
429 /* " An object with 7 vertices (no surfaces, no materials defined).
430 This is a good way of getting point data into AC3D.
431 The Vertex->create convex-surface/object can be used on these
432 vertices to 'wrap' a 3d shape around them "
433 (http://www.opencity.info/html/ac3dfileformat.html)
434
435 therefore: if no surfaces are defined return point data only
436 */
437
438 ASSIMP_LOG_INFO("AC3D: No surfaces defined in object definition, "
439 "a point list is returned");
440
441 meshes.push_back(new aiMesh());
442 aiMesh *mesh = meshes.back();
443
444 mesh->mNumFaces = mesh->mNumVertices = (unsigned int)object.vertices.size();
445 aiFace *faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
446 aiVector3D *verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
447
448 for (unsigned int i = 0; i < mesh->mNumVertices; ++i, ++faces, ++verts) {
449 *verts = object.vertices[i];
450 faces->mNumIndices = 1;
451 faces->mIndices = new unsigned int[1];
452 faces->mIndices[0] = i;
453 }
454
455 // use the primary material in this case. this should be the
456 // default material if all objects of the file contain points
457 // and no faces.
458 mesh->mMaterialIndex = 0;
459 outMaterials.push_back(new aiMaterial());
460 ConvertMaterial(object, materials[0], *outMaterials.back());
461 } else {
462 // need to generate one or more meshes for this object.
463 // find out how many different materials we have
464 typedef std::pair<unsigned int, unsigned int> IntPair;
465 typedef std::vector<IntPair> MatTable;
466 MatTable needMat(materials.size(), IntPair(0, 0));
467
468 std::vector<Surface>::iterator it, end = object.surfaces.end();
469 std::vector<Surface::SurfaceEntry>::iterator it2, end2;
470
471 for (it = object.surfaces.begin(); it != end; ++it) {
472 unsigned int idx = (*it).mat;
473 if (idx >= needMat.size()) {
474 ASSIMP_LOG_ERROR("AC3D: material index is out of range");
475 idx = 0;
476 }
477 if ((*it).entries.empty()) {

Callers

nothing calls this directly

Calls 13

DeadlyImportErrorFunction · 0.85
buildBacksideOfFaceFunction · 0.85
ai_snprintfFunction · 0.85
aiMatrix4x4Class · 0.85
SubdivideMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
emptyMethod · 0.45
GetTypeMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected