Archived

This topic is now archived and is closed to further replies.

Raycasting drawing floors..

This topic is 5619 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
hm no, they are not lines anymore.. not with my cam

sure, flat onto flat gets that, thats okay.. but i dislike that because i want to play with the lenses and do high fov renderings. they are impossible with flat projection planes.

stuff that is as far away should be as big on screen, unimportant where on screen. thats not true with the flat<->flat approach you want to force him..

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
>high fov
Then you have to hold your eyes near the screen.


when I roll my head (rotate around optical axis),
all objects hold their shape.

with x=X/Z y=y/Z this is the case,

robertgamble uses x=X/Z y=atan(y/Z) .. very strange

x=atan(X/Z) y=atan(y/Z) not <=> r=atan(R/r) , phi=PHI
I mean objects change their shape when you roll
when you do this on a LCD for example
Maybe you should buy a dome or cave


Arne

Share this post


Link to post
Share on other sites
Hey that thing is COOL!

byt WHY, WHY do the controls have to be wasd I hate applets that have these controls I have an azerty keyboard

Share this post


Link to post
Share on other sites
quote:
Original post by Lode
Hey that thing is COOL!

byt WHY, WHY do the controls have to be wasd I hate applets that have these controls I have an azerty keyboard


I would use the cursor keys, but as it''s not an applet (it''s DHTML so everything is drawn onto the document body) pressing the up and down keys makes the page scroll up and down

Share this post


Link to post
Share on other sites