Ok, crisis averted, i managed to find it out myself :)

The answer:

You can get the the axis that corresponds to the global x, y, z axes
like this:

var xaxis:Number3D = _cube.transform.right;
var yaxis:Number3D = _cube.transform.up;
var zaxis:Number3D = _cube.transform.forward;

After this you put the Number3D of the axis you want in a Quaternion
object, and just determine the angle amout to rotate. Convert the quat
to a matrix, muliply that matrix with the cube's current transform
matrix, and finally apply that matrix to the cube's transform
property.

Perk



On Feb 25, 1:47 pm, perk <[email protected]> wrote:
> Hi there, i have been struggling with an issue these last days, and
> feel completely stuck. I hope someone here can point me in the right
> direction.
>
> The Scenario:
> On my scene, i have a number of cubes. Over the course of the
> application, these cubes can get rotated on all three axes
> individually. At some point i need to target a group of them and
> rotate them all along one of the global axes. Check this image to
> explain a bit better visually:
>
> http://www.perkstoveland.com/downloads/axis_orientation_fig.jpg
>
> Now these cubes will always be rotated at 90 degrees in any direction,
> so an axis of a given cube will always align with either the x, y, or
> z axis in  global space. Imagine I want to rotate both cubes in the
> figure above, on the global axis X. Cube 1 will need to rotate on its
> own x axis, since cube 1's orientation is aligned exactly to global
> space. However, Cube 2 needs to rotate on it's y axis, since cube 2's
> y axis is the axis that corresponds to the global x axis.
>
> The Question:
> How is it possible for me to calculate which axis i need to rotate a
> given cube on, when i know the cubes orientation, and the global axis
> i want to rotate it on? In other words, how do i translate the global
> axis i want to rotate the cube on, to the local axis of the cube?
>
> Any help here would be much appreciated. If something is unclear here,
> please let me know.
>
> Perk

Reply via email to