[Papervision3D] flying camera around

James Acres - AG james at anonymousgroup.com
Mon Jun 11 16:06:25 EDT 2007


Ah, I could've used the distanceTo method. That would've made more  
sense. Instead I used the modulo of planeVector (modulo is a getter  
in Number3D that returns the length of the vector).

var len:Number = planeVector.modulo + viewingDistance;

That line gets the distance of the plane from the origin (length of  
the 3d vector) and then adds a number to it. The viewingDistance is a  
variable containing the number of units I want the camera to be from  
the plane's position. I have it set to 130.

It's easier to look at it in 2D (it's the same as 3D):

Say we had a point p0 at (15, 0) and we wanted the camera c to be 5  
units away from it
(0, 0) ------------------------------------------- p0 (15, 0) -------- c


We would find the length of the point vector (modulo or perhaps  
distanceTo) - that would give us 15, and we would add the camera  
distance (viewingDistance) to it:

var cameraVectorLength = p0.modulo + 5   // 15 + 5 = 20

That would give us 20, that is the length of the vector we need for  
the camera.

Then we would normalize the p0 vector:
p0.normalize(); // now equals (1,0)

Which would give us a unit vector pointing in the same direction - in  
this case it would be (1,0)

(0, 0) --- p0 (1, 0)

We'd then multiply our p0 vector by 20, to give us the vector for the  
camera

var cameraVector = p0 * cameraVectorLength;

which would be a vector like this:
(0, 0)  
------------------------------------------------------------------ c  
(20, 0)

If we tween the camera to the the x and y of that vector and make it  
look at p0 while it's tweening, it'll be exactly 5 units from the  
point and lined up exactly with it, angle and all.

Hope that helps, it's hard to explain by email!

James


On 11-Jun-07, at 3:44 PM, John Grden wrote:

> is viewDistance using the distanceTo() method?
>
> On 6/11/07, James Acres - AG <james at anonymousgroup.com> wrote:
> Hi John,
>
> I worked on something exactly like that last week ;) It turned out
> really well! I'd post it, but I'm having the bitmap width and height
> problem I posted earlier today. Can't figure it out - any ideas?
>
> Here's a snippet of how I rotated around the sphere:
>
> var currPlane = plane_array[ planeId ];
> var planeVector:Number3D = new Number3D( currPlane.x, currPlane.y,
> currPlane.z );
> var len:Number = planeVector.modulo + viewingDistance;
>
> planeVector.normalize();
>
> Tweener.addTween( camera, { x:planeVector.x*len , y:planeVector.y*len,
> z:planeVector.z*len, time:1.25, transition:"easeinoutexpo",
> onComplete:onShowName, onCompleteParams:[count]} );
>
> Basically getting the normalized vector of the plane object and
> multiplying it by the length of the original vector plus the desired
> viewing distance. I'm using Tweener to take care of animating the
> properties. Also, every frame I'm telling the camera to lookAt() the
> plane. This is simple and works extremely well. Instead of constantly
> calling lookAt() you could do the math yourself.
>
> On 11-Jun-07, at 2:37 PM, John Grden wrote:
>
> > I wonder if anyone's done something like this:
> >
> > 1.  generated random planes around a sphere
> > 2.  told those planes to look at the sphere
> > [ that part works fine ;) ]
> > 3.  Flown a free camera around the outside of those planes to a
> > specified plane and had it look at the plane with the same
> > rotation  (IE:, like the flickr example we saw a while ago, but
> > flying around a sphere?)
> >
> > Here's snapshot of what I'm working with.  Imagine being able to
> > specify any of those planes, and have the camera animate around the
> > outside, then reposition itself infront of the plane fully rotated
> > to match the plane
> >
> > Anyone?
> >
> > I've created a "dummy" displayObject3D to copy the new panel's
> > transform, then move back 500 - then I'm trying to fly to this new
> > position where the dummy is.  So, I have the "where to fly" down,
> > just need some help flying in a radius / 360 I guess ;)  Not
> > totally sure.
> >
> > I've been trying to get the scene just to rotate and re-orient
> > itself to the camera position (opposite the sphere's rotation
> > values) and that's not working as I would hoped.
> >
> > --
> > [  JPG  ]
> > <sphereRandomPanels.png>
> > _______________________________________________
> > Papervision3D mailing list
> > Papervision3D at osflash.org
> > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
>
> -- 
> [  JPG  ]
> _______________________________________________
> 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/20070611/51ec095b/attachment.htm


More information about the Papervision3D mailing list