Thank you both for your suggestions.
Yes i want to do something similar to katopz example.

The difference is, that i got an fixed Camera3D at -z without any
rotation applied and
a Scene3D rotated around multiple axes.
What i try to get are the local XY coordinates from an infinite sized
mathematical Plane at 0,0,0 that matches the orientation of the Scene.
I´ve tried to find the Solution with the help of Katopz classes but
got no success.

package
{
        import away3dlite.cameras.Camera3D;
        import away3dlite.containers.ObjectContainer3D;
        import away3dlite.containers.Scene3D;
        import away3dlite.materials.*;
        import away3dlite.primitives.*;
        import away3dlite.templates.*;
        import flash.events.Event;
        import flash.geom.Matrix3D;
        import flash.geom.Point;

        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.geom.Vector3D;
        import flash.geom.Orientation3D;
        import flash.geom.Utils3D;

        import jiglib.math.JMath3D;

        public class ExMousecontrol extends FastTemplate
        {
                private var container:ObjectContainer3D = new 
ObjectContainer3D();

                private var mouseObject:Plane = new Plane(new ColorMaterial
(0xFF9900), 100, 100, 1, 1);
                private var referencePlane:Plane = new Plane(new 
WireframeMaterial
(0xFFFFFF, 0.5), 1000, 1000, 10, 10);
                private var jMath3DPlane:Vector3D;

                protected override function onInit():void
                {
                        view.camera = new Camera3D();
                        view.camera.zoom = 4;
                        view.camera.z = -1000;

                        referencePlane.bothsides = true;

                        mouseObject.bothsides = true;
                        mouseObject.width = 100;
                        mouseObject.height = 100;

                        scene.rotationX = 45;
                        scene.rotationY = 45;

                        container.addChild(mouseObject);

                        container.addChild(referencePlane);
                        scene.addChild(container);

                        var _sceneNormal:Vector3D = getNormal(scene);
                        jMath3DPlane = JMath3D.fromNormalAndPoint(_sceneNormal, 
new Vector3D
(0,0,0));

                        stage.addEventListener(MouseEvent.MOUSE_MOVE, 
handleMouseMove);
                }

                private function getNormal(object3D:Scene3D):Vector3D{
                        /*var p1:Point = object3D.local3DToGlobal(new 
Vector3D(0,0,0));
                        var p2:Point = object3D.local3DToGlobal(new 
Vector3D(100,0,0));
                        var p3:Point = object3D.local3DToGlobal(new 
Vector3D(0,100,0));

                        var edge1:Vector3D = new Vector3D(p1.x - p2.x, p1.y - 
p2.y, 0);
                        var edge3:Vector3D = new Vector3D(p1.x - p3.x, p1.y - 
p3.y, 0);*/

                        var _matrix:Matrix3D = new Matrix3D();
                        _matrix.rawData = view.scene.transform.matrix3D.rawData;
                        //_matrix.append(view.camera.viewMatrix3D);

                        var p1:Vector3D = _matrix.transformVector(new 
Vector3D(0,0,0));
                        var p2:Vector3D = _matrix.transformVector(new 
Vector3D(100,0,0));
                        var p3:Vector3D = _matrix.transformVector(new 
Vector3D(0,100,0));

                        var edge1:Vector3D = new Vector3D(p1.x - p2.x, p1.y - 
p2.y, p1.z -
p2.z);
                        var edge3:Vector3D = new Vector3D(p1.x - p3.x, p1.y - 
p3.y, p1.z -
p3.z);

                        var _normal:Vector3D = edge3.crossProduct(edge1);
                        _normal.normalize();

                        trace(_normal);
                        return _normal;
                };

                private function screenToWorld(_x:Number, _y:Number):Vector3D{
                        var ray:Vector3D = JMath3D.unproject
(view.camera.transform.matrix3D, view.camera.focus, view.camera.zoom,
_x, _y);
                        ray.add(new Vector3D(view.camera.x, view.camera.y, 
view.camera.z));

                        var intersectPoint:Vector3D = 
JMath3D.getIntersectionLine
(jMath3DPlane, view.camera.position, ray);

                        return intersectPoint;
                };

                private function handleMouseMove(event:MouseEvent):void
                {
                        var _pos:Vector3D = screenToWorld(view.mouseX, 
view.mouseY);
                        mouseObject.x = _pos.x;
                        //mouseObject.y = _pos.z;
                        mouseObject.z = _pos.y;
                        //trace(_pos.x);
                }
        }
}


On Oct 21, 6:08 am, katopz <[email protected]> wrote:
> not sure that you try to drag something on plane, or something like that?
>
> 1. here's some 
> exampleshttp://jiglibflash.googlecode.com/svn/trunk/fp10/src/jiglib/math/JMat...
>
> 2. and here how to use 
> ithttp://jiglibflash.googlecode.com/svn/trunk/fp10/examples/away3dlite/...
>
> 3. and here's 
> resulthttp://jiglibflash.googlecode.com/svn/trunk/fp10/examples/away3dlite/...
>
> hth
>
> 2009/10/21 <[email protected]>
>
>
>
> >  Hello,
>
> > does anybody know how to use the built in Flash Player 10 functions to
>
> > project mouse coords to object3d-space?
>
> > I´ve figured out how to do it from object3d-space to screen in this way:
>
> > var _objectPoint:Vector3D = new Vector3D(100, 100, 0);
>
> > var _screenCoord:Vector3D = Utils3D.projectVector(_object3D.viewMatrix3D,
> > _objectPoint);
>
> > But i dont know how to do itt the other way without MouseEvent3D.
>
> > Thanks,
>
> > Daniel
>
> --
> katopzhttp://www.sleepydesign.com

Reply via email to