 Hey I have a sphere that I created manually and am now trying to calculate the normals so that it shades correctly. I am shining a spotlight on the sphere from the camera’s position. The light shines but instead of the sphere looking like a sphere it looks like it has a grid on it. If anyone knows what I might be doing wrong it would be a life saver!

Here is a link to a picture of the light on the sphere:
http://i173.photobucket.com/albums/w80/Tiburon1186/Untitled-1.jpg
And a pic of the light up close on the sphere:
http://i173.photobucket.com/albums/w80/Tiburon1186/Untitled2.jpg

Below is the code for creating the sphere, calculating the normals, and drawing the sphere.

// Calculates the sphere points.
void make_sphere( OBJECT po, double ray, int rs, int vs ) {
double r,u,t,t_inc,u_inc;
int i,j, level_count;
r = ray;
u_inc = 2
M_PI/rs;
u = -M_PI/2;
for(i=0; i <=rs; i++)
{
t_inc = M_PI/vs;
t=-M_PI/2;
for(j=0; j <=vs; j++)
{
po->vertices[i][j] = (r*cos(t)cos(u));
po->vertices[i][j] = (r
sin(t));
po->vertices[i][j] = (-(r * cos(t)*sin(u)));
po->vertices[i][j] = 1;
t= t+t_inc;
}
u=u+u_inc;

}
Normalize(po, ray); // Calculates Normal vectors
}

// Calculates the normal vectors
{
int i,j;
for(i=0; i <= crt_rs; i++)
{
for(j=0; j <= bcrt_vs; j++)
{
}
}
}
// Draws the sphere and normals.
void draw_sphere(OBJECT *po, int rs, int vs)
{
int i, j;
glBegin(crt_render_mode);
{
glColor3fv(colors[BLUE]);

``````for(i=0; i &lt; rs; i++)
{

for(j=0;j &lt; vs;j++)
{
glNormal3f(po-&gt;normals[i][j],po-&gt;normals[i][j],po-&gt;normals[i][j]);
glVertex4f(po-&gt;vertices[i][j],po-&gt;vertices[i][j],po-&gt;vertices[i][j], po-&gt;vertices[i][j]);
glVertex4f(po-&gt;vertices[i+1][j],po-&gt;vertices[i+1][j],po-&gt;vertices[i+1][j], po-&gt;vertices[i+1][j]);
glVertex4f(po-&gt;vertices[i+1][j+1],po-&gt;vertices[i+1][j+1],po-&gt;vertices[i+1][j+1], po-&gt;vertices[i+1][j+1]);
glVertex4f(po-&gt;vertices[i][j+1],po-&gt;vertices[i][j+1],po-&gt;vertices[i][j+1], po-&gt;vertices[i][j+1]);

}
}

}
``````

glEnd();
}

Just from your figures, I’m guessing that your quads are messed up. Looks like 1 vertex for every quad is at the center of the sphere. Try generating a simpler sphere made up of a dozen or so quads. And don’t generate all of the quads, just generate the first one. I’m betting it will be messed up.

You could also try generating a simpler sphere with your algorithm but rendering it wireframe with no lighting. I think you’re going see a lot of lines (quad edges) going from the surface of the sphere into the center. Good luck.

I generated a wireframe with no lighting and the only abnormality I saw was a single line down the center of the sphere from north pole to south pole. No other criss-crosses or anything like that. Which vertex is at the center? For some reason I haven’t been able to find it.

I also did an output of all the points in the array and none are 0,0,0 (which would be the center of the sphere. I’m not sure how it’s getting to the center…?

Sounds like your vertices are correct but the poly definitions are messed up. What happens if you try to draw one quad only?

Drawing only one quad I get an extremely slender pie shaped quad going from the center of where the sphere would be to where the radius would be.

Which is exactly what was brought up in an earlier post. All of your polygons are messed up in the same way. I leave it up to you to debug your code. Looks like you are computing the vertex coordinates correctly, but that something is off in the indexing you are using in the glVertex commands between glBegin and glEnd.