Hey Artur

the lookAt method is only supposed to work with coordinates from the object
3d's parent container. If you keep all objects in the scene container (the
root), you won't have any problems. If you are unable to do this for
whatever reason, you can use the scenePosition of any object to get the
position based on scene coordinates, and then use the inverseSceneTransform
property of the parent of the object you want to use the lookAt method on,
to transform the scenePosition into the parent coordinate system. In theory
you could construct a global lookAt method to do this automatically.
Something like:

function globalLookAt(object3d:Object3D):void
{
    var sPosition:Number3D = object3d.scenePosition;
    sPosition.transform(sPosition, parent.inverseSceneTransform);
    lookAt(sPosition);
}

let us know how you get on!

Rob


On Mon, Dec 1, 2008 at 1:10 PM, Alex Karmazin <[EMAIL PROTECTED]>wrote:

>
> I notesed grate property scenePosition just use it to get global
> position.
>
> On Nov 30, 4:26 pm, Alex Karmazin <[EMAIL PROTECTED]> wrote:
> > Here is how I see it. But this test seams not working just how it
> > should be, but it is good start for playing around with. Just put this
> > class in document class field, it works with away3d 2.2 If you managed
> > to clearly understand how it works pleas let me know.
> >
> > package
> > {
> >         import away3d.containers.*;
> >         import away3d.core.base.*;
> >         import away3d.core.math.*;
> >         import away3d.primitives.*;
> >         import flash.events.*;
> >         import flash.display.*;
> >         import flash.geom.Matrix;
> >         /**
> >          * ...
> >          * @author Alex Karmazin (NEB Group)
> >          */
> >         public class AbsolutePosTest extends MovieClip
> >         {
> >                 private var view:View3D;
> >                 private var center:Object3D;
> >                 private var testCube:Object3D;
> >                 private var controlCube:Object3D;
> >                 private var container:ObjectContainer3D;
> >
> >                 public function AbsolutePosTest() {
> >                         super();
> >                         init3DObjects();
> >                         testSubject();
> >                         stage.addEventListener(Event.ENTER_FRAME,
> enterFrame);
> >                 }
> >
> >                 private function init3DObjects() {
> >                         this.view = new View3D({x:stage.stageWidth/2,
> y:stage.stageHeight/
> > 2});
> >                         this.addChild(this.view);
> >                         center = new Cube( { x:0, y:0, z:0, width:50,
> height:50,
> > material:"red#black" } );
> >                         this.view.scene.addChild(center);
> >                         this.view.camera.position = new Number3D(0, 500,
> 1000);
> >                         this.view.camera.lookAt(center.position);
> >                 }
> >
> >                 private function testSubject() {
> >                         this.container = new ObjectContainer3D( { x:0,
> y:0, z:0 } );
> >                         this.view.scene.addChild(this.container);
> >                         this.testCube = new Cube( { x:200, y:0, z:0,
> width:50, height:50,
> > material:"blue#black" } );
> >                         this.controlCube = new Cube( { x:200, y:0, z:0,
> width:50, height:
> > 50, material:"green#black" } );
> >                         this.testCube.addOnMouseDown(testClick);
> >                         this.controlCube.addOnMouseDown(controlClick);
> >                         this.container.addChild(this.testCube);
> >                         this.view.scene.addChild(this.controlCube);
> >                         this.container.rotationY += 90;
> >                 }
> >
> >                 public function testClick(e) {
> >                         trace("blue....................");
> >                         localToGlobal3D(testCube.transform);
> >                         trace("local_________________");
> >                         trace("x:"+testCube.x + " y:" + testCube.y + "
> z:" + testCube.z);
> >                 }
> >
> >                 public function controlClick(e) {
> >                         trace("green....................");
> >                         trace("global_________________");
> >                         trace("x:"+controlCube.x + " y:" + controlCube.y
> + " z:" +
> > controlCube.z);
> >                         globalToLocal3D(controlCube.transform);
> >                 }
> >
> >                 public function localToGlobal3D(t:Matrix3D) {
> >                         var m:Matrix3D = new Matrix3D();
> >                         m.multiply4x4(this.container.transform, t);
> >                         trace("global_________________");
> >                         trace("x:"+m.tx + " y:" + m.ty + " z:" + m.tz);
> >                 }
> >                 public function globalToLocal3D(t:Matrix3D) {
> >                         var m:Matrix3D = new Matrix3D();
> >                         m.multiply4x4(this.container.transform, t);
> >                         trace("local_________________");
> >                         trace("x:"+m.tx + " y:" + m.ty + " z:" + m.tz);
> >                 }
> >
> >                 private function enterFrame(e:Event) {
> >                         this.view.render();
> >                 }
> >
> >         }
> >
> > }
> >
> > On Nov 27, 12:01 am, artur <[EMAIL PROTECTED]> wrote:
> >
> > > Alex
> >
> > > Thank so much for answer , can you show me and example of how use the
> > > second technique?
> > > I m not very familiarized with transform between 3dobjects. I trying
> > > to implement the first one but I m really interested in the second
> > > one.
> >
> > > Tks in advance.
> >
> > > Artur
> >
> > > On Nov 26, 8:25 am, Alex Karmazin <[EMAIL PROTECTED]> wrote:
> >
> > > > I had the same problem, so I put extra Object3D near container and
> > > > start rotating container. On every frame I test condition if
> > > > (curent.distanceTo(frontPos) < 7.5)
> > > > where curent is my Object3D that must be facing to the camera and
> > > > frontPos is "flag" Object3D that I placed in front of camera. When
> > > > condition triggers I use extra method to rotate container on proper
> > > > degree, usually it is very small, but I need exactly correct angle.
> So
> > > > for me it works perfect. Another way is to multiplying transform of
> > > > each container to the point coordinates and you will get absolute
> > > > position but I didn't use this method yet.
> >
> > > > On Nov 26, 12:00 am, artur <[EMAIL PROTECTED]> wrote:
> >
> > > > > Hello
> >
> > > > > There is my problem I ll do my best to try explain it:
> >
> > > > > I loading a 3ds in a ObjectContainer3D( BigContainer) so I rotate
> the
> > > > > container to make a 360 view, now the next step is load little 3ds
> > > > > pieces in littles ObjectContainer3D containers, positioning them
> over
> > > > > the bigContainer or at least that is the idea, the little ones 3ds
> > > > > should be look at to the normal of the point where they were added,
> > > > > but they are rotating in crazy ways, I tried to do a lookat camera
> > > > > postion but is not working, I was looking and noticed all
> > > > > ObjectContainer3D has his own local Coords so that would explain
> the
> > > > > weird behaviors, there is a decent way to do this?,basically put
> the
> > > > > face of my loaded models pointing to the normal of the face of the
> big
> > > > > model where was located?, I hope you can bring a light on my day
> >
> > > > > Thanks so much in advance.
> >
> > > > > Artur.
>



-- 
Rob Bateman
Flash Development & Consultancy

[EMAIL PROTECTED]
www.infiniteturtles.co.uk
www.away3d.com

Reply via email to