Hi
I gonna answer myself
I found that if I scale the model the coords are not translated, so my
solution was load the model dont scale it or apply anyy tranform and
add it to an ObjectContainer3D the scale the container, seems now I
get the correct points in the 3d mouse event, now Im trying to
calculate the exact point where that face was clicked
any ideas?
ty.
cheers
Artur
On Nov 22, 12:28 am, artur <[EMAIL PROTECTED]> wrote:
> Hello
>
> Im tryng to make this example based in the turlte meshes tutorial of
> Away, basically I want to add a simple sphere in one of the vertices
> of the clicked face, I tested this technique with a simple sphere and
> adding liitle spheres on it and works, but for some reason it doest
> work well on loaded meshes, the points going anywhere, here is my code
> used for the test concept:
>
> //--------------------------------------------------------------------------------------------------
> // import containers
> import away3d.containers.*;
> // import core library
> import away3d.core.base.*;
> // import file format loaders
> import away3d.loaders.*;
> //import math objects
> import away3d.core.math.*;
> import away3d.events.MouseEvent3D;
> import away3d.core.draw.DrawTriangle;
> import away3d.primitives.Sphere;
>
> // create a 3D-viewport
> var view:View3D = new View3D({x:300, y:200});
> var _holder = new ObjectContainer3D();
> // add viewport to the stage
> addChild(view);
>
> // start mesh loading
> var loader:Object3DLoader = Obj.load("resources/turtle.obj",
> {material:"turtle_texture", name:"turtle", scaling:0.1, y:50, x:10, z:
> 10, loadersize:300,centerMeshes:false});
> // add the loader object to the scene
> loader.addOnSuccess(this.loadCompleted);
> loader.rotationX = -90;
>
> _holder.addChild(loader)
> view.scene.addChild(_holder);
>
> // position camera
> view.camera.position = new Number3D(1000, 1000, 1000);
> view.camera.lookAt(loader.position);
>
> // every frame
> addEventListener(Event.ENTER_FRAME, onEnterFrame);
>
> function onEnterFrame(event:Event):void {
>
> //_holder.rotationY = getTimer() / 100
> // rerender viewport on each frame
> view.render();
>
> }
>
> function addPiece(evt:MouseEvent3D):void{
> trace("click");
> var f:Face = (evt.drawpri as DrawTriangle).face;
>
> if(f==null) return;
>
> var fv0:Number3D = new Number3D(f.v0.x,f.v0.y,f.v0.z);
> var fv1:Number3D = new Number3D(f.v1.x,f.v1.y,f.v1.z);
> var fv2:Number3D = new Number3D(f.v2.x,f.v2.y,f.v2.z);
>
> var obj:Number3D = new Number3D();
>
> obj.x =fv0.x //*1.1;
> obj.y = fv0.y //*1.1;
> obj.z =fv0.z //*1.1;
>
> var sphere:Sphere= new Sphere({material:"blue#cyan", radius:10,
> segmentsW:5, segmentsH:5, x:obj.x, y:obj.y, z:obj.z});
>
> _holder.addChild(sphere);
>
> }
>
> function loadCompleted(evt:Event):void{
>
> loader.handle.addOnMouseDown(addPiece);
>
> }
>
> //--------------------------------------------------------------------------------------------------
>
> any Ideas?
>
> cheers
>
> artur