raycasting

This is a discussion on raycasting within the Game Programming forums, part of the General Programming Boards category; I've seen several demos of raycasting on this site (they're all helpful)
but i need something special.
I am programming ...

raycasting

I've seen several demos of raycasting on this site (they're all helpful)
but i need something special.
I am programming for a console and i need a raycaster that can ray cast a certain size.
If any one could tell me how to change the resolution of a raycaster, could you please tell me?

To change the resolution of a ray caster you simply change the cellsize of each cell.

gridx=rayx/CELLSIZE
gridy=rayy/CELLSIZE

I assume you are splitting rayx and rayy up into two separate functions based upon tangents instead of sin and cos.

Wolf3D uses a cell size of 64 as well as texture sizes of 64. Be careful when altering the cell size because it can produce very ugly images when incorrect values are used. Also if you do not change the step size of your player, but increase the cell size, you may be causing the player to walk a very long way or you may cause the player to not be able to hardly move at all.

If you wish to change the resolution at which the ray caster casts rays you do this. This is assuming a 360 degree circle.

AngleInc=HFOV/ScreenWidth
NumAngles=RayStep/NumAnglesInCircle

so the angle increment on a screen width of 320 is .1875 and the number of angles is 1920. These can be pre-calculated.

re-raycasting

I got some of that,
my program uses sine+cosine and is single coloured walls (not textured)
I'm trying to pull the size of the screen from 360x240 to 160x128
(half size of 360x240 is 180x120, i was thinking of blending a 2x2 set of pixels together)

just in case, can anyone tell me where i can get a program that blends a 15bit map into a half length+width bitmap?

To change the resolution you will also change the number of angles on the screen. Follow my example to do just that. What you are doing is filtering the screen, or you are making one pixel equal one block of pixels, which would be extremely ugly. There is no need to do this.

Your framerate problems are stemming from your use of sine and cosine. Using tangents is much faster.

sin(angle)= a/h
cos(angle)=o/h
tan(angle)=o/a

So if you know the angle and the size of either the adjacent or opposite, you can find the step size by solving the tangent equation for o and a respectively. Since the cell size will never change in an orthogonic projection, you can increase x and y by constants depending on whether or not you are tracing the x-ray or y-ray. This will reduce your intersections test by a factor of 10 on a 10x10 map.

Simple trigonometry will help you a lot in raycasting as well as using as many look-up tables as you can.

For screen size of 160 your angle increment would be 60/160 or .375 which would yield 960 tangents instead of 1920, given you are using 360 degree circle. Some use 256 degrees in a circle.

There is no need to vertically scale the projection since the viewer is assumed to always be looking at the middle of the walls. The only time you must also vertical raycast is normally in the case of voxels and heightmaps or if you wanted to program a DOOM type raycaster, which is essentially a heightmap and a texturemap raycaster. Very close to a voxel-type projection.