[Papervision3D] Move camera to coordinates on a sphere

Alex Br xander_zone_ro at yahoo.com
Wed Sep 24 15:29:25 PDT 2008


Thank's alot! I understand what you've did. Hope I can make it work soon! Thank's again for the help!


alexandra gavrilova <ain.interactive at gmail.com> wrote: hi Alex,
hope this will help you, though my explanations are not comprehensive ..
 I describe the case with cylinder.

 
suppose you have a class for plane (for example MyPlane).
so define public variables in it for angle 


public class MyPlane
{
  public var angle:Number;
                 
                public function MyPlane(angleParameter:Number)
                {
                              angle = angleParameter;



}
 

and pass angle (in degrees) which you use to calculate x and z coordinates of the plane as a parameter when creating the planes.
so, when you click a plane you can get this angle.

 
also, you have to create a DisplayObject3d, which will be the target for orbiting the camera:

var targetPoint:DisplayObject3d = new DisplayObject3d();


and you need an object to tween angle for orbiting the camera (because Tweener can't tween just variables):
 var myObject:Object = new Object();
myObject.yaw = 0;



i used interactiveSceneManager for listening clicks on planes:
viewport.interactiveSceneManager.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onPlaneClick);
 

function onPlaneClick(e:InteractiveScene3DEvent):void {
  var newY:number = e.target.currentDisplayObject3D.parent.y;
   var newAngle:number = e.target.currentDisplayObject3D.parent.angle;
                if(Math.abs(myObject.yaw - newAngle)>Math.PI){
       if (newAngle < myObject.yaw) {
         myObject.yaw -= Math.PI * 2;
       } else {
        myObject.yaw += Math.PI * 2; 
        }
  }
                Tweener.addTween(myObject, { yaw:newYaw, time:2, onComplete:endOfMovement } );
                 Tweener.addTween(targetPoint, { y:newY, time:2 } );
                addEventListener(Event.ENTER_FRAME, onEnterFrame);
}


function endOfMovement():void{
               removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}





function onEnterFrame(e:Event):void {
  camera.orbit(90, camProps.yaw, true, targetPoint); 
   renderer.renderScene(scene, camera, viewport);
}


-
I didn't test this, but I hope it matters that you will understand the principles then simply use the code.
 if something isn't clear plese ask me, I'll try to explain.





ain


  








 _______________________________________________
Papervision3D mailing list
Papervision3D at osflash.org
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


       
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20080924/ea008db6/attachment-0001.html 


More information about the Papervision3D mailing list