How come my polygons are see through?

Started by
3 comments, last by Xai 17 years, 7 months ago
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
Advertisement
Sanity check: is depth-buffering enabled?
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..
What Colorop? Alphaop? Arguments to both? Which blending args have been set?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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.

This topic is closed to new replies.

Advertisement