Blinking light?

xSwan

Newcomer
Joined
Jun 15, 2003
Messages
20
Location
Denmark
Take a look at this, the code is optimal, but I just want to know, why is the light flicking(flashing) then I move the mouse to look around it??
 

Attachments

This is a guess, but it looks like all of your normals are... well, weird. :)

Normally a normal is a unit vector (dot product is 1). You've got some normals defined as (-5, 0, 0) which is odd. Since the only geometry I see is a cube (12 triangles), your normals are very likely to be either (1, 0, 0) or (0, 1, 0) or (0, 0, 1). Other normals (something like (0.2, 0.4, 0.1)) are generally created by a 3d Drawing program.

When the normal is off, the lighting calculations built into Direct3D behave oddly, including making things too dark or too light or just not having the light blend across a surface quite right (compared to what's expected - the math is working right).

I noticed that in loadGeometry, you also define 3 vectors: v0, v1, v2, and v3. They're used in calls to PositionNormalTextured as both the position AND normal vector. I think you'll probably want only one vector for the normal. The position vector can change according to the position you need (I didn't check your code for accuracy on position though the cube does draw).

-Nerseus
 
Well, I think I maked out why it my self, it was becurse the light was "in" the wall, so sometime it get on the one side, and some time om the other side :-\

But, U are talking about the normal, i realy dont understand this, can U descripe them to me, or give some link where to read of it?
 
A normal is a common graphics term, you can read more on MANY websites on 3D graphics.

Basically, there are vertex normals and polygon normals. The kind you're using are polygon normals. Since you're polygons are always simple triangles and they're all facing at very standard angles (all at right angles from each other), you can use a normal that always points in a particular direction (straight up, down, left, right, into the screen or out of the screen). The DX help has some pictures to help explain what a normal is and also contains a lot of info on how DX uses them to calculate lights.

-Ner
 
Back
Top