------------------------------
| 281 | |
| 282 | //------------------------------ |
| 283 | void AnimationImporter::writeAnimationCurveByKeys ( |
| 284 | const COLLADAFW::AnimationCurve* animationCurve ) |
| 285 | { |
| 286 | // The output can have different dimensions. |
| 287 | const COLLADAFW::FloatOrDoubleArray& outputValuesArray = animationCurve->getOutputValues (); |
| 288 | size_t outDimension = animationCurve->getOutDimension (); |
| 289 | size_t numOutputValues = outputValuesArray.getValuesCount () / outDimension; |
| 290 | |
| 291 | const COLLADAFW::PhysicalDimensionArray& outPhysicalDimensions = animationCurve->getOutPhysicalDimensions (); |
| 292 | size_t outDimension2 = outPhysicalDimensions.getCount (); |
| 293 | |
| 294 | size_t keyCount = animationCurve->getKeyCount (); |
| 295 | if ( numOutputValues != keyCount || outDimension != outDimension2 ) |
| 296 | { |
| 297 | std::cerr << "Animation not valid!" << std::endl; |
| 298 | return; |
| 299 | } |
| 300 | |
| 301 | // The uniqueId of the element. |
| 302 | const COLLADAFW::UniqueId& animationId = animationCurve->getUniqueId (); |
| 303 | |
| 304 | // Create a curve for every animated element. |
| 305 | for ( size_t outputIndex=0; outputIndex<outDimension; ++outputIndex ) |
| 306 | { |
| 307 | // Make the maya name unique and manage it in all necessary lists. |
| 308 | String animationName = animationCurve->getName (); |
| 309 | if ( animationName.empty () ) animationName = ANIMATION_NAME; |
| 310 | animationName = DocumentImporter::frameworkNameToMayaName ( animationName ); |
| 311 | const ExtraDataCallbackHandler& callbackHandler = getDocumentImporter ()->getMayaIdCallbackHandler (); |
| 312 | String originalMayaId = getOriginalMayaId ( callbackHandler, animationId, COLLADASaxFWL15::HASH_ELEMENT_ANIMATION ); |
| 313 | if ( !originalMayaId.empty () ) animationName = originalMayaId; |
| 314 | animationName = generateUniqueDependNodeName ( animationName ); |
| 315 | |
| 316 | // Create the animation curve. |
| 317 | FILE* file = getDocumentImporter ()->getFile (); |
| 318 | |
| 319 | // Flag, if the values of the tangents should be normalized. |
| 320 | bool normalizeTangents = true; |
| 321 | |
| 322 | // Create the animation curve. |
| 323 | MayaDM::AnimCurve* animCurve = 0; |
| 324 | |
| 325 | const COLLADAFW::PhysicalDimension& outPhysicalDimension = outPhysicalDimensions [outputIndex]; |
| 326 | switch ( outPhysicalDimension ) |
| 327 | { |
| 328 | case COLLADAFW::PHYSICAL_DIMENSION_LENGTH: |
| 329 | { |
| 330 | animCurve = new MayaDM::AnimCurveTL ( file, animationName ); |
| 331 | animCurve->setTangentType ( TANGENT_TYPE_FIXED ); |
| 332 | setKeyTimeValues ( animationCurve, (MayaDM::AnimCurveTL*)animCurve, outputIndex ); |
| 333 | } |
| 334 | break; |
| 335 | case COLLADAFW::PHYSICAL_DIMENSION_ANGLE: |
| 336 | { |
| 337 | animCurve = new MayaDM::AnimCurveTA ( file, animationName ); |
| 338 | animCurve->setTangentType ( TANGENT_TYPE_FIXED ); |
| 339 | setKeyTimeValues ( animationCurve, (MayaDM::AnimCurveTA*)animCurve, outputIndex ); |
| 340 | normalizeTangents = false; |
nothing calls this directly
no test coverage detected