Wednesday, July 15, 2009

3d LOS

My current LOS implementation has one very HUGE limitation... it's completely 2D. I'm working on an idea that will allow for half-height objects and such to partially block sight... but this would only handle LOS in the same Z level. Most of the LOS algorithms that I saw seemed to be geared towards 2d games. I know I can get a model that works wellish, but it will likely be fairly processor intensive.

I forgot to mention, that while you'll only be able to view one Z level at a time directly, important information will show up regardless of which Z-level your viewscreen is currently focused on (and to go up and down between Z-levels will be but a key-stroke away) Anyone who's played Dwarf Fortess knows that you get some information about the z level that's directly below the one you're looking at, such as if there's an object there. (this basically shows up as 'top of an object') Well, I'll do something similar, that if your agent can spot any other agents/friendlies/corpses/items/aliens that AREN'T on the current z-level that you're viewing, those items will still show in their proper x-y coordinates, but as a different color, perhaps indicating if that object is up/down.

I hope to overcome that possible cumbersomeness of this by making different kinds of data easily accessible/toggle-able. for example, a quick-key to show which of your agents has the highest (fill in the blank) stat/ability/level/health, whatever, by substituting a single digit number for their '@.' No more will you have to rename your units to "thrower" "sniper" "heavy weaponer" "MC agent" or, the super-annoying "55ST70TU60H..."

2 comments:

Jotaf said...

Nice. If you had a true-color display you could also change the color gradually from red to yellow to green reflecting the health, or optionally another stat like you're describing. That would be pretty cool. About the 3D FOV, this might interest you:

http://doryen.eptalys.net/forum/index.php?topic=249.0

I think it's built to integrate nicely into libtcod, but it's a sort of add-on, 3D FOV is not used by a lot of RLs so Jice said it probably won't make it into the regular libtcod distribution. Anyway the code is available :)

abagoforanges said...

Thanks for the link, I'll look at it a bit later. I think I've figured out a way to expand my raycasting LOS to 3d. Basically, each ray would have a dimension (vertical) that would start off unobstructed. Every time the ray encounters an obstruction, instead of just being outright-blocked, the ray gets a new 'obstruction' object added to it. I'm working out how the angles will work, but depending on the height of the agent (eye-height), the distance and the height of the obstruction, as the ray moves onward from the obstruction, the space that the obstruction will block will also shift.

It was either this or have a ton of extra rays shoot off from the agents position, but in z directions also. This would be say, 360 rays * 360, almost 130K rays each movement. Because most downward-aimed rays would hit the bottom z level quite quickly, it would be closer to (360^2)/2, but this is STILL a huge huge number.