//-----------------------------------------------------------------------------
//Name:renderSphere()
//Desc:Createaspherecenteredatcy,cx,czwithradiusr,and
//precisionp.BasedonafunctionWrittenbyPaulBourke.
//http://astronomy.swin.edu.au/~pbourke/opengl/sphere/
//-----------------------------------------------------------------------------
voidSetupSphere(floatcx,floatcy,floatcz,floatr,intp)
{
verNum=(p/2+1)*(p+1);
triNum=p*p*3;//(p/2)*p*2
pVertex=newCVertex[verNum];
pTriIndices=newint[triNum];
constfloatPI=3.14159265358979f;
constfloatTWOPI=6.28318530717958f;
constfloatPIDIV2=1.57079632679489f;
floattheta1=0.0;
floattheta2=0.0;
floattheta3=0.0;
floatex=0.0f;
floatey=0.0f;
floatez=0.0f;
floatpx=0.0f;
floatpy=0.0f;
floatpz=0.0f;
//Disallowanegativenumberforradius.
if(r
我这是opengl下的。你稍微改一下。
http://blog.csdn.net/dizuo/archive/2010/01/05/5135440.aspx
|