MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / addExtraDataAttribute

Method addExtraDataAttribute

dae2ma/src/DAE2MABaseImporter.cpp:435–473  ·  view source on GitHub ↗

-----------------------------------

Source from the content-addressed store, hash-verified

433
434 // -----------------------------------
435 void BaseImporter::addExtraDataAttribute ( const ExtraTreeElement* extraTreeElement )
436 {
437 FILE* file = getDocumentImporter ()->getFile ();
438
439 // Get the child attributes.
440 const std::map<String, ExtraTreeElement*>& children = extraTreeElement->getChildren ();
441 size_t numChildren = children.size ();
442
443 // Create the flags.
444 std::vector<MayaDM::AttributeFlag> attributeFlags;
445 if ( extraTreeElement->getValue ().empty () )
446 {
447 // Create a compound attribute for the knot element.
448 attributeFlags.push_back ( MayaDM::AttributeFlag ( ATTRIBUTE_ATTRIBUTE_TYPE, ATTRIBUTE_TYPE_COMPOUND, false ) );
449 attributeFlags.push_back ( MayaDM::AttributeFlag ( ATTRIBUTE_NUMBER_OF_CHILDREN, COLLADABU::Utils::toString ( numChildren ), false ) );
450 }
451 else
452 {
453 // Create a normal attribute for the current leaf element.
454 attributeFlags.push_back ( MayaDM::AttributeFlag ( ATTRIBUTE_DATA_TYPE, ATTRIBUTE_TYPE_STRING ) );
455 }
456
457 // Get the parent element if it exist and set it into the current tree element.
458 const ExtraTreeElement* parentExtraElement = extraTreeElement->getParent ();
459 if ( parentExtraElement )
460 attributeFlags.push_back ( MayaDM::AttributeFlag ( ATTRIBUTE_PARENT, parentExtraElement->getName (), false ) );
461
462 // Add the current extra tree element.
463 attributeFlags.push_back ( MayaDM::AttributeFlag ( ATTRIBUTE_HIDDEN, "true", false ) );
464 MayaDM::addAttr ( file, extraTreeElement->getName (), attributeFlags );
465
466 // Recursive call.
467 std::map<String, ExtraTreeElement*>::const_iterator it = children.begin ();
468 while ( it != children.end () )
469 {
470 addExtraDataAttribute ( it->second );
471 ++it;
472 }
473 }
474
475 // -----------------------------------
476 void BaseImporter::setExtraDataAttributes (

Callers

nothing calls this directly

Calls 12

AttributeFlagClass · 0.85
addAttrFunction · 0.85
getChildrenMethod · 0.80
getFileMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
getValueMethod · 0.45
push_backMethod · 0.45
getParentMethod · 0.45
getNameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected