Topic: Camera readjustment based on models

Hey,

In my game I have many walls with one sided normals that are only projecting the texture on the inside of the room. When my camera collides with the walls it just goes through them and it can see through the wall from the other side since the texture isn't being projected on the outside of the wall. I have seen in most games, like minecraft, that when the third person camera collides with an object, it zooms in on the player to avoid the collision. How should I go about doing this?

Thanks in advanced

Re: Camera readjustment based on models

Hi,

you could send a ray from the camera position to the player position,
if the ray hit something it means there is a possible occlusion.

Till the ray hit something you can move the camera position in the direction of the player.
When there the ray doesn't hit anything you can move the camera back to normal.

rayHit : http://wiki.maratis3d.org/index.php?title=RayHit

Re: Camera readjustment based on models

Thanks, that seemed to have done the trick.

However, the camera is shaky now, because the terrain is utilizing triangle-mesh as its shape, and terrain is textured in an odd way.
My way of resolving this was by putting a flat, invisible object just slightly above the terrain. Thus, the player walks freely without a shaking camera.
Nevertheless I have many objects in my terrain, and it would be rather cumbersome to do so for every piece of the terrain. Is there any way to adjust the camera to function smoothly without the object?

Re: Camera readjustment based on models

you can smooth the movement of the camera.

Instead of setting the camera position to the ray hit directly :
cam_pos = ray_hit

Do something like :
smooth = 0.1 -- a number between 0 and 1
cam_pos = cam_pos  + (ray_hit - cam_pos)*smooth