Olof Bjarnason wrote:
On 11/6/05, Jake Briggs <jacob_briggs@xxxxxxxxxxxxxxx> wrote:
Olof Bjarnason wrote:
How do you find out which walls are "painted", and which one are notI wouldn't recommend testing against *all* planes in your map -- just the planes of the wall-cubes that are "candidates". How to find the candidates? One simple idea is "drawing" a straight line from point A to point B, testing all walls thus "painted".
without testing all the walls for an intersection? You would end up
doing all the walls once, then re-testing the candidate walls.
Well, in the line-drawing inner-llop, instead of pixels[pitch*y + x] =
color; or whatever draw-pixel-code you have, you do
if(isWall(x,y))
RayCubeCollisionText(theRay, getCubeAt(x,y));
Well we know where the player is, and which way the player is facing, I think that this would be a fast brute force culling technique. Then again, I don't know how Stephen's engine works.
You could cull the walls as an optimisation, getting rid of the test forWell I didn't optimize that much, I just wanted to not have to test
all walls "behind" the player for example, but with only 6400 walls in
the worst case I am not sure if it would be much of an optimisation.
Maybe it would be, I dunno.... But you would have to find a better way
to work out which walls are "behind" the player than testing for an
intersection of the line of sight ray and the wall!
*all* "wall-cubes" of the whole map.
Also you could skip the whole test if the opposing player was "behind"Yep, that's an optimization. Just project the B-A vector on the
the other.
"forward" vector of the player (at A) and check if the result is
positive.
Indeed.
I'm not sure I follow you here.
You can draw the line using Bresenhams classic algorithm, or just use some simple floating-point algo, shouldn't really make any practical difference since you are not "drawing" more than a very small amout of lines per frame (one for each sniper-rifle shot? one for each enemy? never the less an insignificant amount I would hazard .. ). Just make sure you draw a wide enough "line": two may be too thin.
I suppose you could use 8 rays, one pointing at each corner of an invisible bounding box around the opposing player. The rays would start from one point on player one, and target the corners of the opposing player. This would mean 51,200 intersection tests in the worst case. The worst case being that all cells are ceiling cells, and that wouldn't be much fun to play :) But that is still a lot of tests.
A sniper rifle type weapon would only need one ray, but you would have
to test it against each of the 6 planes of the aformentioned bounding
box. You would only need to perform this test if the line of sight test
was true though.
-- Jacob Briggs Systems Engineer
Core Technology Limited Level 1, NZX Centre 11 Cable Street Wellington Phone +64 4 499-1108
--
Named after its country of origin 'England', English is a little known dialect used by up to 1.5 billion non-Americans worldwide. Some interesting but obviously incorrect features of the language include:
- queues of people - wonderful coloUrs - the useful metal aluminIum - the exotic herbs (h-urbs), basil (ba-zil) and oregano (o-re-gaa-no) - specialiSed books called 'dictionaries' that tell you how to spell words correctly
Many people using this bizarre gutter speak also subscribe to the pagan belief that water freezes at 0 degrees and that distances should be measured in the forbidden mathematical system of base-10...
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html