Directx 9 light material
-
Hallo,
ich will ein Licht initialisieren, jedoch leuchtet es seltsamerweise nur mit folgenden Einstellungen:light.Diffuse.r = -107374176.0f; light.Diffuse.g = -107374176.0f; light.Diffuse.b = -107374176.0f; light.Diffuse.a = -107374176.0f;
Wobei es doch eigentlich mit diesen Einstellungen leuchten sollte:
light.Diffuse.r = 1.0f; light.Diffuse.g = 1.0f; light.Diffuse.b = 1.0f; light.Diffuse.a = 1.0f;
Vermutlich ist es ein total dämlicher kleiner Fehler, aber ich komm einfach nicht auf die Lösung. Hier noch Teile von dem restlichen Code:
d3dDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 ); d3dDevice->SetRenderState(D3DRS_LIGHTING, TRUE); d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); d3dDevice->SetRenderState(D3DRS_DITHERENABLE, TRUE); d3dDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE); D3DXMATRIX view; D3DXMATRIX world; D3DXMATRIX projection; D3DXMatrixLookAtLH(&view, &D3DXVECTOR3(0.0f,0.0f,3.0f),&D3DXVECTOR3(0.0f,0.0f,0.0f),&D3DXVECTOR3(0.0f,1.0f,0.0f)); D3DXMatrixPerspectiveFovLH(&projection, D3DXToRadian(45),(float)width/(float)height,1.0f,100.0f); d3dDevice->SetTransform(D3DTS_VIEW, &view); d3dDevice->SetTransform(D3DTS_PROJECTION, &projection);
D3DLIGHT9 light; light.Type = D3DLIGHT_POINT; light.Diffuse.r = -107374176.0f; light.Diffuse.g = -107374176.0f; light.Diffuse.b = -107374176.0f; light.Diffuse.a = -107374176.0f; light.Position.x = 0.0f; light.Position.y = 1.0f; light.Position.z = 1.0f; light.Range = 100.0f; light.Attenuation0 = 0.0f; light.Attenuation0 = 0.025f; light.Attenuation0 = 0.0f; d3dDevice->SetLight(0,&light); d3dDevice->LightEnable(0,TRUE); d3dDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(0,0,0));
D3DMATERIAL9 mat; mat.Diffuse.r = 1.0f; mat.Diffuse.g = 1.0f; mat.Diffuse.b = 1.0f; mat.Diffuse.a = 1.0f; mat.Ambient.r = 0.0f; mat.Ambient.g = 0.0f; mat.Ambient.b = 0.0f; mat.Ambient.a = 0.0f; mat.Specular.r = 1.0f; mat.Specular.g = 1.0f; mat.Specular.b = 1.0f; mat.Specular.a = 1.0f; mat.Power = 100.0f; mat.Emissive.r = 0.0f; mat.Emissive.g = 0.0f; mat.Emissive.b = 0.0f; mat.Emissive.a = 0.0f; d3dDevice->SetMaterial(&mat); d3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); d3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); d3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); d3dDevice->SetTexture(0, texture); int zoomf = 4; Vertex fd[3]; fd[0].position = D3DXVECTOR3(0.0f,1.0f,0.0f); fd[1].position = D3DXVECTOR3(1.0f,-1.0f,0.0f); fd[2].position = D3DXVECTOR3(-1.0f,-1.0f,0.0f); fd[0].tposition = D3DXVECTOR2(0.5f*zoomf,1.0f*zoomf); fd[1].tposition = D3DXVECTOR2(1.0f*zoomf,0.0f*zoomf); fd[2].tposition = D3DXVECTOR2(0.0f*zoomf,0.0f*zoomf); fd[0].nposition.x = 0.0f; fd[0].nposition.y = 0.0f; fd[0].nposition.z = 1.0f; fd[1].nposition.x = 0.0f; fd[1].nposition.y = 0.0f; fd[1].nposition.z = 1.0f; fd[2].nposition.x = 0.0f; fd[2].nposition.y = 0.0f; fd[2].nposition.z = 1.0f; d3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, fd, sizeof(Vertex)); d3dDevice->SetTexture(0, NULL);
Ich freu mich auf eure Antworten
mfg lonol15