Recommended Posts

I have a situation where I have something (a person or vehicle) on the terrain and I’m putting their feet (or tire) very close to the terrain so it looks like they are standing on the ground. This works fine for flat terrain, but when I walk up a slope, my feet are sometimes through the terrain poly’s. If I turn off the z buffer then it seems to work, but only until I start to walk down a hill where the side of the hill should block my legs but it doesn’t.
I know this is basic stuff, but is there some sort of trick to keep my feet from going through the terrain?
Thanks

Share this post

Link to post

Share on other sites

The ideal/proper solution would be to ensure that your feet physically don't penetrate the terrain.

This is assuming you have collision data that accruately matches the render data, and that you have a raycasting system which returns the point of impact, and the normal of the item it hit. And assuming your character rednering code has the ability to oreintate certain parts of your models (i.e. a basic animation system/sub mesh control system)

- If you have loads of CPU time then several raycasts down (for the front/back/left/right) of each foot would probably give you enough information to correct orientate the foot to correct match the terrin, but it still wouldn't be perfect.

- A cheaper option would be to do one raycast down and then grab the normal of the collision data it hits and orientate the foot to match that, but again that won't be perfect (especially on high detail collision meshes with lots of variation in a small space).

- You might be able to get away with stuff by playing around with your rendering order etc. but to be honest you really just want a nice generic way of placing things accurately down and orientating them with the ground.

Tires should be easy, feet harder. But I would try to approach it from a more general 'place items correctly on the ground' approach rather than try to fix it via rendering techniques,

Paul

0

Share this post

Link to post

Share on other sites

I know I can raise the object slightly, and from almost all angles it'll look ok, and changing the height of each foot (animation) just seems like overkill, especially when you might have hundreds of players running around on the terrain. It just seems like there would be a way in this modern day to do it. I understand how the Z buffer works and why I can't do what I want, but I was really hoping there were some tricks between zenable and zwriteenable and zclear that some combination would do the trick, but I'm guessing not.

The problem is most evident when you are perpendicular to the slope of the hill. This happens when you approach it head on, and it looks ok untill you turn 90 degrees from the center of the body, and the one foot goes through the ground. It all depends on the slope, but it's quite anoying.

If anyone else has any suggestions I'd love to hear them.

Thanks

0

Share this post

Link to post

Share on other sites

Well, like the first guy said... the reason it looks like one foot goes into the ground is probably because one foot actually goes into the ground. In real life, when you step forward your foot stops when it hits the ground... that's also how it works in most games.

If you want it to look like the foot doesn't go into the ground, you need to make the foot stop when it reaches the ground.

I don't know of any other way to do it... except maybe use flat terrain.

0

Share this post

Link to post

Share on other sites

Guest Anonymous Poster

Guest Anonymous Poster

I've never done this so it's just a suggestion, if you want the feet to always be over the ground you could draw the feet into the stencil buffer, then the terrain, then the person model. Seems like it would look right.

0

Share this post

Link to post

Share on other sites

just a uneducated suggestion, but you could maybe extend your no z-buffer technique by shooting a ray from the camera to the feet. if it hits the terrain first, enable z-buffer, if not - disable z-buffer.

would still probably look ugly, but if you don't wanna animate the feet, it might work.

Share this post

Link to post

Share on other sites

Guest Anonymous Poster

Guest Anonymous Poster

or, using a skeletal animation system, you could rotate the foot about the ankle such that it always runs parallel to the slope of the terrain

And so you know, most games actually don't tackle this problem; they let the guy's toes go through the terrain. It isn't really that big a deal, and when you're running from a dinosaur or making your way to a treasure cave, you probably won't even notice.