Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DAG node duplication issue in maya 2017

1 REPLY 1
Reply
Message 1 of 2
Anonymous
376 Views, 1 Reply

DAG node duplication issue in maya 2017

Anonymous
Not applicable

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.

 

 

1b76d523df2d102a1dc6775c36d52363.pngPasted image at 2017_05_31 04_25 PM.png

 

0 Likes

DAG node duplication issue in maya 2017

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.

 

 

1b76d523df2d102a1dc6775c36d52363.pngPasted image at 2017_05_31 04_25 PM.png

 

1 REPLY 1
Message 2 of 2
cheng_xi_li
in reply to: Anonymous

cheng_xi_li
Autodesk Support
Autodesk Support

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

0 Likes

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.

Post to forums  

Autodesk Design & Make Report