Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

How come my polygons are see through?

This topic is 4419 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 I'm drawing two tetrahedron back to back, one shorter than the other minus the joining face. And for some reason it is see through, is there anything in my rendering code that could be the culprit? Basically i'm using a directional light, setting the material and setting the cullmode to none.
//view/projection matrices
D3DXMATRIX projectionMatrix;
D3DXMatrixPerspectiveFovLH(&projectionMatrix, D3DX_PI/2, (clientRect.bottom)?(float)clientRect.right/(float)clientRect.bottom:0, 0.00001f,1000000);
d3dDevice->SetTransform(D3DTS_PROJECTION, &projectionMatrix);

D3DXMATRIX viewMatrix;
D3DXMatrixLookAtLH(&viewMatrix, &D3DXVECTOR3(-4,3,-2), &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,1,0));
d3dDevice->SetTransform(D3DTS_VIEW, &viewMatrix);

//begin scene
d3dDevice->Clear(0,0,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(30,50,60),1,0);
d3dDevice->BeginScene();

//
d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
			
//meshes
d3dDevice->SetRenderState(D3DRS_LIGHTING, true);
d3dDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(0,0,0));
d3dDevice->SetRenderState(D3DRS_SPECULARENABLE, TRUE);			
						
D3DLIGHT9 meshLight;
ZeroMemory(&meshLight, sizeof(meshLight));
meshLight.Type = D3DLIGHT_DIRECTIONAL;
meshLight.Specular = D3DXCOLOR(1,0.2f,0.2f,0);
meshLight.Diffuse = D3DXCOLOR(1,0.6f,0.6f,0);
meshLight.Ambient = D3DXCOLOR(0.2f,0.2f,0.2f,0);
D3DXVec3Normalize((D3DXVECTOR3*)&meshLight.Direction, &D3DXVECTOR3(-5,-6,-60));
d3dDevice->SetLight(0, &meshLight);
d3dDevice->LightEnable(0, TRUE);

D3DMATERIAL9 meshMaterial={0};						
meshMaterial.Diffuse=meshMaterial.Specular=meshMaterial.Ambient=D3DXCOLOR(1,1,1,0);
meshMaterial.Power = 20;
d3dDevice->SetMaterial(&meshMaterial);

D3DVERTEXELEMENT9 meshVe[] = {
	{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
	{0, sizeof(D3DXVECTOR3), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},							
	D3DDECL_END()
};

LPDIRECT3DVERTEXDECLARATION9 meshVd;
d3dDevice->CreateVertexDeclaration(meshVe, &meshVd);
d3dDevice->SetVertexDeclaration(meshVd);
meshVd->Release();
			
d3dDevice->SetStreamSource(0, vb, 0, sizeof(MeshVertex));

static float r = 0;
r+=deltaTime;
D3DXMATRIX rotationMatrix;
D3DXMatrixRotationY(&rotationMatrix, r);
d3dDevice->SetTransform(D3DTS_WORLD, &(rotationMatrix));

d3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0,6);

//end scene
d3dDevice->EndScene();
d3dDevice->Present(0,0,0,0);



thx

Share this post


Link to post
Share on other sites
Advertisement
em u mean d3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); ?

i thought that by default waS Already on... though anyway it doesn't make a difference still..

Share this post


Link to post
Share on other sites
I only know basic OpenGL, not D3D, but does D3D have a winding order like OpenGL does? Where only either CCW or CW wound triangles will be visible by default from a certain direction? That was the first idea that poped into my head from reading your problem.

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.

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!