Determining steep rise ahead from heightmap

Started by
2 comments, last by Norman Barrows 11 years, 2 months ago

Hi everyone, I'm working on a fps/rpg title, and having a bit of trouble coming up with a set of rules or a combo of methods or tests to determine if there is a steep rise in the height map in front of the player, NPCs, and monsters. the idea is, when checking for collisions, after calculating the unit's new position, if there is a "steep rise ahead" (like a wall or cliff) they stop. at first i was using the usual "well if its less than x feet high they can just step up, otherwise its a wall type collision". but that doesn't quite get the desired effect.

the desired effect is this: if its something they can easily surmount (say 3 foot high for a person), go ahead and move them. if the slope is not too steep (say 60 degree incline) go ahead and move them, otherwise, they must enter "climb mode" which allows them to scale sheer cliffs etc (imagine a VR rock climbing simulator).

climb mode works great, its the checking of the conditions for "steep rise ahead" (IE a climbable surface) that's being elusive.

the slope check is trivial: delta y / movespeed > 1.3 rads => its too steep, must use climb mode.

its the "easily surmounted" part that's tricky. the base walking moverate for a person is 0.3333 d3d units per frame. doing an altitude or slope check at a range of 1 unit or something like the creature's bounding box radius alone doesn't work. while a person may be able to clamber over a three foot rise in 6 inches of forward travel, the single check alone doesn't tell you if that's the top of the rise, and therefore truly a 3 foot obstacle,or merely the bottom 3 feet of a 100 foot cliff. i guess two checks are called for perhaps? one at one foot ahead and one at 2 feet ahead. if the slope to 1 foot ahead is "steep" and the slope from one to two foot ahead is not, then the altitude at 1 foot is the top of the rise (or close enough to it for government work).

most games i've seen simply limit forward travel based on the slope alone, leading to things like trucks that can drive up walls (EVO 4x4 2.0), or being able to walk across the face of a sheer cliff (Oblivion).

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

I have done something similar by casting ray vertically down one step ahead of player. You record where will the ray hit ground and what will be the inclination.

Now if the dH (difference of heights) at hitpoint is less than vertical step limit AND the inclination there is small (i.e. not steep) go ahead and move.

If the dH is bigger than vertical step you have hit steep rise.

If the dH is smaller but the inclination is high you have potential steep rise and have to test two steps ahead.

Lauris Kaplinski

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/

you could also consider using a lower res heightmap for movement intelligence like this. first this will have the effect of smoothing details like little crevice that could be easily stepped over in reality but could give you wrong results if you check only some points.

secondly, the presence on the cpu of that texture would help its caching performance; whereas the large one only has to reside on the Gpu, thus not hurting cpu caches.

Then go ahead with hacking, trying to figure out complex flawless algorithms is ... a neverending quest. there are many heightmap collisions algorithms, based on cones, based on dichotomy etc etc.

If the dH is smaller but the inclination is high you have potential steep rise and have to test two steps ahead.

Yes, this is the case it think i was not handling at first. with only a single test, you can't tell the difference between a 2 foot wall and a 100' cliff.

you could also consider using a lower res heightmap for movement intelligence like this.

the "heighmap" is 100% procedural, using floating point precision for both input and output. so no crevices etc, except where i code them in (or don't code them out). the world is 2500 miles by 2500 miles in size, so bitmaps for height maps isn't really practical, without a lot of during game paging of stuff off disk. The game doesn't do any loading during play at all, just loads the textures, meshes, models, and animations at program start and goes for it. the world map, dungeon levels, etc are 100% procedurally generated. dungeon levels do get loaded during runtime when you re-enter a dungeon you've been in before (IE it saves dungeon maps once it generates them as needed). since the height map is not stored in a bitmap, there are no issues about memory pool etc.

yesterday i fired up the game to get back to work on this issue. started by testing what i'd done the night before. Low and behold, now it was working! Checked the code, sure enough, last thing i tried was testing two spots not just one step ahead. in the end i didn't even use slopes, just direct comparison of y values. So far it seems to handle all cases correctly. cross fingers, flog the heck out of it in testing, and wait and see.

this led to a solution to a related problem: making you bounce off cliff faces when you slip and fall in climb mode. check y in each of 4 cardinal directions at a range of 1 foot.

if any is more than 1 foot below the y where the player hits the cliff face, its at least a 45 degree slope down, therefore not the bottom (or a level enough surface to land on). whichever y is lowest is the steepest downward slope. move the player 1 foot in that direction (bounce off the wall), and do NOT exit falling state.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement