Friday, 18 January 2013

It's amazing what you can access in the hypershade

Not found a use for this yet but someone might......

Found a way to access the tangent of the curve at a given edit point. I'm sure there might be another way but it goes to show that it is possible to access all kinds of things and by having a little play and looking at how things connect.

Draw a CV curve (quadratic)
Get a locator

Open either the node editor or the hypershade (I'll be using the node editor)

In the attribute editor turn on the Disp EP in the component display so that you can see the edit points.

If you expand the curve shape in the node editor you will only see one edit point, this is a glitch in maya. To be able to access other edit points all you need to do is connect the output of the edit point to something (such as the translate of the locator) and another one will appear. Bear in mind it will add access to another edit point each time you connect the last available edit point, even if there are not any more edit points on the curve. e.g. I have 4 edit points but when I connect something to edit point [3]; the last one. I get access to edit point [4] which doesn't exist on the curve, another glitch.

Connect the curve shape -edit point[1] to the transform of the locator. In the viewport you will see the locator is now snapped to the edit point.

Now to access the tangent at that point we need another node. In the mel script box (bottom left) type
createNode motionPath
This is the same node created if you are animating an object along a path.

 You'll need the connection editor for the next bit as the connections you need are not in the node editor.
Connect the world space of the curve shape to the geometry path of the motion path node.

Then to apply the tangent to the locator, connect the rotate from the motion path to the rotate of the locator.

In the attribute editor have a look at the motion path node.
The u-value lets you decide the tangent that you want (each edit point has a whole number value starting at 0) in my case I have my locator tied to the second edit point so I set the u value to 1. You can also use these attributes to decide which axis to point down the tangent.
If you want more than one tangent you will need a  motion path node for each one.

As I say not got a use for this but when I do I will have forgotten how I did it so thought I would throw it up here.
Final setup.