   Sphere generation problem
  I'm attempting to generate Sphere Vertex data based on the sphere games Sky Domes pdf. found at http://www.spheregames.com/files/SkyDomesPDF.zipif i implement the code in the pdf for generating a dome it works, however the dome is on its side. This is easy to fix. The second problem is when i try to extend the Dome into a full SphereYou can see the problem hereBasically instead of extending the sphere it goes back over the Dome.I use the following method to determine the vertices for the domem_pVerts = new sVertexXYZCUV[m_iNumberOfVertices];int n = 0;for(int iPhi = -90; iPhi < 90; iPhi += m_idPhi){for(int iTheta = 0; iTheta < 360; iTheta += m_idTheta){m_pVerts[n].fX = m_fRadius * sinf(iPhi * DTOR) * cosf(DTOR * iTheta);m_pVerts[n].fY = m_fRadius * sinf(iPhi * DTOR) * sinf(DTOR * iTheta);m_pVerts[n].fZ = m_fRadius * cosf(iPhi * DTOR);n++;m_pVerts[n].fX = m_fRadius * sinf((iPhi + m_idPhi) * DTOR) * cosf(iTheta * DTOR);m_pVerts[n].fY = m_fRadius * sinf((iPhi + m_idPhi) * DTOR) * sinf(iTheta * DTOR);m_pVerts[n].fZ = m_fRadius * cosf((iPhi + m_idPhi) * DTOR);n++;m_pVerts[n].fX = m_fRadius * sinf(DTOR * iPhi) * cosf(DTOR * (iTheta + m_idTheta));m_pVerts[n].fY = m_fRadius * sinf(DTOR * iPhi) * sinf(DTOR * (iTheta + m_idTheta));m_pVerts[n].fZ = m_fRadius * cosf(DTOR * iPhi);n++;if(iPhi > -90 && iPhi < 90){m_pVerts[n].fX = m_fRadius * sinf((iPhi + m_idPhi) * DTOR) * cosf(DTOR * (iTheta + m_idTheta));m_pVerts[n].fY = m_fRadius * sinf((iPhi + m_idPhi) * DTOR) * sinf(DTOR * (iTheta + m_idTheta));m_pVerts[n].fZ = m_fRadius * cosf((iPhi + m_idPhi) * DTOR);n++;}}}DTOR is defined as D3DX_PI / 180.0fThis is me attempting to implement the latitude / longitude method :S[Edited by - LordFallout on March 20, 2008 9:42:11 AM]
  I managed to sort the orientation problem by switching the Y and Z co-ordinate calculations.Also, i managed to make a whole sphere, there still exists a problem thoughtI'm not sure if its clear or not from this photo but the vertices are mixed up towards the poles.This was the semi solutionm_pVerts = new sVertexXYZCUV[m_iNumberOfVertices];int n = 0;for(float fPhi = -90; fPhi < 90; fPhi += m_fdPhi){for(float fTheta = 0; fTheta < 360; fTheta += m_fdTheta){m_pVerts[n].fX = m_fRadius * sinf(fPhi * DTOR) * cosf(DTOR * fTheta);m_pVerts[n].fY = m_fRadius * cosf(fPhi * DTOR);if(fPhi < 0)m_pVerts[n].fY = -m_pVerts[n].fY;m_pVerts[n].fZ = m_fRadius * sinf(fPhi * DTOR) * sinf(DTOR * fTheta);n++;m_pVerts[n].fX = m_fRadius * sinf((fPhi + m_fdPhi) * DTOR) * cosf(fTheta * DTOR);m_pVerts[n].fY = m_fRadius * cosf((fPhi + m_fdPhi) * DTOR);if(fPhi < 0)m_pVerts[n].fY = -m_pVerts[n].fY;m_pVerts[n].fZ = m_fRadius * sinf((fPhi + m_fdPhi) * DTOR) * sinf(fTheta * DTOR);n++;m_pVerts[n].fX = m_fRadius * sinf(fPhi * DTOR) * cosf(DTOR * (fTheta + m_fdTheta));m_pVerts[n].fY = m_fRadius * cosf(fPhi * DTOR);if(fPhi < 0)m_pVerts[n].fY = -m_pVerts[n].fY;m_pVerts[n].fZ = m_fRadius * sinf(fPhi * DTOR) * sinf(DTOR * (fTheta + m_fdTheta));n++;m_pVerts[n].fX = m_fRadius * sinf((fPhi + m_fdPhi) * DTOR) * cosf(DTOR * (fTheta + m_fdTheta));m_pVerts[n].fY = m_fRadius * cosf((fPhi + m_fdPhi) * DTOR);if(fPhi < 0)m_pVerts[n].fY = -m_pVerts[n].fY;m_pVerts[n].fZ = m_fRadius * sinf((fPhi + m_fdPhi) * DTOR) * sinf(DTOR * (fTheta + m_fdTheta));n++;}}The initial problem arose because the cos of a number would be the same no matter if it was positive or negative, hence the solution to check if the number is negative or not, i think there might have been a better solution, if anyone notices it, please post for me. I'm going to continue my search.   ;  wow, i've spent the past five hours doing nothing, :) the fix was to for(float fPhi = 0; fPhi < 180; fPhi += m_fdPhi){instead of for(float fPhi = -90; fPhi < 90; fPhi += m_fdPhi){Maybe that'll help someone else out in the future :)Now onto the colouring.   