Jump to content
  • Advertisement
Sign in to follow this  
larspensjo

Detect camera inside wall

This topic is 2264 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!