once again special apologies to SATAN.
since my pc crashed i couldn’t respond.
I started this thread to ask the following question
2. Is it possible to move the light position along with view point?
but i mixed up and typed everthing.
sorry guys.
Actually i’m confused about how to specify normals because already i specified the normals in the way you guys said. But the lighting effect was different one.
Here is my coding for lighting and draw functions
lighting
{
GLfloat globalambient[]={0.830,0.830,0.830,1.0},
diffuse0[]={0.5,0.5,0.5,1.0},
ambient0[]={0.30,0.30,0.30,1.0}, shine=5.0,
speclight[]={0.3,0.3,0.3},
pos0[]={camera aim(x),camera aim(y),camera aim(z),1.0};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,globalambient);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,1.0);
//glLightfv(GL_LIGHT0,GL_AMBIENT,ambi0);
glLightfv(GL_LIGHT0,GL_POSITION,pos0);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diff0);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,speclight);
glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,&shine);
}
draw
{
int INCR=1,i;
double ax,ay,az,bx,by,bz,cx,cy,cz,dx,dy,dz;
float veclen=0,veclen2=0;
for (i=0;i<360;i=i+INCR)
{
ax=x1+r1cos(ipi/180);
ay=y1+r1*(sin(ipi/180))(cos(ang1pi/180));
az=z1+r1(sin(ipi/180))(sin(ang1*pi/180));
bx=x1+r1*cos((i+INCR)*pi/180);
by=y1+r1*(sin((i+INCR)*pi/180))*(cos(ang1*pi/180));
bz=z1+r1*(sin((i+INCR)*pi/180))*(sin(ang1*pi/180));
cx=x2+r2*cos((i+INCR)*pi/180);
cy=y2+r2*(sin((i+INCR)*pi/180))*(cos(ang2*pi/180));
cz=z2+r2*(sin((i+INCR)*pi/180))*(sin(ang2*pi/180));
dx=x2+r2*cos(i*pi/180);
dy=y2+r2*(sin(i*pi/180))*(cos(ang2*pi/180));
dz=z2+r2*(sin(i*pi/180))*(sin(ang2*pi/180));
veclen=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
glNormal3f((x2-x1)/veclen,(y2-y1)/veclen,(z2-z1)/veclen);
//veclen=sqrt(pow((ax-x1),2)+pow((ay-y1),2)+pow((az-z1),2));
//glNormal3f((ax-x1)/veclen,(ay-y1)/veclen,(az-z1)/veclen);
//veclen2=sqrt(pow((dx-x2),2)+pow((dy-y2),2)+pow((dz-z2),2));
//glNormal3f((dx-x2)/veclen,(dy-y2)/veclen,(dz-z2)/veclen);
glBegin(GL_POLYGON);
glVertex3f(ax,ay,az);
glVertex3f(bx,by,bz);
glVertex3f(cx,cy,cz);
glVertex3f(dx,dy,dz);
glEnd();
}
}
x1,y1,z1-centre of circle1
x2,y2,z2-centre of circle2
ang1,ang2 - angle of the plane which holds the circles with respect to world cooordinates
r1,r2-radius of circles
method of drawing the tunnel
using centre points & radius, vertices of circles are calculated and they are joined by polygons
now my problem I can’t get the lighting effect with shades and shininess of the surface
Hope everybody understood what my problem is.
pl