rovolution

06-29-2010, 12:50 PM

Hey all,

So i am generating a half sphere that slants upwards.

I use the following code

for (ph=0;ph<90;ph+=d)

{

glBegin(GL_QUAD_STRIP);

for (th=180;th<=360;th+=180)

{

glVertex3d(Sin(th)*Cos(ph) + 0.1, Sin(ph) + 0.1, Cos(th)*Cos(ph));

glVertex3d(1.1 * Sin(th)*Cos(ph) + 0.1, 1.2 * Sin(ph) + 0.16, Cos(th)*Cos(ph) * 1.4);

glVertex3d(Sin(th)*Cos(ph + d) + 0.1 , Sin(ph + d) + 0.1 , Cos(th)*Cos(ph + d));

glVertex3d(1.1 * Sin(th)*Cos(ph + d) + 0.1 , 1.2 * Sin(ph + d) + 0.16 , Cos(th)*Cos(ph + d) * 1.4);

}

glEnd();

}

How would i derive proper normal vectors for the vertices of this shape such that it would make the surface appear curved? I understand how it works for a normal sphere but not sure how it works in my curved situation

Thanks!

So i am generating a half sphere that slants upwards.

I use the following code

for (ph=0;ph<90;ph+=d)

{

glBegin(GL_QUAD_STRIP);

for (th=180;th<=360;th+=180)

{

glVertex3d(Sin(th)*Cos(ph) + 0.1, Sin(ph) + 0.1, Cos(th)*Cos(ph));

glVertex3d(1.1 * Sin(th)*Cos(ph) + 0.1, 1.2 * Sin(ph) + 0.16, Cos(th)*Cos(ph) * 1.4);

glVertex3d(Sin(th)*Cos(ph + d) + 0.1 , Sin(ph + d) + 0.1 , Cos(th)*Cos(ph + d));

glVertex3d(1.1 * Sin(th)*Cos(ph + d) + 0.1 , 1.2 * Sin(ph + d) + 0.16 , Cos(th)*Cos(ph + d) * 1.4);

}

glEnd();

}

How would i derive proper normal vectors for the vertices of this shape such that it would make the surface appear curved? I understand how it works for a normal sphere but not sure how it works in my curved situation

Thanks!