Hi guys,

I'm trying to do the good old thingy: drag some sprite (in 2d coords)
over some object3D and get it attached to the material of object3D
exactly where mouse_up happened. I don't have access to MouseEvent3d
while I have something else under the cursor, so obviously, it
involves some Matrix3D stuff but so far I can't get it to work. Must
be doing something wrong.

Scene setup:
Away3D 3.6.0 (not lite).
View.scene contains _objectContainer3D which has some transformations
applied to it.
This ObjectContainer3D contains _object3D.
I drag some sprite all over the screen, on mouse_up i kill the sprite
and make view fire MouseEvent3D.MOUSE_UP with mouseX and mouseY as
params.

Now comes the matrix stuff. Tried the following:

///// #1-2
var matrixChild:Matrix3D = _object3D.sceneTransform.clone(); // or
_object3D.transform.clone()
matrixChild.invert();
var localPosition:Vector3D = matrixChild.transformVector(new
Vector3D(event.sceneX, event.sceneY, event.sceneZ));

///// #3-4
var matrixChild:Matrix3D = _object3D.sceneTransform.clone(); // or
_object3D.transform.clone();
var matrixContainer:Matrix3D =
_objectContainer3D.sceneTransform.clone(); // or
_objectContainer3D.transform.clone()
matrixChild.append(matrixContainer);
matrixChild.invert();
var localPosition:Vector3D = matrixChild.transformVector(new
Vector3D(event.sceneX, event.sceneY, event.sceneZ));

None seems to work - with what I get for localPosition's X and Y I get
sprite attached anywhere else but what should be the globalToLocal3D
of the original 2d mouse coords.

I found a temporary workaround not involving Matrix3D but it's kind of
awkward (and it annoys me that I lose to this mighty Matrix3D stuff).
What is it that i'm doing wrong? Am I wrong treating Vector3D as just
a number in this case? Maybe i need to find intersection point between
this vector and material? It's just like pulling strings at random, i
feel i don't understand what I'm doing anymore.=(

Reply via email to