--------------------------------------------
| 390 | |
| 391 | // -------------------------------------------- |
| 392 | bool ControllerImporter::importSkinControllerData ( |
| 393 | const COLLADAFW::SkinControllerData* skinControllerData ) |
| 394 | { |
| 395 | // This is the second parsing. On the first parsing, we have already copied the controller. |
| 396 | if ( skinControllerData == 0 ) return false; |
| 397 | |
| 398 | // Check if the current controller is already imported. |
| 399 | const COLLADAFW::UniqueId& skinControllerDataId = skinControllerData->getUniqueId (); |
| 400 | if ( skinControllerDataExported ( skinControllerDataId ) ) return false; |
| 401 | mSkinControllerDataIds.push_back ( skinControllerDataId ); |
| 402 | |
| 403 | // Get the current maya file. |
| 404 | FILE* file = getDocumentImporter ()->getFile (); |
| 405 | |
| 406 | // Get all controller objects, which use the current skinControllerData. |
| 407 | // We have to create the skinController data for every skinController object. |
| 408 | const std::vector<COLLADAFW::SkinController*>& skinControllers = findSkinControllersByDataId ( skinControllerDataId ); |
| 409 | for ( size_t i=0; i<skinControllers.size (); ++i ) |
| 410 | { |
| 411 | // Get the current controller. |
| 412 | const COLLADAFW::SkinController* skinController = skinControllers[i]; |
| 413 | const COLLADAFW::UniqueId& controllerId = skinController->getUniqueId (); |
| 414 | |
| 415 | // Just import the skin controller elements, which are directly referenced as an |
| 416 | // instance_controller element from a transform node. |
| 417 | VisualSceneImporter* visualSceneImporter = getDocumentImporter ()->getVisualSceneImporter (); |
| 418 | const UniqueIdVec* transformIds = visualSceneImporter->findControllerTransformIds ( controllerId ); |
| 419 | if ( transformIds == 0 ) continue; |
| 420 | |
| 421 | // Create a data store object to hold all the MayaDM objects of the current controller. |
| 422 | // The objects will be needed, to make all the connections. |
| 423 | SkinClusterData* skinClusterData = new SkinClusterData (); |
| 424 | |
| 425 | // SkinCluster nodes are created during a smooth bindSkin. The purpose of the skinCluster |
| 426 | // is to store a weight per influence object for each component of each geometry that is |
| 427 | // deformed. Influence objects can be joints or any transform. |
| 428 | const String skinClusterName = createSkinCluster ( skinControllerData, *skinClusterData ); |
| 429 | if ( skinClusterName.empty () ) return false; |
| 430 | |
| 431 | // Create all maya objects, which are needed to connect a maya skinCluster to a geometry. |
| 432 | createGeometryFilterBindingObjects ( *skinClusterData, skinClusterName ); |
| 433 | |
| 434 | // Hold the controller data in a map. |
| 435 | mGeometryFilterDataMap [ controllerId ] = skinClusterData; |
| 436 | |
| 437 | // Every controller has two groupIds, which have to be connected to the geometry object |
| 438 | // groups. About this, the initial index position for connections to the geometry's |
| 439 | // object groups have to be on a later index position. |
| 440 | addControllerToObjectGroupsInitialIndex ( controllerId ); |
| 441 | |
| 442 | // Calculate the transformation of the skin cluster's transform nodes |
| 443 | const COLLADABU::Math::Matrix4& bindShapeMatrix = skinControllerData->getBindShapeMatrix (); |
| 444 | if ( !bindShapeMatrix.isIdentiy () ) |
| 445 | { |
| 446 | // Get all transformations, which reference to this skin cluster and get the transformations. |
| 447 | const UniqueIdVec* transformIdVec = visualSceneImporter->findControllerTransformIds ( controllerId ); |
| 448 | if ( transformIdVec != 0 ) |
| 449 | { |
no test coverage detected