PDA

View Full Version : how to extract normal from sub-object and apply to another object's rotation?


josh3light
06-26-2006, 11:23 AM
I have a pressing issue that I need to solve... I am in the process of learning maxscript and can do some things already, but this is a little beyond me...

How can I find the normal information on either three points on a mesh or a face, and apply that to another object's rotation? Right now I'm using getvert <object> <vertex> on a position script controller to make dummies attach to a mesh's vertices. I also need them to rotate appropriately.

I tried a non-scripting solution with an unconventional use of IK and bones that worked terribly!

Additionally (which may be a separate question), when using the position script "getvert <object> <vertex>" I've tried to use the create character tool to "characterize" the mesh and scripted dummies together, but this seems to rip the system apart.

Any help is greatly appreciated!

josh3light
06-26-2006, 12:29 PM
for everyone's reference, I'll post part of the solution as I found it
I pieced this together with resources from this forum
thanks everyone

I used this on a rotation script controller on $point01 with sphere01= $sphere01 and pnt = $point01 as node variables


fn getrot a which_axis b =
(
local c = normalize (b - a)
local angle = acos (dot which_axis c)
local axis = normalize (cross which_axis c)

local out = (angleaxis angle axis) as quat
out
)
pa= getvert sphere01 209
pb= getvert sphere01 210
pc= getvert sphere01 241
pd= getvert sphere01 242

vAB=pB-pA
vAC=pC-pA
vCD=pD-pC

vectnorm= (cross vAB vAC)

a = vectnorm
b = pnt.position
q = getrot a z_axis b
inverse q

josh3light
06-26-2006, 12:37 PM
This is still not ideal as there is some odd flipping happening

basically, what I REALLY want to do is just stick a helper object on a mesh and have it really stick there, position and rotation, without parenting it to the main object

so I can spin and move and deform the main object and that helper just sticks there

any ideas?

josh3light
06-26-2006, 07:48 PM
just for the record, I'm now using the cloth modifier to solve the problem. It's a bit inefficient for just attaching one object to another, but since I'm rigging wing feathers it has the added benefit of giving them secondary movement with the simulation.

I'd still like to know how to do it with script to have full control over it though

Bobo
06-26-2006, 08:55 PM
This is still not ideal as there is some odd flipping happening

basically, what I REALLY want to do is just stick a helper object on a mesh and have it really stick there, position and rotation, without parenting it to the main object

so I can spin and move and deform the main object and that helper just sticks there

any ideas?

An Attachment controller does not do the job?

josh3light
06-26-2006, 09:10 PM
Thank you very much Bobo, I have used the attachment constraint only once before and I totally forgot about it. It will work very well in this case. I have been watching your advanced maxscript dvd lately so I guess I was thinking in an overly complicated way. :)

_stev_
06-26-2006, 09:36 PM
Have you tried using "getNormal" or "getFaceNormal"?

Bobo
06-26-2006, 09:59 PM
Thank you very much Bobo, I have used the attachment constraint only once before and I totally forgot about it. It will work very well in this case. I have been watching your advanced maxscript dvd lately so I guess I was thinking in an overly complicated way. :)

Yep, my bad! ;)
Btw, the DVD mentions the Attachment constraint in the Barycentric coordinates topics...

josh3light
06-26-2006, 10:55 PM
_stev_, I will try the getFaceNormal command soon as well.

now that the workflow issue is solved I have a lot of work to do, over 20 wings need to be animated by tomorrow :)

I've watched about half of your Advanced DVD Bobo and I need to watch it again before I watch the other half... there's so much in there

Thanks everyone!

CGTalk Moderation
06-26-2006, 10:55 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.