//Establish constants used in sphere generation
FLOAT rDeltaRingAngle = (D3DX_PI / m_nRings);
FLOAT rDeltaSegAngle = (2.0f * D3DX_PI / m_nSegments);
//Generate the group of rings for the sphere
for(nCurrentRing = 0; nCurrentRing < m_nRings + 1; nCurrentRing++)
{
FLOAT r0 = sinf(nCurrentRing * rDeltaRingAngle);
FLOAT y0 = cosf(nCurrentRing * rDeltaRingAngle);
//Generate the group of segments for the current ring
for(nCurrentSegment = 0; nCurrentSegment < m_nSegments + 1; nCurrentSegment++)
{
FLOAT x0 = r0 * sinf(nCurrentSegment * rDeltaSegAngle);
FLOAT z0 = r0 * cosf(nCurrentSegment * rDeltaSegAngle);
vNormal.x = x0;
vNormal.y = y0;
vNormal.z = z0;
D3DXVec3Normalize(&vNormal, &vNormal);
//Add one vertex to the strip which makes up the sphere