MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / writeObjectGroups

Method writeObjectGroups

dae2ma/src/DAE2MAGeometryImporter.cpp:1164–1237  ·  view source on GitHub ↗

--------------------------------------------

Source from the content-addressed store, hash-verified

1162
1163 // --------------------------------------------
1164 void GeometryImporter::writeObjectGroups (
1165 const COLLADAFW::Mesh* mesh,
1166 MayaDM::Mesh &meshNode,
1167 const COLLADAFW::UniqueId& transformNodeId )
1168 {
1169 // Create the object group instances and the object groups and write it into the maya file.
1170 VisualSceneImporter* visualSceneImporter = getDocumentImporter ()->getVisualSceneImporter ();
1171
1172 // setAttr -size 2 ".instObjGroups"; // for every instance
1173 // setAttr -size 2 ".instObjGroups[0].objectGroups"; // for every mesh primitive
1174 // setAttr ".instObjGroups[0].objectGroups[0].objectGrpCompList" -type "componentList" 1 "f[0:5]";
1175 // setAttr ".instObjGroups[0].objectGroups[1].objectGrpCompList" -type "componentList" 1 "f[6:11]";
1176
1177 // We have to go through every mesh primitive.
1178 const COLLADAFW::MeshPrimitiveArray& meshPrimitives = mesh->getMeshPrimitives ();
1179 size_t meshPrimitivesCount = meshPrimitives.getCount ();
1180
1181 // We don't need this, if we have just one primitive.
1182 if ( meshPrimitivesCount <= 1 ) return;
1183
1184 // For every geometry instance
1185 // For every transform instance
1186 // For every mesh primitive
1187 // addAttr (objectGrpCompList)
1188
1189 const COLLADAFW::UniqueId& geometryId = mesh->getUniqueId ();
1190 size_t globalInstanceCount = 0;
1191
1192 // Count the geometry instances.
1193 const UniqueIdVec* geometryInstanceTransformIds = visualSceneImporter->findGeometryTransformIds ( geometryId );
1194 if ( geometryInstanceTransformIds )
1195 {
1196 size_t numGeometryInstancesTransformIds = geometryInstanceTransformIds->size ();
1197 for ( size_t n=0; n<numGeometryInstancesTransformIds; ++n )
1198 {
1199 // Count the transform node instances, which have the geometry as a child.
1200 const COLLADAFW::UniqueId& currentTransformNodeId = (*geometryInstanceTransformIds) [n];
1201 size_t numTransformNodeInstances = visualSceneImporter->getNumTransformInstances ( currentTransformNodeId );
1202 globalInstanceCount += numTransformNodeInstances;
1203 }
1204 }
1205
1206 // Iterate over the mesh primitives
1207 size_t initialFaceIndex = 0;
1208 for ( size_t i=0; i<meshPrimitivesCount; ++i )
1209 {
1210 // Get the number of faces of the current primitive element.
1211 const COLLADAFW::MeshPrimitive* meshPrimitive = meshPrimitives [ i ];
1212 size_t numFaces = meshPrimitive->getFaceCount ();
1213
1214 // Create the string with the face informations for the component list.
1215 String val = "f[" + COLLADABU::Utils::toString ( initialFaceIndex )
1216 + ":" + COLLADABU::Utils::toString ( numFaces-1 + initialFaceIndex ) + "]";
1217
1218 // Create the component list.
1219 MayaDM::componentList componentList;
1220 componentList.push_back ( val );
1221

Callers

nothing calls this directly

Calls 9

getUniqueIdMethod · 0.80
setObjectGrpCompListMethod · 0.80
getCountMethod · 0.45
sizeMethod · 0.45
getFaceCountMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected