Jump to content
  • Advertisement
Sign in to follow this  
combatc2

Light reflects wrong way

This topic is 4424 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

I am building a white cube that rotates. I have 5 faces completed(they reflect the light the right way, etc.) but on the very bottom face, the light reflects up inside of the rest of the cube instead of reflecting down
// Other faces are defined above and have been snipped

	// Bottom face
	v[20] = Vertex(0.0, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f);
	v[21] = Vertex(0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f);
	v[22] = Vertex(1.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f);
	v[23] = Vertex(1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f);

        // And then I have my directional light
        D3DLIGHT9 dir;
	::ZeroMemory(&dir, sizeof(dir));
	dir.Type = D3DLIGHT_DIRECTIONAL;
	dir.Diffuse = white;
	dir.Specular = white;
	dir.Ambient = white;
	dir.Direction = D3DXVECTOR3(1.0f, 0.0f, 1.0f);
	
	Device->SetLight(0, &dir);
	Device->LightEnable(0, true);
	Device->SetRenderState(D3DRS_NORMALIZENORMALS, true);

When I make the Vertice calls, the normal Y is set to -1.0f which should make it reflect light downward but it still reflects upward even with NORMALIZENORMALS. Any help is greatly appreciated. Thanks, Carl

Share this post


Link to post
Share on other sites
Advertisement

struct Vertex {
Vertex() { }
Vertex(float x, float y, float z) {
_x = x; _y = y; _z = z;
}

Vertex(float x, float y, float z, float nx, float ny, float nz) {
_x = x; _y = y; _z = z;
_nx = nx; _ny = ny; _nz = nz;
}

Vertex(float x, float y, float z, D3DCOLOR c) {
_x = x; _y = y; _z = z; color = c;
}
float _x, _y, _z, _nx, _ny, _nz;
D3DCOLOR color;
};

#define FVF_VERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)



I'm using the second constructor(obviously) and I do make a call to:
Device->SetFVF(FVF_VERTEX);



Thanks again,
Carl

Share this post


Link to post
Share on other sites
I think you need to include D3DFVF_NORMAL as part of your flexible vertex format.


edit...

Dang, too slow...

You should probably assign a colour value as well. Or at least default it to something in the vertex constructor.

Share this post


Link to post
Share on other sites
I now have:

#define FVF_VERTEX (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE)

but that doesn't seem to work either?

Carl

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!