Raycasting drawing floors..

Started by
13 comments, last by robertgamble 21 years, 9 months ago
Hi, could anyone give me a few pointers for drawing floors in a raycasting engine? I''ve added stairs to my engine and whilst sides of stairs are drawn ok I can''t work out how to draw the floors/tops of them.. http://www.elephantsneverforget.co.uk/rg/raycast.htm (it''s in DHTML, but is reasonably fast.. Use W,A,S and D). I''ve faked the stair floors somewhat but it looks a bit crappy, if anyone has any ideas for a better way of doing it I''d be really grateful. Thanks!
Advertisement
WTF! cool!
really cool! sorry i cant help you, but its COOL!
Try my older version, it doesn''t have stairs but looks 100x better.

http://www.elephantsneverforget.co.uk/rg/gmen2.asp
O MY GOODNES!!!
ver impressive!
nice job. but can the resolution be upped?
I''ll maybe add resolution options later, I want to get the floors sorted out first though
draw walls
for each column store this:
struct{ int Wall_id, y} cbuffer[enough]

the floor spans between the walls on the screen,
between it is spanned in 3d.
I.E.



sort cbuffer by y,

start span at first y with id=one of walls_wich_floor is spanned
for all other y with id=one of walls_wich_floor is spanned
draw_span_seg to y
One thing I know that you are doing wrong:

Notice when you are facing a wall, the middle of the wall seems to be closer to you then the portions of the wall a little to the right and left (even though they are all the same distance away from you - because the wall is straight, and not curved )?

The problem with that is that you are 'shooting' your rays at equal speed, and they should be 'moving' faster the more off-center they are. If you do not know what I am talking about, maybe a diagram will help:





Note the distance to a wall in the image on the left is different for every ray. If you are assuming the distance is the same, then you would have a curved wall, like the image on the right. Remember, distance in the 3D formula Inverse Z is linear is Z distance only , not the actual distance.
(actual distance = sqrt(deltaX2+deltaY2+deltaZ2) )

Oh, and another thing, note the angles are different in the left frame, and are the same in the right frame. The should be different. (If do not understand why because the diagrams appear to have the same angles in both pictures, then imaging the wall continuing forever to the left, and imagine the distance L being constant - eventually the angle will be almost the same for each new ray you shoot to the left. )

Hope this helps,

Jason Doucette
www.jasondoucette.com

[edited by - Jason Doucette on July 26, 2002 3:02:57 PM]
Jason Doucette / Xona.comDuality: ZF — Xbox 360 classic arcade shmup featuring Dual Play
quote:Original post by Jason Doucette
One thing I know that you are doing wrong:

Notice when you are facing a wall, the middle of the wall seems to be closer to you then the portions of the wall a little to the right and left (even though they are all the same distance away from you - because the wall is straight, and not curved )?

The problem with that is that you are 'shooting' your rays at equal speed, and they should be 'moving' faster the more off-center they are. If you do not know what I am talking about, maybe a diagram will help:





Note the distance to a wall in the image on the left is different for every ray. If you are assuming the distance is the same, then you would have a curved wall, like the image on the right. Remember, distance in the 3D formula Inverse Z is linear is Z distance only , not the actual distance.
(actual distance = sqrt(deltaX2+deltaY2+deltaZ2) )

Oh, and another thing, note the angles are different in the left frame, and are the same in the right frame. The should be different. (If do not understand why because the diagrams appear to have the same angles in both pictures, then imaging the wall continuing forever to the left, and imagine the distance L being constant - eventually the angle will be almost the same for each new ray you shoot to the left. )

Hope this helps,

Jason Doucette
www.jasondoucette.com

[edited by - Jason Doucette on July 26, 2002 3:02:57 PM]




all people are stating a wall should not be round when you face it but a) its round when i look at it with my eyes and b) its even round in movies, but you won't see it that much depending on fov used.
you all get blind because of too much gaming at the pc.. that blinds you from the truth..

"take a look around" - limp bizkit
www.google.com

[edited by - davepermen on July 26, 2002 3:30:47 PM]
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

quote:Original post by davepermen all people are stating a wall should not be round when you face it but a) its round when i look at it with my eyes and b) its even round in movies, but you won''t see it that much depending on fov used.
you all get blind because of too much gaming at the pc.. that blinds you from the truth..


Technically true. But remember, the rendering is supposed to produce an image to be displayed on a (more or less) flat screen. Your eyes might do round-ish things with the picture afterwards, but if you don''t keep distances (rather than angles) constant you are in effect doing the work of your eyes twice.

And, no, fish-eye doesn''t occur in movies, tv, etc., unless they decide to use a lens designed to cause that effect.


Don''t listen to me. I''ve had too much coffee.
davepermen:
ever laid a liner onto a straight edge (3d) on a photo?
Its straight (2d), not curved like with fisheye.

the dome/fisheye-effect comes from the dome in the eyes

if one does fisheye in the computer and the eye does it a
second time, you have double fisheye (too much) on your retina


by the way, I made a mistake in the code above:

//y are sorted

while(i<max) draw_span(cbuffer[i++].y,cbuffer[i++].y);


Arne Rosenfeldt

This topic is closed to new replies.

Advertisement