PDA

View Full Version : Lighting problem,



dreamspaced
10-18-2005, 05:33 AM
Hi,

Can you see a problem with this code that generates normals for a mesh? With lighting mode 1 (i.e GL_Light_position x,y,z,1) it works on one side of the plane , but not the other) with a mode of 0, it appreas to work on curve surfaces but no on flat surfaces)

Here's the code I use to set up gl lights,

</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">namespace Vivid3D
{
public class Light : Pivot
{
public int glLight, lightObj;
public static int[] lstack = new int[8];
public static int[] GL_Light = new int[8];
public static void SetupLights()
{
GL_Light[0] = Gl.GL_LIGHT0;
GL_Light[1] = Gl.GL_LIGHT1;
GL_Light[2] = Gl.GL_LIGHT2;
GL_Light[3] = Gl.GL_LIGHT3;
GL_Light[4] = Gl.GL_LIGHT4;
GL_Light[5] = Gl.GL_LIGHT5;
GL_Light[6] = Gl.GL_LIGHT6;
GL_Light[7] = Gl.GL_LIGHT7;
}
public static int RequestLight()
{
for (int j = 0; j < 8; j++)
{
if (lstack[j] == 0)
{
lstack[j] = 1;
Gl.glEnable(GL_Light[j]);
return j;
}
}

return -1;
}
public static void FreeLight(int light)
{
if (light < 0

dreamspaced
10-18-2005, 05:35 AM
Why is it cutting my post in half?

</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">namespace Vivid3D
{
public class Light : Pivot
{
public int glLight, lightObj;
public static int[] lstack = new int[8];
public static int[] GL_Light = new int[8];
public static void SetupLights()
{
GL_Light[0] = Gl.GL_LIGHT0;
GL_Light[1] = Gl.GL_LIGHT1;
GL_Light[2] = Gl.GL_LIGHT2;
GL_Light[3] = Gl.GL_LIGHT3;
GL_Light[4] = Gl.GL_LIGHT4;
GL_Light[5] = Gl.GL_LIGHT5;
GL_Light[6] = Gl.GL_LIGHT6;
GL_Light[7] = Gl.GL_LIGHT7;
}
public static int RequestLight()
{
for (int j = 0; j < 8; j++)
{
if (lstack[j] == 0)
{
lstack[j] = 1;
Gl.glEnable(GL_Light[j]);
return j;
}
}

return -1;
}
public static void FreeLight(int light)
{
if (light < 0

jide
10-18-2005, 07:33 AM
First of all, avoid post twice.
Second, it seems the C or statement is responsible of cutting codes.
Third, if you have a problem with calculating normals, the maths forum seems to suit best.