PDA

View Full Version : Material-Light problem



Maxmagnus
09-05-2002, 03:01 AM
Hi guy's,
I have this problem:
I have couple of objects which are linked to eache other (simple objects)
and one light source.
The problem is that objects that are closest to the center O(0,0,0) at the start
of runing have the ligher coulor than others that are linked to them and are
further from center.
I have tried to change the position of light, and to rotate objects but the diferance
in their coulors do not change.
I have defined their coulors this way

void init(void)
{ GLfloat mat_ambijentsko[4]={.11,.6,.11,1.};
GLfloat mat_difuzno[4]={.43,.47,.54,1};
GLfloat mat_specular[4]={.55,.55,.95,1.};

GLfloat pozicija_svetla[4]={0,0,20.,.0};

//druge vrednosti za svetlo
GLfloat ambijentsko_svetlo[4]={.0,.0,.0,0};
GLfloat difuzno_svetlo[4]={.3,.3,.3,0};
GLfloat specular_svetlo[4]={.3,.3,.3,0};

glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);

glLightfv(GL_LIGHT0,GL_AMBIENT,ambijentsko_svetlo) ;
glLightfv(GL_LIGHT0,GL_DIFFUSE,difuzno_svetlo);
glLightfv(GL_LIGHT0,GL_SPECULAR,specular_svetlo);
glLightfv(GL_LIGHT0,GL_POSITION,pozicija_svetla);

glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_difuzno);
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambijentsko);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_svetlucanje );

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

}

What could be causing this?
thnks
maxmagnus

nexusone
09-05-2002, 04:20 PM
How are you making your normals?
That could be your problem


Originally posted by Maxmagnus:
Hi guy's,
I have this problem:
I have couple of objects which are linked to eache other (simple objects)
and one light source.
The problem is that objects that are closest to the center O(0,0,0) at the start
of runing have the ligher coulor than others that are linked to them and are
further from center.
I have tried to change the position of light, and to rotate objects but the diferance
in their coulors do not change.
I have defined their coulors this way

void init(void)
{ GLfloat mat_ambijentsko[4]={.11,.6,.11,1.};
GLfloat mat_difuzno[4]={.43,.47,.54,1};
GLfloat mat_specular[4]={.55,.55,.95,1.};

GLfloat pozicija_svetla[4]={0,0,20.,.0};

//druge vrednosti za svetlo
GLfloat ambijentsko_svetlo[4]={.0,.0,.0,0};
GLfloat difuzno_svetlo[4]={.3,.3,.3,0};
GLfloat specular_svetlo[4]={.3,.3,.3,0};

glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);

glLightfv(GL_LIGHT0,GL_AMBIENT,ambijentsko_svetlo) ;
glLightfv(GL_LIGHT0,GL_DIFFUSE,difuzno_svetlo);
glLightfv(GL_LIGHT0,GL_SPECULAR,specular_svetlo);
glLightfv(GL_LIGHT0,GL_POSITION,pozicija_svetla);

glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_difuzno);
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambijentsko);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_svetlucanje );

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

}

What could be causing this?
thnks
maxmagnus

Maxmagnus
09-06-2002, 03:20 PM
The problem might be with the vectors, but since I am using glutSolidSphere
- which manages vetors automaticly it might be linked with the light.
I am not sure is it's vector managed automaticly too.
Also I am not sure why the coulors would stay in the same order from
the lighest to darkest when all objects got rotated.
maxmagnus