realbasic-nug
[Top] [All Lists]

Re: RB3D Camera.position based on Object3d.postion

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: RB3D Camera.position based on Object3d.postion
From: Bryan Lund <bryan at radicalbreeze dot com>
Date: Wed, 30 Jan 2008 22:13:04 -0800
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <47A005E9 dot 1040701 at radicalbreeze dot com> <1D6A4AF1-AD19-475B-8078-EDE99C414F36 at inspiringapps dot com>
Joe Strout wrote:
> On Jan 29, 2008, at 10:06 PM, Bryan Lund wrote:
> 
>> What I'd like to do is figure out what X and Y values I need to assign
>> to the camera.position in order to place the Object3D at the edge  
>> of the
>> RB3DSpace view (so that it's flush with the border).  And I'm just not
>> good at 3D math. :)
>>
>> Anyone have a bit of experience here and would mind pointing me in the
>> right direction?
> 
> 
> I've done this sort of thing, and there's no shortcut for it -- you  
> just have to do the trig.  Fortunately, you don't need 3D math, but  
> only 2D.  Draw a triangle where the long side is the Z distance to  
> the object, and the angle is half the Rb3DSpace's FieldOfView.  Then  
> do the trig (using Atan) to determine the short side; that's your X  
> value.  Y value shouldn't matter, assuming you want the object placed  
> on the left or right side of the view.

Thanks Joe!  That's exactly what I was looking for.

Basically what I'm now doing is something like this:
ShortSide = tan(degreesAsRadians) * LengthOfAdjecentSide

Is this the correct approach to take no matter with the width of the 
rb3d space is? (As the viewable area changes depending on the width of 
the RB3DSpace no matter what the field of view is set to.)

-Bryan

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>