Notifications
Clear all
[Closed] .dir property of objects
Sep 24, 2010 12:05 pm
It is not clear how the .dir property of an object works.
-
I create a teapot ( in Top) and use this code to set the object’s z direction face the x axis:
XAxis = [1,0,0]
$teapot01.dir = XAxis -
I create another teapot, this time I MANUALLY rotate the object about y axis, again to make its z along xaxis.
Why are the 2 results different ? Setting it with .dir introduces another rotation about x- axis. What is going on? Is it to align the gizmo's vectors along the positive directions of the axes of the world space ?It will be very nice if someone can find time to answer this.
Thanks in advance.
venx
1 Reply
Sep 24, 2010 12:05 pm
it seems to be that when you set the .dir property, it’s actually calculating a new transform matrix internally and applying that to the object. It would be calculated like this:
zVec = [1,0,0] -- the value that you set .dir to here
xVec = normalize (cross [0,0,1] zVec) -- cross the world up axis with the z vector to get the x vector
yVec = normalize (cross zVec xVec) -- cross the z and x vectors to get the y vector
newTransform = matrix3 xVec yVec zVec obj.pos