This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

nccb
nccb presents ...

2012/6/20

Texture Mapping

This is an example of raycasting, a psuedo-3D technique used in some early games such as Wolfenstein 3D, now with texture-mapping.

Use the left and right keys to spin your view. Use the WASD keys to move around the grid (but note: you don't move in the direction you're facing in this example!). The minimap in the top left shows your position as the white dot, so you can see how the 3D view corresponds to the map.

The technique is explained in this blog post:

http://sinepost.wordpress.com/2012/06/20/another-brick-in-the-wall/

8040 views / 30 in the last 7 days

6 votes | 0 in the last 7 days

Tags: with-source

This scenario is a member of: Ray Casting


open in greenfoot
Your browser does not support the canvas tag.
MatheMagicianMatheMagician

2012/6/20

Awesome! would you mind if I used it in a game and then posted it on the site?
nccbnccb

2012/6/22

That would be fine -- go for it!
As an optimization, since you aren't rotating the camera along the Y axis at all, you could also take individual 'slices' of wall image and scale them instead of going pixel by pixel.
nccbnccb

2012/6/23

@Builderboy2005: Yes -- that's true. Did you know that the original Wolf3D raycasting engine actually pre-compiled all the line-scaling routines that it needed, for speed? At least, wikipedia claims: "The secret behind engine's performance is vertical scanline scaling algorithm. Unlike later engines and hardware rasterizers, the texture coordinate for the pixel is not calculated at runtime. Instead, a fixed set of several hundred rendering functions is generated during game startup (or viewport size change) where all memory offsets are fixed. To keep the number of these procedures small, height is quantized, which can be easily seen when player is close to the wall, but not looking at it at a right angle."
yedefeiyedefei

2012/8/16

I'm not very clear how to decide which face of the wall the sight line hits ,in other words ,when to use the decimal part of x coordinate and when to use y's

Want to leave a comment? You must first log in.

Who likes this?

Duta pandapal09 bourne MatheMagician SPower mkramer