--------------------------------------------
| 253 | |
| 254 | // -------------------------------------------- |
| 255 | const String ControllerImporter::createBlendShape ( |
| 256 | COLLADAFW::MorphController* morphController, |
| 257 | BlendShapeData& blendShapeData ) |
| 258 | { |
| 259 | // The uniqueId. |
| 260 | const COLLADAFW::UniqueId& controllerId = morphController->getUniqueId (); |
| 261 | |
| 262 | // Create a unique blend shape name. |
| 263 | String blendShapeName = morphController->getName (); |
| 264 | if ( blendShapeName.empty () ) blendShapeName = BLEND_SHAPE_NAME; |
| 265 | blendShapeName = DocumentImporter::frameworkNameToMayaName ( blendShapeName ); |
| 266 | const ExtraDataCallbackHandler& callbackHandler = getDocumentImporter ()->getMayaIdCallbackHandler (); |
| 267 | String originalMayaId = getOriginalMayaId ( callbackHandler, controllerId, COLLADASaxFWL15::HASH_ELEMENT_CONTROLLER ); |
| 268 | if ( !originalMayaId.empty () ) blendShapeName = originalMayaId; |
| 269 | blendShapeName = generateUniqueDependNodeName ( blendShapeName, true, true ); |
| 270 | |
| 271 | // Create the skin cluster |
| 272 | FILE* file = getDocumentImporter ()->getFile (); |
| 273 | MayaDM::BlendShape* blendShape = new MayaDM::BlendShape ( file, blendShapeName ); |
| 274 | blendShapeData.setBlendShape ( blendShape ); |
| 275 | |
| 276 | // Add the original id attribute. |
| 277 | String colladaId = morphController->getOriginalId (); |
| 278 | if ( !colladaId.empty () ) |
| 279 | { |
| 280 | MayaDM::addAttr ( file, COLLADA_ID_ATTRIBUTE_NAME, ATTRIBUTE_DATA_TYPE, ATTRIBUTE_TYPE_STRING ); |
| 281 | MayaDM::setAttr ( file, COLLADA_ID_ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_TYPE_STRING, colladaId ); |
| 282 | } |
| 283 | // // TODO Add the attributes for all the extra tags. |
| 284 | // setExtraData ( morphController->getExtraDataArray () ); |
| 285 | |
| 286 | // Write the weights |
| 287 | const COLLADAFW::UniqueIdArray& morphTargets = morphController->getMorphTargets (); |
| 288 | size_t numMorphTargets = morphTargets.getCount (); |
| 289 | COLLADAFW::FloatOrDoubleArray& morphWeights = morphController->getMorphWeights (); |
| 290 | size_t numMorphWeights = morphWeights.getValuesCount (); |
| 291 | if ( numMorphTargets != numMorphWeights ) |
| 292 | { |
| 293 | std::cerr << "The number of morph targets differs from the number of morph weights!" << std::endl; |
| 294 | return EMPTY_STRING; |
| 295 | } |
| 296 | |
| 297 | // Add the morph targets in the list of targets. |
| 298 | for ( size_t targetIndex=0; targetIndex<numMorphTargets; ++targetIndex ) |
| 299 | { |
| 300 | const COLLADAFW::UniqueId& morphTargetId = morphTargets [targetIndex]; |
| 301 | mMorphTargetIds [controllerId].push_back ( morphTargetId ); |
| 302 | } |
| 303 | |
| 304 | // setAttr -size 5 ".weight[0:4]" 0 1 0 0 0; |
| 305 | if ( numMorphWeights == 1 ) |
| 306 | { |
| 307 | float weight = getFloatValue ( morphWeights, 0 ); |
| 308 | blendShape->setWeight ( 0, weight ); |
| 309 | } |
| 310 | else |
| 311 | { |
| 312 | const COLLADAFW::FloatOrDoubleArray::DataType& inputDataType = morphWeights.getType (); |
nothing calls this directly
no test coverage detected