objects: behind and in front of

Started by
1 comment, last by Claudio 14 years, 10 months ago
Hi. My problem is that the virtual object A (that is behind of the virtual object B in the virtual envroinment) is graphically always in front of the object B. The current settings are the follows:
 	
ZEnable = true;
CullMode = ccw;
AlphaBlendEnable = true;
BlendOp = add;
SrcBlend = srcalpha;
DestBlend = invsrcalpha;


Are theese settings correct ? or incorrect ? And/Or there are also other parameters to set ? The version of DirectX is 9.
Advertisement
Yes and no. For opaque translucent objects, you'll need to draw them in back-to-front order, otherwise the translucency won't work properly.

Have you actually created a Z-buffer? What is the depth-stencil format set to in your D3DPRESENT_PARAMETERS?
Hi.

The follow are the parameter for the Z-Buffer (like in the site http://www.toymaker.info/Games/html/z_buffer.html and http://www.toymaker.info/Games/html/render_states.html#Zbuffer):

// D3D present parametersD3DPRESENT_PARAMETERS D3Dpp;ZeroMemory(&D3Dpp, sizeof(D3Dpp));// Fill of the structure D3Dpp...D3Dpp.EnableAutoDepthStencil = true;D3Dpp.AutoDepthStencilFormat = D3DFMT_D16;// creation of the device:....


and then:

D3DDev->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); // ZEnableD3DDev->SetRenderState(D3DRS_ZWRITEENABLE, TRUE); D3DDev->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);


But the object A (behind of the object B) is always in front of the object B.

Are the parametrs correct so ? or not ?

This topic is closed to new replies.

Advertisement