Archived

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

Funkodysse

Near/far clipping

Recommended Posts

Psybr    122
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
Cybertron    122
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
Funkodysse    122

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
Funkodysse    122
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
thedo    124
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
Funkodysse    122
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