Detect camera inside wall

Started by
2 comments, last by dpadam450 11 years, 9 months ago
[font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

What are the options on how to do this (kind of collision detection)? The current algorithm detects most of the cases, but there are some tricky ones that remains.[/font]

[font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

I have an application with "lots" of triangles. It is not only a problem with the camera getting inside the wall, it is a problem when getting too near the wall (passing the near frustum plane).[/font]

[font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

I suppose I can do the test "manually". That is, search through all relevant triangles and test them. This is difficult to do efficiently, as I have problems to reduce the number of possible triangles.[/font]

[font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

Another option could be to do it in the vertex shader or fragment shader. I am not sure if it is feasible, as the camera would almost certainly be behind some wall all the time (that is, facing a negative normal).[/font]

[font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

One idea I have is to draw some dark grey walls behind the usual walls. A wall doesn't look good anyway, if you are very close to it.[/font]

[size=2]Current project: Ephenation.
[size=2]Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/
Advertisement
I personally treat a camera as just another spherical object in the scene, and allow my collision code to handle it, so that it doesn't go behind/through objects.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
You could shoot some rays from the current camera position to the four corners of the near clip plane. When doing this without culling back face ray tests you can check to see if the intersection distance is shorter than the distance it should have from camera origin to near clip plane point. If this is the case you know one of the corners is behind a wall. This wont work if the intersection is only in the center ofcourse.
This is a physics problem. You don't need to test every triangle but you can generalize things like say a statue as a box.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement