Making an RTS camera

How would I go about making an RTS style camera that will collide with the terrain (to stop the camera going through it)? I need the camera to pan, zoom and rotate in the x and y direction.

I’ve currently got the camera doing all of this using simple translates and rotations, but it does not collide with the terrain - it just goes straight through it.

The terrain will have hills in it, so for example if I pan the camera in to a hill, the camera should avoid the hill while still looking at the original point. How do I go about doing this?

look at this post