View Full Version : rotate like lookat
I have two objects.with script i want to rotate first object like lookat to secend object.
|
|
Swordslayer
06-07-2011, 02:12 PM
Hi, for Z-axis direction it's really simple:
obj.dir = target.pos - obj.pos
for the other axes, it can be illustrated for example by something like this (this is for the X-axis):
vec1 = normalize obj.transform.row1 -- X-axis vector
vec2 = normalize (target.pos - obj.pos) -- direction vector
rotate obj (quat (acos(dot vec1 vec2)) (cross vec1 vec2))
Tank you for your answer; what about this:
-----------------CodeStart---------------
A=teapot pos:[50,0,80]
B=teapot()
angles = atan2 (A.pos.x-B.pos.x) (A.pos.z-B.pos.z)
about B.pos rotate B angles y_axis
----------------CodeEnd-----------------
3dsmax lookat have a big problem and icant use it in my rig,im going to make a better and custom one,i think spline and lookat have a same problem
MatanH
06-09-2011, 08:12 AM
3dsmax lookat have a big problem and icant use it in my rig,im going to make a better and custom one,i think spline and lookat have a same problem
What problem exactly are you talking about? If I would create my own lookat I would use an expression controller and not a mxs controller because it's faster but I can't think of an idea of why to do that and not use the lookat controller.
You right,i just use mxs to create cuatom rig.but for custom lookat i use expression.one of problem with lookat is when we want to mirror it.just run this script an try to mirror it in x axis .
Obj=teapot
P=point pos:[0,0,200]
R=circle radius:50
L= obj.rotation.controller= lookat_constraint()
L.appendtarget p 100
L.target_axis=2
L.upnode_axis =1
L.stoup_axis=1
Obj.parent=p.parent=r
CGTalk Moderation
06-10-2011, 04:12 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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.