This project is read-only.

Camera and Physics

Jan 25, 2008 at 4:22 AM
Shaw, you're on physics, and I'm on cameras. Would you like me to take care of camera->terrain collision, or would you like to do it?

If I were to do it, would I do it like I did in the original engine, or would it be better to use PhysX to do it? I plan on creating a box using the camera frustum. Currently we're only using the point of the camera to check collision, which can result in seeing through the terrain when the camera is right up against terrain at certain angles. If we check collision on the frustum itself, or make the frustum into a box then we won't have that problem.

Also, I'm going to need a way to do ray casting against physics entities. I plan on casting a ray from the target point (on cameras with targets) to the camera, and then if specific groups of physics are between the camera and target the camera can optionally snap forward to keep the target in view. This will let the developer choose which types of physics entities can and cannot come between the camera and target.

Also, I believe we should have a simple view mode that we can switch to that will draw the physics entities or physics world. This way if collisions aren't as they seem you can switch views and see if maybe the physics model isn't rotating, or matched up right, or scaled right, etc...
Jan 25, 2008 at 1:59 PM
Create issues for whatever physics suggestions you have.

The camera collision should be handled by scene management code. It's not just terrain that you need to worry about, but all entities. Rendering from inside another character is just as bad as rendering through the terrain.

How would you check collision based on the frustum? The camera frustum practically always intersects the terrain. I was thinking more along the lines of just enclosing the camera in a small sphere.
Jan 25, 2008 at 3:33 PM
A sphere is ok, if we want to use physics on the camera. If I used the frustum I could just check if any of the corners of the frustum were below the terrain. Using physics would stop us from going through a lot of things, however sometimes I want cameras to be able to go through things, it is usually easier to do a ray trace to see if anything is in the way of the camera.
Jan 25, 2008 at 4:23 PM
However works best for you is fine. I would just keep camera-specific logic out of the physics code.