Sign in to follow this  

Creating the virtual camera.....

This topic is 4687 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

Hey everyone, I had a quick question. I was wondering what the farClip/nearClip do with this section of code:
createCamera(1.0f, 500.0f);		// near clip plane, far clip plane
//CreateCamera(...) function
/*************************************************************************
* createCamera
* creates a virtual camera
*************************************************************************/
void createCamera(float nearClip, float farClip)
{
	//Here we specify the field of view, aspect ration and near and far clipping planes.
    D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 640/480, nearClip, farClip);
	pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);
}

I was just wondering how the createCamera function works. I'm reading a book Beginning DirectX 9 by Wendy Jones (in case you've read it) and the book doesn't explain 100% on how the D3DXMatrixPerspectiveFovLH(...) works. Thanks in advance.

Share this post


Link to post
Share on other sites
The near clip is the minimum distance an object must be from the camera to be visible on screen, far clip is the maximum distance. The D3DX_PI / 4 is the vertical field of view (45 degrees in that case), the 640/480 is the aspect ratio (used to determine the horizontal field of view).

Check out the DirectX 9 SDK @ "DirectX Graphics -> Programming Guide -> Getting Started -> Viewports and Clipping" for more details about the projection transform.

Share this post


Link to post
Share on other sites

This topic is 4687 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this