Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Getting a background to fill the 3D space 1x1 this code should work? (Real Studio games Mailinglist archive)

Back to the thread list
Next thread: Re: REALbasic-Games Digest #191


Re: explosions   -   Jeff Quan
  Getting a background to fill the 3D space 1x1 this code should work?   -   Chris Dillman
   Re: Getting a background to fill the 3D space 1x1 this code should work?   -   Joseph J. Strout
   Re: Getting a background to fill the 3D space 1x1 this code should work?   -   Chris Dillman
   Re: Getting a background to fill the 3D space 1x1 this code should work?   -   Joseph J. Strout
   Re: Getting a background to fill the 3D space 1x1 this code should work?   -   Chris Dillman

Getting a background to fill the 3D space 1x1 this code should work?
Date: 26.01.04 22:22 (Mon, 26 Jan 2004 15:22:39 -0600)
From: Chris Dillman

Hi Im using this code from joe's 3D FAQ...

Which I think was supposed to let sprites be 1 for 1 texture to pixel
to the screen.

So

1. did I do something wrong?

2. does this work for a back ground?

Dim degrees As SIngle
Dim angle As Single
Dim distance As Single

degrees = 0.0174532925 // (radians per degree)
angle = me.fieldOfView * degrees * 0.5
distance = ( me.width * 0.5) / tan(angle)
me.camera.position.Z = distance

Re: Getting a background to fill the 3D space 1x1 this code should work?
Date: 27.01.04 15:43 (Tue, 27 Jan 2004 08:43:39 -0600)
From: Joseph J. Strout
Chris Dillman wrote:

> degrees = 0.0174532925 // (radians per degree)
> angle = me.fieldOfView * degrees * 0.5
> distance = ( me.width * 0.5) / tan(angle)
> me.camera.position.Z = distance

I note that you're not checking with the view's width < height, and
the assumption your code makes is that the width is less than the
height. Is that in fact the case? Maybe it'd be safer to leave the
if-test in, as shown in Q4.7 of the FAQ?

HTH,
- Joe

Re: Getting a background to fill the 3D space 1x1 this code should work?
Date: 27.01.04 16:59 (Tue, 27 Jan 2004 09:59:50 -0600)
From: Chris Dillman
>Chris Dillman wrote:
>
>> degrees = 0.0174532925 // (radians per degree)
>> angle = me.fieldOfView * degrees * 0.5
>> distance = ( me.width * 0.5) / tan(angle)
>> me.camera.position.Z = distance
>
>I note that you're not checking with the view's width < height, and
>the assumption your code makes is that the width is less than the
>height. Is that in fact the case?

Nope not the case...

I would say opps but read below...

> Maybe it'd be safer to leave the if-test in, as shown in Q4.7 of the FAQ?

My Faq reads...
Actually The FAQ... I grabbed the new one based on the URL in the Faq...
Reads...

Im not seeing the check any where?

4.7. Using the 3D Engine for Sprites

This section is still quite incomplete. But the basic idea is, you set
your FieldOfView to a very small angle, and move the camera very far
away; this cancels out most of the perspective. Then you just make a
bunch of little flat objects with AddShapeFromPicture[WithMask], and
move them around -- presto, a sprite engine with hardware acceleration,
as well as sprite rotation and scaling.

For convenience, you'll usually want 1 unit in 3D space to come out to 1
pixel on the screen. You can set it up this way:

degrees = 0.0174532925 // (radians per degree)
angle = view.fieldOfView * degrees * 0.5
distance = (view.width * 0.5) / tan(angle)

view.camera.position.Z = distance
view.hither = distance - 10
iew.yon = distance + 10

For more details, see issue 1.1 of RB Developer magazine (but note that
it contains an error: the distance formula in the magazine uses
sin(angle) instead of tan(angle).

Re: Getting a background to fill the 3D space 1x1 this code should work?
Date: 27.01.04 17:16 (Tue, 27 Jan 2004 10:16:20 -0600)
From: Joseph J. Strout
At 9:59 AM -0600 1/27/04, Chris Dillman wrote:

>Im not seeing the check any where?

No? Perhaps I've failed to update the web site. I'll do that now
just to be sure. Meanwhile, 4.7 should read:

4.7. Using the 3D Engine for Sprites

This section is still quite incomplete. But the basic idea is, you
set your FieldOfView to a very small angle, and move the camera very
far away; this cancels out most of the perspective. Then you just
make a bunch of little flat objects with
AddShapeFromPicture[WithMask], and move them around -- presto, a
sprite engine with hardware acceleration, as well as sprite rotation
and scaling.

For convenience, you'll usually want 1 unit in 3D space to come out
to 1 pixel on the screen. You can set it up this way:

degrees = 0.0174532925 // (radians per degree)
angle = view.fieldOfView * degrees * 0.5
if view.width < view.height then
distance = (view.width * 0.5) / tan(angle)
else
distance = (view.height * 0.5) / tan(angle)
end if

view.camera.position.Z = distance
view.hither = distance - 10
view.yon = distance + 10

For more details, see issue 1.1 of RB Developer magazine (but note
that it contains an error: the distance formula in the magazine uses
sin(angle) instead of tan(angle)).

Re: Getting a background to fill the 3D space 1x1 this code should work?
Date: 27.01.04 17:45 (Tue, 27 Jan 2004 10:45:43 -0600)
From: Chris Dillman
>At 9:59 AM -0600 1/27/04, Chris Dillman wrote:
>
>>Im not seeing the check any where?
>
>No? Perhaps I've failed to update the web site. I'll do that now
>just to be sure. Meanwhile, 4.7 should read:

Ah and it all runs perfect now.

Thanks joe.