Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Funkodysse

Near/far clipping

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

Hi. i would like to know how to set near/far clipping. could anyone be so kind and tell me Edited by - Funkodysse on January 31, 2002 10:31:12 AM

Share this post


Link to post
Share on other sites
Advertisement
could you be more specific? in general, in d3d7/8, you set up the near/far clipping plane values when you set up the projection matrix

Share this post


Link to post
Share on other sites
Most likely you use D3DXMatrixPerspectiveFovLH or a similar function to set up the projection matrix (both 7 and 8)

two of the paramiters set the veiw plane, check it out in the SDK!

Share this post


Link to post
Share on other sites

DX8.

i tried this but not work.

D3DVIEWPORT8 Viewport;
Viewport.X=0;
Viewport.Y=0;
Viewport.Width=800;
Viewport.Height=600;
Viewport.MinZ=-1000.0f; //near clipping
Viewport.MaxZ=1000.0f; //far clipping
g_pDevice->SetViewport(&Viewport);

Share this post


Link to post
Share on other sites
No no no, MinZ and MaxZ are the depth buffer values, not the near/far clipping planes.

D3DXMatrixPerspectiveFovRH( &ProjectionMatrix,
FOV * 0.5f,
float(Viewport.Width) / float(Viewport.Height),
NearDistance,
FarDistance );

Near may be 0.125, Far may be 1000, for example. Both must be greater than zero.

~CGameProgrammer( );

Share this post


Link to post
Share on other sites
D3DVIEWPORT8 Viewport;
Viewport.X=0;
Viewport.Y=0;
Viewport.Width=800;
Viewport.Height=600;
Viewport.MinZ=-1000.0f;
Viewport.MaxZ=1000.0f;
g_pDevice->SetViewport(&Viewport);
D3DXMatrixLookAtLH(&g_ViewMatrix,&D3DXVECTOR3(0.0f,0.0f,-5.0f), &D3DXVECTOR3(0.0f,0.0f,0.0f), &D3DXVECTOR3(0.0f,1.0f,0.0f));
g_pDevice->SetTransform(D3DTS_VIEW,&g_ViewMatrix);
D3DXMatrixPerspectiveFovLH( &g_matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
g_pDevice->SetTransform( D3DTS_PROJECTION, &g_matProj );
D3DXMatrixPerspectiveFovRH( &g_matProj,0.5f,float(Viewport.Width) / float(Viewport.Height),-1000, -300); //far,near



It aint worked

Share this post


Link to post
Share on other sites
This is your error:

Viewport.MinZ=-1000.0f;
Viewport.MaxZ=1000.0f;

MinZ and MaxZ must be between 0 and 1 (being a percentage of your far clip distance in D3DXPerspectiveFovLH).

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
hi.

i removed the viewport and D3DXMatrixPerspectiveFovRH and just changed the D3DXMatrixPerspectiveFovLH( &g_matProj, D3DX_PI/4, 1.0f, 0.1f, 500.0f ); to this.

and it worked..

thanks anyway.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!