Jump to content
  • Advertisement
Sign in to follow this  
ArgusMaker

[DX9] face visibility & camera angolation

This topic is 2588 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 there!
i've got a problem..
i draw a sort of floor (a rectangle made of 2 triangles) with DrawPrimitive function.
If i look at the floor from an higher z value it is not drawn. On the other hand, when i look at the floor from a lower z value it switchs to visible.
What should i do to make it visible from any point of view? Thanks in advance cool.gif
edit: Moreover , even if the rectangle is visible, it is bad drawn against an other polygon ( a block ).
I think it is due to the same problem..

Share this post


Link to post
Share on other sites
Advertisement
You have two problems here.

To make the 'floor' visible from both sides either change D3DRS_CULLMODE to D3DCULL_NONE or duplicate the triangles, but with the opposite vertex winding order.

To make it sort correctly with the cube make sure that D3DRS_ZENABLE and D3DRS_ZWRITEENABLE are set to TRUE, make sure the near and far clip planes are sensible (aim for a ratio of about 1000:1 or less between the two) and make sure you've created a z-buffer.

Share this post


Link to post
Share on other sites

You have two problems here.

To make the 'floor' visible from both sides either change D3DRS_CULLMODE to D3DCULL_NONE or duplicate the triangles, but with the opposite vertex winding order.

To make it sort correctly with the cube make sure that D3DRS_ZENABLE and D3DRS_ZWRITEENABLE are set to TRUE, make sure the near and far clip planes are sensible (aim for a ratio of about 1000:1 or less between the two) and make sure you've created a z-buffer.

Thank you Adam!

Firstly i'll try to fix my zbuffer trouble.
Actually there was no zbuffer before.
I mean, I used to believe that DX automatically initializes it, so my presentation parameters were these:


d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.hDeviceWindow = hwnd;

With them the cube and the floor didn't have any depth checking.
Still, if i change my pp in this way:


d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.hDeviceWindow = hwnd;

nothing is visible.
Even if I set this:



pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);


So, where is the problem? I'm so confused..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!