Surfaces reverse when animating.

Surfaces reverse when animating.

Nicholasjcorden
Explorer Explorer
362 Views
1 Reply
Message 1 of 2

Surfaces reverse when animating.

Nicholasjcorden
Explorer
Explorer

Hi all, 

 

I have created a rope using nHair. When the rope is animated the surfaces are flipped and become black. It's like when the starting point of the rope goes beyond the end point, the direction is flipped. I have seen that the direction of a curve can impact this however the problem still persists. When I reverse the direction, the rope then flips back to normal upon moving beyond that certain point. I have also tried convert the NURBS into a mesh but the same thing happens.

 

I followed the techniques in the video tutorial here: https://lesterbanks.com/2020/11/easily-create-a-dynamic-rope-in-maya/

 

I'll also add some pictures of my rope situation. 

 

If anyone can suggest what to do, I would be very grateful. 

Thanks. 

0 Likes
363 Views
1 Reply
Reply (1)
Message 2 of 2

mcw0
Advisor
Advisor

You can use your current setup as a measuring device.  Create a second rope mesh as your final mesh.  Create a blendshape from your original mesh to the second mesh.  All pretty straightforward stuff.  But how does this address your problem of reversed normals?

Here's the fun part.  Sample 2 faces at either end of your original rope.  You can use follicles to attach the locators to the rope.  The 2 faces should be directly across from each other.  Now use a plusMinusAverage node and subtract the positions of the 2 locators in world space.  Use their "worldPosition" attributes.   "worldPosition" is located on the shape node of the locator.

 

Now create a pointOnMeshInfo node and connect your original mesh to it.  Also connect the locator that is connected to the plusMinusAverage node's input3D[1] plug to the pointOnMeshInfo node's "inPosition".  Again, use the worldPosition attribute.  This will allow you to get the normal of the surface at the locator.  You will now compare the surface normal to the vector established by your locators.  Do this by calculating the dot product between the two with a vectorProduct node.  Connect the "normal" attribute of the pointOnMeshInfo node to vector1.  And connect the output of your plusMinusAverage node to vector2.  Set the operation of the vectorProduct node to "Dot Product".


Now you need 3 more nodes.  A condition node, a choice node and a polyNormal node.  Connect the outputX of the vectorProduct node to the firstTerm of the condition node.  Set the operation of the condition node to "Greater Than".  Now connect the outColorR of the condition node to the "selector" attribute of the choice node.

 

Now select the blendShape node that you created earlier.  Connect the outputGeometry attribute of the blendShape node to the polyNormal node's "inputPolymesh".  Connect the polyNormal node's output to the choice node's "input[0]".  Connect the blendShape node's "outputGeometry" to the choice node's "input[1]".  Finally, connect the choice node's output to the second rope mesh's "inMesh" attribute.  This is located on the shape node of the mesh.

 

What this does is it compares the normals of the first rope mesh to a set direction vector.  Then based on the dot product, determines whether to reverse the second rope mesh or not.  I hope I got everything right.  Just off the top of my head.  Good luck.

0 Likes