JokerMartini
06-21-2011, 11:10 PM
Im trying to place the teapot which is at a [0,0,50] world position, to a plane’s local [0,0,50] space.Which the positioning part of it works. The rotation is wrong though. Its opposite.
In this example the teapot goes to the correct position, but the rotation is opposite of what it should be.
(
undo on (
clearListener()
newMatrix = $Teapot01.transform * $Plane01.transform -- Calculate offset between objects
$Teapot01.position = newMatrix.position
in coordsys (transmatrix $Teapot01.transform.pos) $Teapot01.rotation = quatToEuler newMatrix.rotation
)
)
this is the sloppy solution
(
undo on (
clearListener()
newMatrix = $Teapot01.transform * $Plane01.transform -- Calculate offset between objects
$Teapot01.position = newMatrix.position
newRotation = quatToEuler newMatrix.rotation
newRotation.x *= -1;
newRotation.y *= -1;
newRotation.z *= -1;
in coordsys $Teapot01.transform $Teapot01.rotation = newRotation
)
)
attached is the test scene.
In this example the teapot goes to the correct position, but the rotation is opposite of what it should be.
(
undo on (
clearListener()
newMatrix = $Teapot01.transform * $Plane01.transform -- Calculate offset between objects
$Teapot01.position = newMatrix.position
in coordsys (transmatrix $Teapot01.transform.pos) $Teapot01.rotation = quatToEuler newMatrix.rotation
)
)
this is the sloppy solution
(
undo on (
clearListener()
newMatrix = $Teapot01.transform * $Plane01.transform -- Calculate offset between objects
$Teapot01.position = newMatrix.position
newRotation = quatToEuler newMatrix.rotation
newRotation.x *= -1;
newRotation.y *= -1;
newRotation.z *= -1;
in coordsys $Teapot01.transform $Teapot01.rotation = newRotation
)
)
attached is the test scene.
