Archived

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

My mesh is see through for some reason!

This topic is 5040 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 my mesh is see through for some reason, like, its a tiger and i can see its legs through the body. Ive never noticed this before, but its doing it... i recently set it to grey background instead of black Images of whats happening.. http://users.bigpond.net.au/andrews/problem.jpg (had a link but something weird happened, browser kept going to it automatically ,also not finding it) i am drawing it like so:
	void draw()
	{
		for( int i=0; i<lp_NumMaterials; i++ )
		{
				
				lp_Device->SetMaterial( &lp_MeshMaterials[i] );
			
				lp_Device->SetTexture( 0, lp_MeshTextures[i] );
				lp_Mesh->DrawSubset( i );
		}
	}
};
ive got the lighting off so all ive set is the view and world matrices. i dont know why its doing this, any ideas? thanks, [edited by - johnnyBravo on February 22, 2004 5:53:24 AM]

Share this post


Link to post
Share on other sites
ok this is what ive got:

lp_Device->SetRenderState( D3DRS_ZENABLE, TRUE );
lp_Device->SetRenderState( D3DRS_AMBIENT, 0xffffffff );

DWORD bgColour = D3DCOLOR_XRGB(200,200,200);
lp_Device->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, bgColour, 1.0f, 0);

the only options really going onto the d3d device.
still its see through.

ive tried comparing it to the mesh tutorial and looks basically the same. Any thing else it could be ?

thanks,


[edited by - johnnyBravo on February 23, 2004 2:21:02 AM]

[edited by - johnnyBravo on February 23, 2004 2:21:36 AM]

Share this post


Link to post
Share on other sites
This won't help at all, but I had this same problem. I restarted the project, and it was fixed, so I must've changed something in the code. I'll look around and see if I can find it, but I think my dad deleted it.

Ok, I found it. If you want I can email it (its somewhat large to post). Here's the device creation code:

// Direct3D Creation

g_pInterface = Direct3DCreate8(D3D_SDK_VERSION);

if(g_pInterface == NULL)
{
LogError((char*)g_sAppName,".txt","Failure creating g_pInterface.");
g_iErrorLine = __LINE__;
}

D3DPRESENT_PARAMETERS PresentParams;
ZeroMemory(&PresentParams,sizeof(D3DPRESENT_PARAMETERS));
PresentParams.BackBufferWidth = g_iScreenWidth;
PresentParams.BackBufferHeight = g_iScreenHeight;
PresentParams.BackBufferFormat = g_fmtScreenFormat;
PresentParams.hDeviceWindow = g_hWnd;
PresentParams.Windowed = g_bWindowed;
PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
PresentParams.EnableAutoDepthStencil = TRUE;
PresentParams.AutoDepthStencilFormat = D3DFMT_D16;

HRESULT hResult = g_pInterface->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,g_hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&PresentParams,&g_pDevice);

if(FAILED(hResult))
{
LogError((char*)g_sAppName,".txt","Failure during call to CreateDevice.");
g_iErrorLine = __LINE__;
}

hResult = g_pDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&g_pBackBuffer);

if(FAILED(hResult))
{
LogError((char*)g_sAppName,".txt","Failure during call to GetBackBuffer.");
g_iErrorLine = __LINE__;
}

// Setup the world matrix

D3DXMATRIX matWorld;
D3DXMATRIX matRotX,matRotY,matRotZ;
D3DXMATRIX matTrans;
D3DXMATRIX matScale;

D3DXMatrixRotationX(&matRotX,D3DXToRadian(RotX));
D3DXMatrixRotationY(&matRotY,D3DXToRadian(RotY));
D3DXMatrixRotationZ(&matRotZ,D3DXToRadian(RotZ));

D3DXMatrixTranslation(&matTrans,TransX,TransY,TransZ);

D3DXMatrixScaling(&matScale,1.0f,1.0f,1.0f);

D3DXMatrixIdentity(&matWorld);

D3DXMatrixMultiply(&matWorld,&matWorld,&matScale);
D3DXMatrixMultiply(&matWorld,&matWorld,&matRotX);
D3DXMatrixMultiply(&matWorld,&matWorld,&matRotY);
D3DXMatrixMultiply(&matWorld,&matWorld,&matRotZ);
D3DXMatrixMultiply(&matWorld,&matWorld,&matTrans);

g_pDevice->SetTransform(D3DTS_WORLD,&matWorld);
// Setup the view matrix

D3DXMATRIX matView;
D3DXVECTOR3 vecVP(0.0f,-3.0f,-5.0f),vecTP(0.0f,0.0f,0.0f),vecUp(0.0f,1.0f,0.0f);

D3DXMatrixLookAtLH(&matView,&vecVP,&vecTP,&vecUp);
// Setup the projection matrix

float FOV = D3DX_PI/4;
float Aspect = (float)g_iScreenWidth / (float)g_iScreenHeight;

D3DXMATRIX matProj;

D3DXMatrixPerspectiveFovLH(&matProj,FOV,Aspect,1.0f,1000.0f);

g_pDevice->SetTransform(D3DTS_PROJECTION,&matProj);

g_pDevice->SetRenderState(D3DRS_LIGHTING,TRUE);
g_pDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
g_pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE);
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
g_pDevice->SetRenderState(D3DRS_ALPHATESTENABLE,TRUE);

D3DLIGHT8 Light;
ZeroMemory(&Light,sizeof(D3DLIGHT8));

Light.Type = D3DLIGHT_POINT;
Light.Diffuse.r = 1.0f;
Light.Diffuse.g = 1.0f;
Light.Diffuse.b = 1.0f;
Light.Position = D3DXVECTOR3(0,0,0);
Light.Range = 100.0f;
Light.Attenuation0 = 1.0f;

g_pDevice->SetLight(0,&Light);
g_pDevice->LightEnable(0,TRUE);


/*
I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)
*/

[edited by - Programmer16 on February 23, 2004 2:56:34 AM]

Share this post


Link to post
Share on other sites