POV-Ray : Newsgroups : povray.general : orthographic projection of game tiles.... Server Time
2 Nov 2024 17:19:35 EDT (-0400)
  orthographic projection of game tiles.... (Message 1 to 8 of 8)  
From: Stephen Guentert
Subject: orthographic projection of game tiles....
Date: 27 Feb 1999 22:40:09
Message: <36d8ba99.0@news.povray.org>
I'm working on a shareware video game similar to diablo  and I want to use
POV-RAY to render the tiles.  the tiles need to be 64x64 with two diamonds
rendered from a checkered floor, one right above the other.  so far I've got
the orthographic part right, but I cant get the camera into the right
position to render it perfectly.  I need the perfect rendering position so
the individual tiles will match up correctly inside the game.  so right now
I've got a checkered floor and I'm looking at 0,0,0 from 10,10,10 with the
floor scaled up by 10.  this doesnt give me the effect I'm looking for.  I
need the corners to line up to the edges and to the center of the tile....

so can anybody lend some advice?


Post a reply to this message

From: John M  Dlugosz
Subject: Re: orthographic projection of game tiles....
Date: 1 Mar 1999 01:45:28
Message: <36da3788.0@news.povray.org>
Forget the "look at" and just use the height/width in your right/up vectors.
If memory serves (I did some ortho reciently), the camer's position is the
lower-left corner, not the center!   Don't rotate the camera and you'll have
nice straight lines.

--John


Stephen Guentert wrote in message <36d8ba99.0@news.povray.org>...
>I'm working on a shareware video game similar to diablo  and I want to use
>POV-RAY to render the tiles.  the tiles need to be 64x64 with two diamonds
>rendered from a checkered floor, one right above the other.  so far I've
got
>the orthographic part right, but I cant get the camera into the right
>position to render it perfectly.  I need the perfect rendering position so
>the individual tiles will match up correctly inside the game.  so right now
>I've got a checkered floor and I'm looking at 0,0,0 from 10,10,10 with the
>floor scaled up by 10.  this doesnt give me the effect I'm looking for.  I
>need the corners to line up to the edges and to the center of the tile....
>
>so can anybody lend some advice?
>
>


Post a reply to this message

From: Phoenix
Subject: Re: orthographic projection of game tiles....
Date: 1 Mar 1999 04:34:56
Message: <MPG.11447dce346addd698969c@news.povray.org>
'T was on Mon, 1 Mar 1999 00:45:26 -0600,
that John M. Dlugosz wrote:
> Forget the "look at" and just use the height/width in your right/up vectors.
> If memory serves (I did some ortho reciently), the camer's position is the
> lower-left corner, not the center!   Don't rotate the camera and you'll have
> nice straight lines.

Er... Not exactly true.
With orthographic camera's, the up and right vectors determine the view 
size with the look_at point as the *middle*.

For instance,

camera {
    location <0, 10, 0>
    up <0, 2, 0>
    right <2, 0, 0>
    look_at <0, 0, 0>
}

would give you a view of 2 units wide and 2 units high (yes, a square 
image :) with the origin as the center point.

With this camera you could use a plane on the y axis as the background 
and put whatever you want to tile on the origin.

Don't forget to specify the image width and height itself!

Phoenix

-- 
eag### [at] telekabelnl                       http://users.telekabel.nl/eagle
------------------------------------------------------------------------
The POV-Ray VFAQ: http://iki.fi/warp/povVFAQ.html


Post a reply to this message

From: Phoenix
Subject: Re: orthographic projection of game tiles....
Date: 1 Mar 1999 08:23:49
Message: <MPG.1144a8a467e6c9d898969d@news.povray.org>
'T was on Mon, 1 Mar 1999 10:35:28 +0100,
that Phoenix wrote:
> camera {
      orthographic
>     location <0, 10, 0>
>     up <0, 2, 0>
>     right <2, 0, 0>
>     look_at <0, 0, 0>
> }

Stupid me! Give a lecture on the orthographic camera and then forget to 
make it one...

Phoenix

-- 
eag### [at] telekabelnl                       http://users.telekabel.nl/eagle
------------------------------------------------------------------------
The POV-Ray VFAQ: http://iki.fi/warp/povVFAQ.html


Post a reply to this message

From: John M  Dlugosz
Subject: Re: orthographic projection of game tiles....
Date: 1 Mar 1999 19:47:18
Message: <36db3516.0@news.povray.org>
yes, I looked at the actual script and it's in the middle.

#local Height= 71;
#local Width= 47;
#local Base= 18;

#declare ortho=
camera {
   orthographic
   location <0,Base+(1+Height)/2,-8*ft>
   direction <0,0,1>
   up <0,Height+1,0>
   right <Width+1,0,0>
   look_at <0,Base+(1+Height)/2,0>
   }


As long as the camera was pointed perpendicularly to the scene's horizontal
and vertical components, those components rendered straight.

--John


Phoenix wrote in message ...
>'T was on Mon, 1 Mar 1999 00:45:26 -0600,
>that John M. Dlugosz wrote:
>> Forget the "look at" and just use the height/width in your right/up
vectors.
>> If memory serves (I did some ortho reciently), the camer's position is
the
>> lower-left corner, not the center!   Don't rotate the camera and you'll
have
>> nice straight lines.
>
>Er... Not exactly true.
>With orthographic camera's, the up and right vectors determine the view
>size with the look_at point as the *middle*.
>
>For instance,
>
>camera {
>    location <0, 10, 0>
>    up <0, 2, 0>
>    right <2, 0, 0>
>    look_at <0, 0, 0>
>}
>
>would give you a view of 2 units wide and 2 units high (yes, a square
>image :) with the origin as the center point.
>
>With this camera you could use a plane on the y axis as the background
>and put whatever you want to tile on the origin.
>
>Don't forget to specify the image width and height itself!
>
>Phoenix
>
>--
>eag### [at] telekabelnl                       http://users.telekabel.nl/eagle
>------------------------------------------------------------------------
>The POV-Ray VFAQ: http://iki.fi/warp/povVFAQ.html


Post a reply to this message

From: Stephen Guentert
Subject: Re: orthographic projection of game tiles....
Date: 1 Mar 1999 22:15:32
Message: <36db57d4.0@news.povray.org>
I messed with the up and right vectors and got it to work perfectly.
I didn't use all those #declares and #locals though.  notice that everything
is scaled up by 10.  notice also that my right vector is the square root of
2 (scaled by 10).  my up vector is 1.63 (scaled again).
this gives me exactly what I want - but I'd like to understand the
mathematical significance of these numbers.

and also, is anyone interested in doing some images for a shareware game?

heres my tile.ini:

Width = 512
Height = 512
Bounding_Threshold = 3
Display=On
Verbose=On
Library_Path=C:\Program Files\POV-Ray for Windows\INCLUDE
Input_File_Name=tile2.pov
Output_File_Name=C:\WINDOWS\Desktop\images\


heres my tile.pov:

global_settings {
  ambient_light <1.0,1.0,1.0>
  assumed_gamma 1.9
}

background { color <0.000,0.000,0.000> }

camera {  //  Camera StdCam
orthographic
  location  <10 , 10, 10 >
  right     <0  , 1.4142135623730950488016887242097 * 10 , 0.0 >
  up        <1.63 * 10, 0.0 , 0.0 >
  direction <0  , 0 , 1 >
  look_at   <0.000, 0.000, 0.000>


}

//
// *******  L I G H T S *******
//

light_source {   // Light1
  <10.000, 20.000, 20.000>
  color rgb <1.000, 1.000, 1.000>
}


//  Moray V3.01 For Windows (c) 1991-1998 Lutz + Kretzschmar
//

//
// ********  TEXTURES  *******
//

#include "tile2.inc"


//
// ********  REFERENCED OBJECTS  *******
//



//
// ********  OBJECTS  *******
//
sphere { //left foot
  <0, 0, 0>, .5
  texture {
    Tiles
  }
  scale <2,1,1>
  translate <5, 0, 3>
}

sphere { //right foot
  <0, 0, 0>, .5
  texture {
    Tiles
  }
  scale <2,1,1>
  translate <5, 0, 7>

}

sphere { // head
  <0, 0, 0>, .75
  texture {
    Tiles
  }
  translate <5, 8, 5>
}

sphere { // torso
  <0, 0, 0>, 1
  texture {
    Tiles
  }
  scale <.5,1,1>
  translate <5, 6, 5>

}


sphere { // hips
  <0, 0, 0>, 1
  texture {
    Tiles
  }
  scale <.5,.75,1>
  translate<5, 4, 5>
}

sphere { // left shin
  <0, 0, 0>, 1
  texture {
    Tiles
  }
  scale <.5,1,.5>
  rotate <10,0,0>
  translate<5, 1.5, 3.25>
}

sphere { // left thigh
  <0, 0, 0>, 1
  texture {
    Tiles
  }
  scale <.5,1,.5>
  rotate <10,0,0>
  translate<5, 3, 3.75>
}

sphere { // right shin
  <0, 0, 0>, 1
  texture {
    Tiles
  }
  scale <.5,1,.5>
  rotate <-10,0,0>
  translate<5, 1.5, 6.75>
}

sphere { // right thigh
  <0, 0, 0>, 1
  texture {
    Tiles
  }
  scale <.5,1,.5>
  rotate <-10,0,0>
  translate<5, 3, 6.25>
}


plane { // Plane001
  y,0
  texture {
    Tiles
  }
  scale 10.0
}


Post a reply to this message

From: John M  Dlugosz
Subject: Re: orthographic projection of game tiles....
Date: 1 Mar 1999 23:22:09
Message: <36db6771.0@news.povray.org>
Stephen Guentert wrote in message <36db57d4.0@news.povray.org>...
>I messed with the up and right vectors and got it to work perfectly.
>I didn't use all those #declares and #locals though.

Why not?  makes it easier to change, and you don't have magic numbers in the
final code but see the reasons for them.

> notice also that my right vector is the square root of
>2 (scaled by 10).  my up vector is 1.63 (scaled again).
>this gives me exactly what I want - but I'd like to understand the
>mathematical significance of these numbers.

Well root-two is the diagonal of a square, and 1.618123 (close to what you
have) is the inverse of the "golden ratio", a way to divide a line so that
the ratio the small piece to the large is the same as the ratio of the large
to the whole.

>camera {  //  Camera StdCam
>orthographic
>  location  <10 , 10, 10 >
>  right     <0  , 1.4142135623730950488016887242097 * 10 , 0.0 >
>  up        <1.63 * 10, 0.0 , 0.0 >
>  direction <0  , 0 , 1 >
>  look_at   <0.000, 0.000, 0.000>
>  scale 10.0
>}
>


In a ortho camera, the "right" is the number of POV units wide the scene
will render, and the "up" is the number of POV units tall.  So you're saying
you want 14.1 x 16.3 POV units to form your image, outputting in 512x512
pixels.  Strange that your pixels are not square...

You are located at 10,10,10, but looking down over your left sholder.  The
angle of this view to the ground probably is the cause of these numbers.

Normally, in an ortho projection, the "look at" should be directly down the
line of sight, so it has two numbers the same as the location, and the one
that's different is the one that's not used in the up and right.


Post a reply to this message

From: Stephen Guentert
Subject: Re: orthographic projection of game tiles....
Date: 2 Mar 1999 00:27:03
Message: <36db76a7.0@news.povray.org>
John M. Dlugosz wrote in message <36db6771.0@news.povray.org>...
>
>Stephen Guentert wrote in message <36db57d4.0@news.povray.org>...
>>I messed with the up and right vectors and got it to work perfectly.
>>I didn't use all those #declares and #locals though.
>
>Why not?  makes it easier to change, and you don't have magic numbers in
the
>final code but see the reasons for them.
>

I plan to eventually use variables.  this was just to get me up and running.

>> notice also that my right vector is the square root of
>>2 (scaled by 10).  my up vector is 1.63 (scaled again).
>>this gives me exactly what I want - but I'd like to understand the
>>mathematical significance of these numbers.
>
>Well root-two is the diagonal of a square, and 1.618123 (close to what you
>have) is the inverse of the "golden ratio", a way to divide a line so that
>the ratio the small piece to the large is the same as the ratio of the
large
>to the whole.
>

aha! that's what I was looking for.........

>>camera {  //  Camera StdCam
>>orthographic
>>  location  <10 , 10, 10 >
>>  right     <0  , 1.4142135623730950488016887242097 * 10 , 0.0 >
>>  up        <1.63 * 10, 0.0 , 0.0 >
>>  direction <0  , 0 , 1 >
>>  look_at   <0.000, 0.000, 0.000>
>>  scale 10.0
>>}
>>
>
>
>In a ortho camera, the "right" is the number of POV units wide the scene
>will render, and the "up" is the number of POV units tall.  So you're
saying
>you want 14.1 x 16.3 POV units to form your image, outputting in 512x512
>pixels.  Strange that your pixels are not square...
>
>You are located at 10,10,10, but looking down over your left sholder.  The
>angle of this view to the ground probably is the cause of these numbers.
>
>Normally, in an ortho projection, the "look at" should be directly down the
>line of sight, so it has two numbers the same as the location, and the one
>that's different is the one that's not used in the up and right.

512 x 512 was a "test" size.  the tiles will be 64x64 in the end.
I just had to maintain powers of 2 in both directions of the image,
and the corners of the diamonds had to fall in a perfectly tilable fashion.

declare a checkered texture (where I failed to include mine) and you will
see the
perfect math that comes out of it.

 I know this doesn't look like everyday POV, but
I've already plugged a couple tiles into the engine and it's working like a
dream.

thank you much for the mathematical clarification! It had me stumped.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.