[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Raycaster Demo



Farai Aschwanden wrote:
Hi
Its as small as impressive. You are using circles for the walls and wondering why you get the fish eye view? I assume the block would look better if you use rectangles.
Farai:
Kris is not using circles for his walls, he's using rectangles. You can see that from the minimap. That's why the fish eye view is a problem. The walls really aren't circular. They just look like they are. If the walls were circular, there would be no problem.
Fish Eye distortion is caused by the fact that the rays that are cast to represent the edge of the screen (+30 or -30 degrees from the rays that are cast at the center of the screen)
will naturally have a longer distance to the wall than the rays that are cast straight ahead.
The only way you would see a flat wall in this case would be if the wall were actually concave, and curved in toward the player.


Kris:
One way to correct for this is to, instead of using a single point to cast rays, use a camera plane.
This plane will be parallel to the wall when the wall is perpendicular to the player, which means that the fish-eye problem doesn't occur at all,
since you're casting from a set distance away from the wall, instead of from a single point.


I don't know if I explained that very well.
Did you use F. Permadi's raycasting tutorial?
http://www.permadi.com/tutorial/raycast/

It is a fantastic tutorial, IMHO, but it doesn't use the camera plane system.

http://student.kuleuven.be/~m0216922/CG/raycasting.html
does, however.
It doesn't really feel like it's as good of a tutorial, but I would say that you should try to look into that method of raycasting.
Also, I ported this to Python, and it resulted in many zero-division by float errors.
I haven't had time to figure out what exactly needs to be changed to fix this.



Otherwise, F. Permadi goes on to detail how to correct for fisheye in his tutorial, I believe, if you don't want to try the other
method of raycasting.


HTH,
-Luke


Just my 2 cents Farai


Am 06.12.2006 um 17:01 schrieb Kris Schnee:

On a whim, since we're talking about graphics engines and I hear someone else is doing one, I put together a super-simple raycasting engine during class this morning. I call it "Tachikoma," having just rented "Ghost In the Shell: Stand-Alone Complex." For your amusement:

http://kschnee.xepher.net/code/raycaster.py.txt

It works in that you can view some "walls" in a 3D perspective in the style of "Wolfenstein 3D," but there's some weird fisheye distortion I haven't figured out how to correct for.

(To use: Just run it, and use the arrow keys to move and Esc to quit. Requires just Python and Pygame, no graphics files.)

Kris