--------------------------------------------
| 1073 | |
| 1074 | // -------------------------------------------- |
| 1075 | void GeometryImporter::createGroupNodes ( |
| 1076 | const COLLADAFW::Mesh* mesh, |
| 1077 | size_t& geometryInstanceIndex, |
| 1078 | const COLLADAFW::UniqueId& transformId, |
| 1079 | const size_t numNodeInstances, |
| 1080 | const COLLADAFW::UniqueId& controllerId /*= COLLADAFW::UniqueId ()*/ ) |
| 1081 | { |
| 1082 | // This method is called for every geometry instance. |
| 1083 | |
| 1084 | // The maya ascii file. |
| 1085 | FILE* file = getDocumentImporter ()->getFile (); |
| 1086 | |
| 1087 | // Get the unique id of the current geometry. |
| 1088 | const COLLADAFW::UniqueId& geometryId = mesh->getUniqueId (); |
| 1089 | |
| 1090 | // Look for a list of componentLists of the current geometry. |
| 1091 | const std::vector<MayaDM::componentList>* componentLists = findComponentLists ( geometryId ); |
| 1092 | size_t componentListsCount = 0; |
| 1093 | if ( componentLists ) componentListsCount = componentLists->size (); |
| 1094 | |
| 1095 | // Create a group for every mesh primitive of every instanciated geometry |
| 1096 | // and every transform instance, which has a reference to the geometry. |
| 1097 | VisualSceneImporter* visualSceneImporter = getDocumentImporter ()->getVisualSceneImporter (); |
| 1098 | |
| 1099 | // Get the number of transform node instances. |
| 1100 | size_t numTransformInstances = visualSceneImporter->getNumTransformInstances ( transformId ); |
| 1101 | |
| 1102 | // Iterate over the instances and create the group nodes. |
| 1103 | for ( size_t transformInstanceIndex=0; transformInstanceIndex<numTransformInstances; ++transformInstanceIndex ) |
| 1104 | { |
| 1105 | // We have to go through every mesh primitive. |
| 1106 | const COLLADAFW::MeshPrimitiveArray& meshPrimitives = mesh->getMeshPrimitives (); |
| 1107 | size_t meshPrimitivesCount = meshPrimitives.getCount (); |
| 1108 | |
| 1109 | // We don't need to create groups if we just have one primitive. |
| 1110 | if ( meshPrimitivesCount <= 1 ) return; |
| 1111 | if ( meshPrimitivesCount != componentListsCount ) |
| 1112 | { |
| 1113 | std::cerr << "No component lists generated for the current geometry's primitives!" << std::endl; |
| 1114 | return; |
| 1115 | } |
| 1116 | |
| 1117 | // Create a group for every primitive. |
| 1118 | for ( size_t primitiveIndex=0; primitiveIndex<meshPrimitivesCount; ++primitiveIndex ) |
| 1119 | { |
| 1120 | // Get the current mesh primitive shader id |
| 1121 | const COLLADAFW::MeshPrimitive* meshPrimitive = meshPrimitives [primitiveIndex]; |
| 1122 | const COLLADAFW::MaterialId shadingEngineId = meshPrimitive->getMaterialId (); |
| 1123 | |
| 1124 | // Assign the group to the unique geometry id, the transform node |
| 1125 | // to the mesh instance and the index of the geometry's primitives. |
| 1126 | ShadingBinding shadingBinding ( geometryId, transformId, shadingEngineId, controllerId ); |
| 1127 | shadingBinding.setNumInstances ( numNodeInstances ); |
| 1128 | shadingBinding.setInstanceIndex ( geometryInstanceIndex ); |
| 1129 | |
| 1130 | // Create the maya groupId object |
| 1131 | String groupName = generateUniqueDependNodeName ( GROUP_ID_NAME, true, true ); |
| 1132 | MayaDM::GroupId groupId ( file, groupName ); |
nothing calls this directly
no test coverage detected