[SOLVED] Rotating a Model in Away3D

Software: Away3D 4.x

DodgerThud, Newbie
Posted: 26 September 2013 12:19 PM   Total Posts: 1

Here’s what i want to do:
I want to load a model (most likely .3ds) into my .swf and be able to rotate it with the mouse.
This works fine at first glance, but there’s problem, the rotations ‘switch’ over. Or to say it differently:

Imagine we have a model in the shape of a pipe. If we drag the mouse to the right, the model rotates along its X-Axis to the left, mouse to the left, X-Axis rotation to the right, moving the mouse up, Y-Axis rotation downward, mouse down, Y-Axis rotation upward.
Now, lets say we turn the pipe to the right or left, until we face the (former) ‘backside’ of the pipe, and then we move the mouse down. The model will rotate downward instead of upward.

I hope you understand what i mean with this. I’ve been looking around for a good while now and never found a satisfying solution. There was talk about quaternions, but i can’t grasp them.
Another suggestion i read somewhere is the following:
create a Matrix3D object, apply rotation on it, then multiply it with the desired Matrix3D of my 3d-Model.

I tried to do it, but the result stays the same, the directions of rotation switches depending on what side i’m facing.

private function update(e:Event):void
{
   xCalc 
= (0.3*(stage.mouseX lastMouseX));
   
yCalc = (0.3*(stage.mouseY lastMouseY));

   if(
move)
   
{
      
var objTransform:Matrix3D = new Matrix3D();

      
objTransform.prependRotation(xCalcVector3D.Y_AxisobjC.pivotPoint);
      
objTransform.prependRotation(yCalcVector3D.X_AxisobjC.pivotPoint);

      
mesh.transform multiply3DMatrices(mesh.transformobjTransform);
    
}
    lastMouseX 
stage.mouseX;
    
lastMouseY stage.mouseY;

    
view.render();
 

multiply3DMatrices simply multiplies two 4x4 Matrices together.

objC is the ObjectContainer3D that holds my model. For some reason i cannot rotate it properly, unless i manipulate the rotationX/Y/Z properties.

mesh is the mesh inside of the Model (which is very simple, a single mesh).

If I didn’t describe the problem properly enough, i can provide the (quite messy) project itself as well.

edit:
i solved it by myself somehow, here the fixed version:

private function update(e:Event):void
{
   
...

   if(
move)
   
{
      
var objTransform:Matrix3D mesh.transform;

      
objTransform.appendRotation(xCalcVector3D.Y_AxisobjC.pivotPoint);
      
objTransform.appendRotation(yCalcVector3D.X_AxisobjC.pivotPoint);

      
mesh.transform objTransform;
    
}
    
...
 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X