Rob,

You got me down the correct path. I had to use
o3D.transform.matrix3D
instead of the
o3D.sceneMatrix3D

Also had to apply the rotation transfor for the inner object. I did
not have to apply the rotations to the outer object. Also... this is
the confusing part but it works.. please note that I had to use
"rotationZ" for Y_AXIS and the "rotationY" for the "Z_AXIS. Either
way.. this following bit of code works.

Test setup: Create an ObjectContainer3D and add it to the view.scene.
Create or load another object and put into the above
ObjectContainer3D.
Now rotate the inner most object: RotationX = 90; RotationZ = 45;
Now rotate the outer object that contains it: RotationY = 20;


public function Global3DtoLocal3D(GlobalVector3D:Vector3D,
o3D:Object3D):Vector3D
{
var localVect:Vector3D;
var parent:Object3D = o3D.parent as Object3D;

// inner Object3D matrix3D (this is inside an ObjectContainer3D)
var matrix:Matrix3D = o3D.transform.matrix3D.clone();

// apply rotations.... append() does not seem to do that on the inner
object
matrix.appendRotation(-o3D.rotationX,Vector3D.X_AXIS);
matrix.appendRotation(-o3D.rotationZ,Vector3D.Y_AXIS);
matrix.appendRotation(-o3D.rotationY,Vector3D.Z_AXIS);

// outer Object3D matrix3D (this is inside the view.scene)
var matrix2:Matrix3D = parent.transform.matrix3D.clone();



// multiply the two matrix together
matrix.append(matrix2);
// invert the result
matrix.invert();

// transform the Global3D to Local3D
localVect = matrix.transformVector(GlobalVector3D);
return localVect;
}

On Oct 31, 5:38 pm, mogg <[email protected]> wrote:
> Rob,
>
> Thank you! The spheres are now showing at the correct location! When I
> use the "Away3D/trunk/fp10/Away3DLite/" source.
>
> But.. when I use the "Away3D/branches/lite/libs" the spheres DO NOT
> show up at the correct location and the rendering/camera are all
> different. Whatever you did recently has fixed a  number of issues.
> Thank you again!
>
> YOUDAMAN!
>
> On Oct 31, 5:11 pm, mogg <[email protected]> wrote:
>
>
>
> > Rod, Thank you! The Away3Dlite scene coordinates were not working
> > correctly for me before. To test I would add a sphere to the
> > view.scene at the returned mouse3d scene position but the sphere would
> > apear at strange locations... never under the mouse cursor in 3D
> > space. I will update and try again along with your global to local
> > code. Again, Thank you.
>
> > On Oct 30, 8:47 am, Rob Bateman <[email protected]> wrote:
>
> > > Hey mogg
>
> > > the sceneX, sceneY and sceneZ properties from the mouse event are
> > > essentially global coordinates. they represent the position in the
> > > scene of your mouse event. if you want to determine the position local
> > > to the object (ie the coordinate inside the cube object of the mouse
> > > event) then you can simply transform the scene coordinates into local
> > > coordinates by using the inverse of the sceneMatrix3D property in
> > > Away3dLite:
>
> > > var invSceneMatrix3D:Matrix3D = o3D.sceneMatrix3D.clone();
> > > invSceneMatrix3D.invert();
> > > var localPosition:Vector3D =
> > > invSceneMatrix3D.transformVector(event.scenePosition);
>
> > > hth!
>
> > > Rob
>
> > > On Wednesday, October 28, 2009, Philip <[email protected]> wrote:
>
> > > > I'd love to see a built in Local3D to Global3D method!- Hide quoted 
> > > > text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Reply via email to