00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "K3dDrawSphere.h"
00034
00036 void K3dDrawSphere::DrawSpheres()
00037 {
00038 for(int i=0; i<m_pGameData->GetSphereObjSP().GetNum(); i++)
00039 {
00040
00041 K3dSphereObj *pSphere = m_pGameData->GetSphereObjSP().Get(i);
00042
00043 glEnable(GL_BLEND);
00044
00045 glBlendFunc(GL_ONE, GL_ONE);
00046 glPushMatrix();
00047
00048 m_kViewMatrix = *m_pGameData->GetViewMatrix();
00049 m_kModelMatrix = *pSphere->GetMatrix();
00050
00051 m_kViewMatrix.Multiply( m_kModelMatrix);
00052
00053 glLoadMatrixf(m_kViewMatrix.GetMatrix());
00054 int iTextureId = pSphere->GetTextureId();
00055
00056 if(iTextureId > 0)
00057 {
00058
00059 glEnable(GL_TEXTURE_2D);
00060 glBindTexture(GL_TEXTURE_2D, iTextureId);
00061 gluQuadricTexture(m_pQuadricObj, true);
00062 }
00063 glColor3ubv(pSphere->GetColor()->GetColorArray());
00064 gluQuadricDrawStyle(m_pQuadricObj, GLU_FILL);
00065 gluQuadricOrientation(m_pQuadricObj,GLU_OUTSIDE);
00066 gluQuadricNormals(m_pQuadricObj, GLU_SMOOTH);
00067 gluSphere(m_pQuadricObj, pSphere->GetRadius(), pSphere->GetNumSlices(), pSphere->GetNumStacks());
00068 glPopMatrix();
00069
00070 glDisable(GL_BLEND);
00071
00072 glColor3ub( 255, 255, 255 );
00073 }
00074 }