I hate lights

Started by
13 comments, last by Trillian 18 years, 6 months ago
there it goes. [smile] I sent it to you.

Good luck with it.
Advertisement
I don't think thats the problem because it is still lit with RGB 0 0 0 for the light...


PS : TX streamer, i'll look at these. (but I don't think i've ever installed the "basic" sdk o_O)
Quote:Original post by Trillian
I don't think thats the problem because it is still lit with RGB 0 0 0 for the light...


PS : TX streamer, i'll look at these. (but I don't think i've ever installed the "basic" sdk o_O)


Too bad :) there are samples that you can't find in any DirectX 9.0a-b-c "Update".

You're welcome [smile]
Quote:Original post by Trillian
the mesh should have normals (I put D3DFVF_NORMAL in my CloneMeshFVF) but not the other objects

Specifying D3DFVF_NORMAL in an ID3DXMesh::CloneMeshFVF() call will NOT generate normals for your object. It just allocates space (per vertex) for a normal vector. What exactly it'll be filled with is anyones guess [smile]

Try calling D3DXComputeNormals() after the cloning process.

Correct normals are required for fixed-function lighting.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Now I have made a new file to start from zero implementing lights and my directional light WORKS!!!!

BUT! (I knoe you guys hate "but"s)

I made a D3DXMesh cylinder and when lit, it flashes really annoyingly.

now I have decided to put my ENTIRE script (almost)!

LPD3DXMESH Cylinder = 0;D3DMATERIAL9 DefaultMaterial;D3DLIGHT9 Light;bool Setup(){	pD3DDevice->SetRenderState(D3DRS_ZENABLE,  true );	pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);	pD3DDevice->SetRenderState(D3DRS_LIGHTING, true);	pD3DDevice->SetRenderState(D3DRS_AMBIENT,RGB(0,0,0));	pD3DDevice->SetRenderState(D3DRS_SPECULARENABLE,true);	return true;}bool Init(){	ZeroMemory( &Light, sizeof(Light) );	pD3DDevice->SetRenderState(D3DRS_LIGHTING, true);	//pD3DDevice->SetRenderState(D3DRS_AMBIENT,RGB(0.0f,1.0f,1.0f));	Light.Type	    = D3DLIGHT_DIRECTIONAL;	Light.Ambient   = D3DYCOLOR_WHITE * 0.6f;	Light.Diffuse   = D3DYCOLOR_WHITE;	Light.Specular  = D3DYCOLOR_WHITE * 0.3f;	//Light.Position  = D3DXVECTOR3(0.0f, 3.0f, -1.0f);	Light.Direction = D3DXVECTOR3(1.0f, 0.0f, 0.0f);	Light.Range	    = 0.0f;	Light.Falloff   = 0.0f;	Light.Attenuation0 = 1.0f;	Light.Attenuation1 = 0.0f;	Light.Attenuation2 = 0.0f;	pD3DDevice->SetLight(0, &Light);	pD3DDevice->LightEnable(0, true);	pD3DDevice->LightEnable(0, TRUE);	DefaultMaterial.Ambient  = D3DYCOLOR_WHITE;	DefaultMaterial.Diffuse  = D3DYCOLOR_WHITE;	DefaultMaterial.Emissive = D3DYCOLOR_BLACK;	DefaultMaterial.Specular = D3DYCOLOR_WHITE;	DefaultMaterial.Power=5.0f;	pD3DDevice->SetMaterial(&DefaultMaterial);	pD3DDevice->SetRenderState(D3DRS_LIGHTING, true);	pD3DDevice->SetLight(0, &Light);	pD3DDevice->LightEnable(0, true);	LPD3DXMESH TempMesh = 0;	D3DXCreateCylinder(pD3DDevice, 2.0f, 2.0f, 4.0f, 40, 40 ,&TempMesh, 0);	TempMesh->CloneMeshFVF(0,D3DFVF_XYZ | D3DFVF_NORMAL,pD3DDevice,&Cylinder);	SAFE_RELEASE(TempMesh);	D3DXComputeNormals(Cylinder,NULL);	return true;}bool Update(float timeDelta){	pD3DDevice->Clear( 0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,0.0f), 1.0f, 0 );	/***********************/	pD3DDevice->BeginScene();	/***********************/	Cylinder->DrawSubset(0);	/*********************/	pD3DDevice->EndScene();	/*********************/	pD3DDevice->Present( NULL, NULL, NULL, NULL );	return true;}bool Destroy(){	SAFE_RELEASE(Cylinder);	return true;}


but then that dumb cylinder flashes (mostly on the two circlar sides).

You guys know what causes this?

EDIT -> System:
Intel Pentium 4 CPU 3.00GHz (2CPUs), ~3.00GHz
Microsoft windows XP home edition
512MB RAM
ATI RADEON 9200
DirectX 9.0c (DXSDK august 2005)

This topic is closed to new replies.

Advertisement