   Zoom In
  I am working out of the Programming a Multiplayer FPS in DirectX.  My goal is to add a feature that allows the camera to zoom in.  My idea was to have a percentage and a strength passed into the function.  Then this would translate the camera to that position giving the impression of zooming.  Of course I am going to add a an image that makes it look like a scope later on.The main problem I have is allowing the camera not to go through an object.  Should I be doing this a different way, not using the camera.void SceneObject::zoom(float percent, float strength){if(!zoomed){m_oldTranslation=m_translation;m_zoomTranslation = m_translation;}if(percent > 1.0f)percent = 1.0f;float value = percent*strength;m_zoomTranslation = m_oldTranslation + m_forward*value;m_translation = m_zoomTranslation;zoomed = true;}void SceneObject::zoomOut(){m_translation = m_oldTranslation;zoomed = false;}bool SceneObject::GetZoom(){return zoomed;}
  You could just do a collision test between the camera and the target like you do with your player when moving to a new location. If the camera would collide with anything on the way to the zoom target, don't allow the zoom.;  Moving the camera like that won't give the correct effect.  It will look like the player is moving, not the camera zooming.Zoom is done by adjusting the camera's Field of View.Build your projection matrix using D3DXMatrixPerspectiveFovLH and adjust the 'fovy' parameter to change the zoom.You don't need to worry about camera collisions as the camera doesn't move when zooming.;Quote:Original post by WillCMoving the camera like that won't give the correct effect.  It will look like the player is moving, not the camera zooming.Zoom is done by adjusting the camera's Field of View.Build your projection matrix using D3DXMatrixPerspectiveFovLH and adjust the 'fovy' parameter to change the zoom.You don't need to worry about camera collisions as the camera doesn't move when zooming.Quoted for correctness. I focused on the first part of adam23's issue and didn't even consider that there was a better way to do it. Just forget I was here.;  Thanks, I never thought of doing it that way.Just so I'm clear, to give the illusion of zooming in, I just increase the y value.  I will have to play around with this a little bit.   ;Quote:Original post by adam23Just so I'm clear, to give the illusion of zooming in, I just increase the y value.You decrease the y FOV. See the docs for D3DXMatrixPerspectiveFovLH. Basically, you're narrowing the view, but it still takes up the same width on the backbuffer, so it appears zoomed in. A normal FOV is between 45 and 90 degrees, you can decrease the FOV to almost zero to get really zoomed in (but it'll look really weird - I wouldn't go lower than 5 degrees), or you can increase the FOV to get a fish-eye effect.   ;  That worked perfectly, thanks a lot for the advice everyone :)   