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

How to find vector of direction object is facing and connect it to another node?

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
1934 Views, 3 Replies

How to find vector of direction object is facing and connect it to another node?

I'm a programmer writing a custom shader for Maya. One of the inputs to this shader is a vector that represents the direction of gravity.

What I would like to do is create a nurbs curve object to represent the force of gravity. I would then find the vector of the object that coresponds to its z axis in world space. I'd then multiply this vector by the strength of gravity and connect it to the input gravity attribute on my custom shader.

This sounds like the sort of thing Maya should handle, but I can't figure out how to do it. Can I do this with the default shader network nodes Maya ships with, or do I have to do some custom programming?
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Not sure, why you want to use Z vector instead of Y but:

-create vectorProduct node;
-connect your curve worldMatrix attribute to vectorProduct.matrix
-set first inVector to 0,0,1
-set operation to Vector Matrix Product

vectorProduct.output will return desired vector in world space

if you want to get this vector in camera space then you still can do this with nodes (probably it is better to script/code this part). You can use different methods for example dot product or matrix conversion. Lets use the second:

-create pointMatrixMult node
-connect vectorProduct.output to pointMatrixMult.inPoint
-connect your camera.worldInverceMatrix to pointMatrixMult.inMatrix
-now we can normalize this result vector using another vectorProduct node
-connect pointMatrixMult.output to second vectorProduct.input1
-connect camera.worldMatrix to second vectorProduct.matrix
-set operation to Vector Matrix Product
-turn on normalize vector

this one should work in theory, still I think it is better not to do it in graph editor.
Message 3 of 4
Anonymous
in reply to: Anonymous

Thanks. That worked perfectly.
Message 4 of 4
wynandlens
in reply to: Anonymous

Dude! That works great! Thank you very much 🙂

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report