Hey, I've been developing a plugin for maya for a game project with a team of artists/designers. It started of with may 2016 but I need to port it to maya 2017 and I ran into a seemingly unexplainable issue.
we are using the maya Houdini plugin to generate the boundingbox and the final mesh for a racetrack but when we export a scene we want to get rid of all the extra Houdini stuff. so I wrote some code that would duplicate the boundingbox, then let Houdini generate the final mesh, and then duplicate that final mesh. the two duplicates are parented under the same root transform node created using a MDagModifier. in the below code the DagNode is the root of the Houdini digital asset.
// root node that will receive the duplicates
MObject rootTransform = mod.createNode("transform"); mod.doIt(); // copy over the bounding box for (uint32_t i = 0; i < DAGnode.childCount(); i++) { // the two shape nodes MFnDagNode sourceShape(digitalAssetTransform.child(i)); duplicateBoundingBox(sourceShape, rootTransform); MDagPath path; sourceShape.getPath(path); path.extendToShape(); ignoredShapes.push_back(path.node()); } // set the houdini mesh type to generate the final mesh type.setValue(2); //copy over the final mesh for (uint32_t i = 0; i < DAGnode.childCount(); i++) { // the two shape nodes MFnDagNode sourceShape(digitalAssetTransform.child(i)); duplicateFinalMesh(sourceShape, rootTransform); MDagPath path; sourceShape.getPath(path); path.extendToShape(); ignoredShapes.push_back(path.node()); }
and here is the code for one of the duplicate functions
auto duplicateFinalMesh = [](MFnDagNode &sourceShape, MObject &parent = MObject::kNullObj) { // the target node MDagModifier mod; MFnDagNode targetShape(sourceShape.duplicate()); // add the right attributes to the shape targetShape.addAttribute(createObjectTypeAttr()); targetShape.addAttribute(createEventsAttr()); m_callbackIds.append(MNodeMessage::addAttributeChangedCallback(targetShape.object(), AttrChangedCB)); m_callbackIds.append(MNodeMessage::addAttributeAddedOrRemovedCallback(targetShape.object(), AttrAddedOrRemovedCB)); // extend the paths to the actual geometries MDagPath sourcePath; sourceShape.getPath(sourcePath); sourcePath.extendToShape(); MDagPath targetPath; targetShape.getPath(targetPath); targetPath.extendToShape(); //copy the shaders over to the new shape MoveShaders(sourcePath, targetPath); mod.reparentNode(targetShape.object(), parent); mod.doIt(); };
now, this code runs perfectly fine in maya 2016 but in maya 2017 both the boundingbox and final mesh are the same even though the code is exactly the same (all custom attributes do get duplicated correctly however). are there any suggestions on why this code behaves differently in maya 2016?
below are images of the different results.
Hey, I've been developing a plugin for maya for a game project with a team of artists/designers. It started of with may 2016 but I need to port it to maya 2017 and I ran into a seemingly unexplainable issue.
we are using the maya Houdini plugin to generate the boundingbox and the final mesh for a racetrack but when we export a scene we want to get rid of all the extra Houdini stuff. so I wrote some code that would duplicate the boundingbox, then let Houdini generate the final mesh, and then duplicate that final mesh. the two duplicates are parented under the same root transform node created using a MDagModifier. in the below code the DagNode is the root of the Houdini digital asset.
// root node that will receive the duplicates
MObject rootTransform = mod.createNode("transform"); mod.doIt(); // copy over the bounding box for (uint32_t i = 0; i < DAGnode.childCount(); i++) { // the two shape nodes MFnDagNode sourceShape(digitalAssetTransform.child(i)); duplicateBoundingBox(sourceShape, rootTransform); MDagPath path; sourceShape.getPath(path); path.extendToShape(); ignoredShapes.push_back(path.node()); } // set the houdini mesh type to generate the final mesh type.setValue(2); //copy over the final mesh for (uint32_t i = 0; i < DAGnode.childCount(); i++) { // the two shape nodes MFnDagNode sourceShape(digitalAssetTransform.child(i)); duplicateFinalMesh(sourceShape, rootTransform); MDagPath path; sourceShape.getPath(path); path.extendToShape(); ignoredShapes.push_back(path.node()); }
and here is the code for one of the duplicate functions
auto duplicateFinalMesh = [](MFnDagNode &sourceShape, MObject &parent = MObject::kNullObj) { // the target node MDagModifier mod; MFnDagNode targetShape(sourceShape.duplicate()); // add the right attributes to the shape targetShape.addAttribute(createObjectTypeAttr()); targetShape.addAttribute(createEventsAttr()); m_callbackIds.append(MNodeMessage::addAttributeChangedCallback(targetShape.object(), AttrChangedCB)); m_callbackIds.append(MNodeMessage::addAttributeAddedOrRemovedCallback(targetShape.object(), AttrAddedOrRemovedCB)); // extend the paths to the actual geometries MDagPath sourcePath; sourceShape.getPath(sourcePath); sourcePath.extendToShape(); MDagPath targetPath; targetShape.getPath(targetPath); targetPath.extendToShape(); //copy the shaders over to the new shape MoveShaders(sourcePath, targetPath); mod.reparentNode(targetShape.object(), parent); mod.doIt(); };
now, this code runs perfectly fine in maya 2016 but in maya 2017 both the boundingbox and final mesh are the same even though the code is exactly the same (all custom attributes do get duplicated correctly however). are there any suggestions on why this code behaves differently in maya 2016?
below are images of the different results.
Hi stanpepels,
Can you send us detailed samples?
I am not very clear about your description. Shouldn't it be the same after duplication?
Yours,
Li
Hi stanpepels,
Can you send us detailed samples?
I am not very clear about your description. Shouldn't it be the same after duplication?
Yours,
Li
Can't find what you're looking for? Ask the community or share your knowledge.