Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding objects that obscure the player in a 3D scene

Tags:

c#

algorithm

xna

3d

I'm designing a 3D game with a camera not entirely unlike that in The Sims and I want to prevent the player character from being hidden behind objects, including walls, pillars and other objects.

One easy way to handle the walls case is to have them face inwards and not have an other side, but that won't cover the other cases at all.

What I had planned is to somehow check for objects that are "in front" of the player, relative to the camera, and hide them - be it by alpha blending or not rendering at all.

One probably not so good idea I had in mind is to scan from the camera to the player in a straight line and see if you hit a non-hidden object, continuing until you reach the player. Unfortunately, I am an almost complete newbie on 3D programming.

Demonstration SVG illustration < that wall panel obscures the player, so it must be hidden. Another unrelated and pretty much already solved problem is removing all three wall panels on that side, which is irrelevant to this question and only caused by the mapping system I came up with.

like image 657
Kawa Avatar asked Jan 30 '26 02:01

Kawa


1 Answers

What I had planned is to somehow check for objects that are "in front" of the player, relative to the camera, and hide them - be it by alpha blending or not rendering at all.

This is a good plan. You'll want to incorporate some kind of bounding volume onto the player, so the entire player (plus a little extra) is visible at all times. Then, simply run the intersection algorithm for each corner of the bounding volume.

like image 194
Jon Seigel Avatar answered Jan 31 '26 22:01

Jon Seigel