------------------------------
| 1437 | |
| 1438 | //------------------------------ |
| 1439 | void AnimationImporter::connectMorphControllers ( |
| 1440 | const COLLADAFW::UniqueId& animationListId, |
| 1441 | const COLLADAFW::AnimationList::AnimationBindings& animationBindings ) |
| 1442 | { |
| 1443 | // Get the maya file. |
| 1444 | FILE* file = getDocumentImporter ()->getFile (); |
| 1445 | |
| 1446 | // Get the node, which use this animation list. |
| 1447 | ControllerImporter* controllerImporter = getDocumentImporter ()->getControllerImporter (); |
| 1448 | const MorphAnimation* morphAnimation = controllerImporter->findMorphAnimation ( animationListId ); |
| 1449 | if ( !morphAnimation ) return; |
| 1450 | |
| 1451 | // connectAttr "animCurveTU1.output" "geom_QuadPatch01_morph1.weight[0]"; |
| 1452 | MayaDM::BlendShape blendShapeTarget = morphAnimation->getBlendShapeTarget (); |
| 1453 | |
| 1454 | // Get the animation curves of the current animated element. |
| 1455 | size_t numAnimationBindings = animationBindings.getCount (); |
| 1456 | for ( size_t i=0; i<numAnimationBindings; ++i ) |
| 1457 | { |
| 1458 | // Get the animation curve element of the current animation id. |
| 1459 | const COLLADAFW::AnimationList::AnimationBinding& animationBinding = animationBindings [i]; |
| 1460 | const COLLADAFW::UniqueId& animationId = animationBinding.animation; |
| 1461 | const std::vector<MayaDM::AnimCurve*>* animationCurves = findMayaDMAnimCurves ( animationId ); |
| 1462 | if ( animationCurves == 0 ) continue; |
| 1463 | |
| 1464 | // Get the array binding. |
| 1465 | size_t firstIndex = animationBinding.firstIndex; |
| 1466 | |
| 1467 | // Connect all animation curves of the current animation. |
| 1468 | size_t animationCurveCount = animationCurves->size (); |
| 1469 | if ( animationCurveCount > 1 ) |
| 1470 | { |
| 1471 | std::cerr << "Multiple curves on morph animation not implemented!" << std::endl; |
| 1472 | return; |
| 1473 | } |
| 1474 | for ( size_t curveIndex=0; curveIndex<animationCurveCount; ++curveIndex ) |
| 1475 | { |
| 1476 | const MayaDM::AnimCurve* animCurve = (*animationCurves) [curveIndex]; |
| 1477 | MayaDM::AnimCurveTA* animCurveTA = (MayaDM::AnimCurveTA*) animCurve; |
| 1478 | |
| 1479 | // Connect the animation curve and the current transform node. |
| 1480 | // connectAttr "pCube1_translateX.output" "pCube1.translateX"; |
| 1481 | const COLLADAFW::AnimationList::AnimationClass& animationClass = animationBinding.animationClass; |
| 1482 | switch ( animationClass ) |
| 1483 | { |
| 1484 | case COLLADAFW::AnimationList::ARRAY_ELEMENT_1D: |
| 1485 | { |
| 1486 | connectAttr ( file, animCurveTA->getOutput (), blendShapeTarget.getWeight ( firstIndex ) ); |
| 1487 | } |
| 1488 | break; |
| 1489 | default: |
| 1490 | { |
| 1491 | std::cerr << "Animation class for morph controller animation not implemented!" << std::endl; |
| 1492 | break; |
| 1493 | } |
| 1494 | } |
| 1495 | } |
| 1496 | } |
nothing calls this directly
no test coverage detected