- Main Page
- Classes
- Files

- File List
- File Members

# flGraphics3d.c

Go to the documentation of this file.

    00001 #include "flGlobal.h"
    00002 #if FL_GRAPHICS_3D != 0
    00003 #include <pspgu.h>
    00004 #include <pspgum.h>
    00005
    00006 #if FL_MATH == 0
    00007 #include <math.h>
    00008 #endif
    00009
    00010 #if FL_INCLUDE_ALL_C == 0
    00011 #include "flGraphics3d.h"
    00012 #include "flGraphics.h"
    00013 #include "flMemory.h"
    00014
    00015 #if FL_COLOR != 0
    00016 #include "flColor.h"
    00017 #endif
    00018
    00019 #if FL_MATH != 0
    00020 #include "flMath.h"
    00021 #endif
    00022 #endif
    00023
    00024 void graphics3dDrawOrigin() {
    00025      sceGuDisable(GU_TEXTURE_2D);
    00026
    00027      sceGumPushMatrix();
    00028      sceGumLoadIdentity();
    00029
    00030      vertcVf* tempVerts = (vertcVf*)sceGuGetMemory(sizeof(vertcVf) * 7);
    00031
    00032      tempVerts[0].vertX = -0.5f; tempVerts[0].vertY = 0.0f; tempVerts[0].vertZ = 0.0f; tempVerts[0].vertColor = 0xF003;
    00033      tempVerts[1].vertX = +0.5f; tempVerts[1].vertY = 0.0f; tempVerts[1].vertZ = 0.0f; tempVerts[1].vertColor = 0xF77F;
    00034
    00035      tempVerts[2].vertX = 0.0f; tempVerts[2].vertY = -0.5f; tempVerts[2].vertZ = 0.0f; tempVerts[2].vertColor = 0xF030;
    00036      tempVerts[3].vertX = 0.0f; tempVerts[3].vertY = +0.5f; tempVerts[3].vertZ = 0.0f; tempVerts[3].vertColor = 0xF7F7;
    00037
    00038      tempVerts[4].vertX = 0.0f; tempVerts[4].vertY = 0.0f; tempVerts[4].vertZ = -0.5f; tempVerts[4].vertColor = 0xF300;
    00039      tempVerts[5].vertX = 0.0f; tempVerts[5].vertY = 0.0f; tempVerts[5].vertZ = +0.5f; tempVerts[5].vertColor = 0xFF77;
    00040
    00041      sceGumDrawArray(GU_LINES, GU_COLOR_4444 | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 6, 0, tempVerts);
    00042      sceGumPopMatrix();
    00043      sceGuEnable(GU_TEXTURE_2D);
    00044 }
    00045
    00046 void graphics3dDrawCubeWireframe() {
    00047      sceGuDisable(GU_TEXTURE_2D);
    00048
    00049      vertVf* tempVerts = (vertVf*)sceGuGetMemory(sizeof(vertVf) * 24);
    00050
    00051      // Vertical struts
    00052      tempVerts[0].vertX = -0.5f; tempVerts[0].vertY = -0.5f; tempVerts[0].vertZ = -0.5f;
    00053      tempVerts[1].vertX = -0.5f; tempVerts[1].vertY = +0.5f; tempVerts[1].vertZ = -0.5f;
    00054      tempVerts[2].vertX = +0.5f; tempVerts[2].vertY = -0.5f; tempVerts[2].vertZ = -0.5f;
    00055      tempVerts[3].vertX = +0.5f; tempVerts[3].vertY = +0.5f; tempVerts[3].vertZ = -0.5f;
    00056      tempVerts[4].vertX = -0.5f; tempVerts[4].vertY = -0.5f; tempVerts[4].vertZ = +0.5f;
    00057      tempVerts[5].vertX = -0.5f; tempVerts[5].vertY = +0.5f; tempVerts[5].vertZ = +0.5f;
    00058      tempVerts[6].vertX = +0.5f; tempVerts[6].vertY = -0.5f; tempVerts[6].vertZ = +0.5f;
    00059      tempVerts[7].vertX = +0.5f; tempVerts[7].vertY = +0.5f; tempVerts[7].vertZ = +0.5f;
    00060
    00061      // Horizontal struts
    00062      tempVerts[8].vertX = -0.5f; tempVerts[8].vertY = -0.5f; tempVerts[8].vertZ = -0.5f;
    00063      tempVerts[9].vertX = +0.5f; tempVerts[9].vertY = -0.5f; tempVerts[9].vertZ = -0.5f;
    00064      tempVerts[10].vertX = -0.5f; tempVerts[10].vertY = +0.5f; tempVerts[10].vertZ = -0.5f;
    00065      tempVerts[11].vertX = +0.5f; tempVerts[11].vertY = +0.5f; tempVerts[11].vertZ = -0.5f;
    00066      tempVerts[12].vertX = -0.5f; tempVerts[12].vertY = -0.5f; tempVerts[12].vertZ = +0.5f;
    00067      tempVerts[13].vertX = +0.5f; tempVerts[13].vertY = -0.5f; tempVerts[13].vertZ = +0.5f;
    00068      tempVerts[14].vertX = -0.5f; tempVerts[14].vertY = +0.5f; tempVerts[14].vertZ = +0.5f;
    00069      tempVerts[15].vertX = +0.5f; tempVerts[15].vertY = +0.5f; tempVerts[15].vertZ = +0.5f;
    00070
    00071      // Depth struts
    00072      tempVerts[16].vertX = -0.5f; tempVerts[16].vertY = -0.5f; tempVerts[16].vertZ = -0.5f;
    00073      tempVerts[17].vertX = -0.5f; tempVerts[17].vertY = -0.5f; tempVerts[17].vertZ = +0.5f;
    00074      tempVerts[18].vertX = +0.5f; tempVerts[18].vertY = -0.5f; tempVerts[18].vertZ = -0.5f;
    00075      tempVerts[19].vertX = +0.5f; tempVerts[19].vertY = -0.5f; tempVerts[19].vertZ = +0.5f;
    00076      tempVerts[20].vertX = -0.5f; tempVerts[20].vertY = +0.5f; tempVerts[20].vertZ = -0.5f;
    00077      tempVerts[21].vertX = -0.5f; tempVerts[21].vertY = +0.5f; tempVerts[21].vertZ = +0.5f;
    00078      tempVerts[22].vertX = +0.5f; tempVerts[22].vertY = +0.5f; tempVerts[22].vertZ = -0.5f;
    00079      tempVerts[23].vertX = +0.5f; tempVerts[23].vertY = +0.5f; tempVerts[23].vertZ = +0.5f;
    00080
    00081      sceGumDrawArray(GU_LINES, GU_VERTEX_32BITF | GU_TRANSFORM_3D, 24, 0, tempVerts);
    00082      sceGuEnable(GU_TEXTURE_2D);
    00083 }
    00084
    00085 void graphics3dDrawCube() {
    00086      if(graphicsWireframe)
    00087           graphics3dDrawCubeWireframe();
    00088      sceGuDisable(GU_TEXTURE_2D);
    00089
    00090      vertVf* tempVerts = (vertVf*)sceGuGetMemory(sizeof(vertVf) * 18);
    00091
    00092      // Surround
    00093      tempVerts[0].vertX = -0.5f; tempVerts[0].vertY = +0.5f; tempVerts[0].vertZ = -0.5f;
    00094      tempVerts[1].vertX = -0.5f; tempVerts[1].vertY = -0.5f; tempVerts[1].vertZ = -0.5f;
    00095
    00096      tempVerts[2].vertX = +0.5f; tempVerts[2].vertY = +0.5f; tempVerts[2].vertZ = -0.5f;
    00097      tempVerts[3].vertX = +0.5f; tempVerts[3].vertY = -0.5f; tempVerts[3].vertZ = -0.5f;
    00098
    00099      tempVerts[4].vertX = +0.5f; tempVerts[4].vertY = +0.5f; tempVerts[4].vertZ = +0.5f;
    00100      tempVerts[5].vertX = +0.5f; tempVerts[5].vertY = -0.5f; tempVerts[5].vertZ = +0.5f;
    00101
    00102      tempVerts[6].vertX = -0.5f; tempVerts[6].vertY = +0.5f; tempVerts[6].vertZ = +0.5f;
    00103      tempVerts[7].vertX = -0.5f; tempVerts[7].vertY = -0.5f; tempVerts[7].vertZ = +0.5f;
    00104
    00105      tempVerts[8] = tempVerts[0];
    00106      tempVerts[9] = tempVerts[1];
    00107
    00108      // Base
    00109      tempVerts[10].vertX = -0.5f; tempVerts[10].vertY = +0.5f; tempVerts[10].vertZ = -0.5f;
    00110      tempVerts[11].vertX = -0.5f; tempVerts[11].vertY = +0.5f; tempVerts[11].vertZ = +0.5f;
    00111      tempVerts[12].vertX = +0.5f; tempVerts[12].vertY = +0.5f; tempVerts[12].vertZ = +0.5f;
    00112      tempVerts[13].vertX = +0.5f; tempVerts[13].vertY = +0.5f; tempVerts[13].vertZ = -0.5f;
    00113
    00114      // Top
    00115      int i;
    00116      for(i = 14; i < 18; i++) {
    00117           tempVerts[i] = tempVerts[i - 4];
    00118           tempVerts[i].vertY = -0.5f;
    00119      }
    00120
    00121      sceGumDrawArray(GU_TRIANGLE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_3D, 18, 0, tempVerts);
    00122      sceGumDrawArray(GU_TRIANGLE_FAN, GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, 0, &tempVerts[10]);
    00123      sceGumDrawArray(GU_TRIANGLE_FAN, GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, 0, &tempVerts[14]);
    00124
    00125      sceGuEnable(GU_TEXTURE_2D);
    00126 }
    00127
    00128 void graphics3dDrawSphere(u32 inDetail) {
    00129      sceGumPushMatrix();
    00130      vect3f tempScale = (vect3f){ 0.5f, 0.5f, 0.5f };
    00131      sceGumScale(&tempScale);
    00132
    00133      sceGuDisable(GU_TEXTURE_2D);
    00134
    00135      if(inDetail < 3)
    00136           inDetail = 3;
    00137
    00138      vertVf* tempVerts;
    00139      u32 i, j;
    00140
    00141      float tempSin[inDetail + 1];
    00142      float tempCos[inDetail + 1];
    00143      float tempFloat = (MATH_PI * 2.0f) / (float)inDetail;
    00144      for(i = 0; i < inDetail; i++) {
    00145           tempSin[i] = mathSinf((float)i * tempFloat);
    00146           tempCos[i] = mathCosf((float)i * tempFloat);
    00147      }
    00148      tempSin[inDetail] = tempSin[0];
    00149      tempCos[inDetail] = tempCos[0];
    00150
    00151      float tempLatitudes[inDetail];
    00152      for(i = 0; i < inDetail; i++) {
    00153           tempFloat = ((float)i / (float)inDetail);
    00154           tempFloat -= 0.5f;
    00155           tempFloat *= -MATH_PI;
    00156           tempFloat = mathSinf(tempFloat);
    00157           tempLatitudes[i] = tempFloat;
    00158      }
    00159
    00160      float tempScales[inDetail];
    00161      for(i = 0; i < inDetail; i++) {
    00162           tempFloat = ((float)i / (float)inDetail);
    00163           tempFloat -= 0.5f;
    00164           tempFloat *= -MATH_PI;
    00165           tempFloat = mathCosf(tempFloat);
    00166           tempScales[i] = tempFloat;
    00167      }
    00168
    00169      #if FL_GRAPHICS_USEDEGENERATETRIS
    00170      u32 tempVertCount = (((inDetail << 1) * inDetail) + (inDetail << 1)) - 2;
    00171      tempVerts = (vertVf*)sceGuGetMemory(tempVertCount * sizeof(vertVf));
    00172      u32 tempBase = 0;
    00173      u32 tempIndex;
    00174      for(i = 0; i < inDetail; i++) {
    00175           tempVerts[tempBase + 0].vertX = 0.0f;
    00176           tempVerts[tempBase + 0].vertY = 0.0f;
    00177           tempVerts[tempBase + 0].vertZ = 1.0f;
    00178
    00179           if(i > 0) {
    00180                tempBase++;
    00181                tempVerts[tempBase + 0] = tempVerts[tempBase - 1];
    00182           }
    00183
    00184           for(j = 1, tempIndex = 1; j < inDetail; j++, tempIndex += 2) {
    00185                tempVerts[tempBase + tempIndex + 0].vertX = tempSin[i] * tempScales[j];
    00186                tempVerts[tempBase + tempIndex + 0].vertY = tempCos[i] * tempScales[j];
    00187                tempVerts[tempBase + tempIndex + 0].vertZ = tempLatitudes[j];
    00188
    00189                tempVerts[tempBase + tempIndex + 1].vertX = tempSin[i + 1] * tempScales[j];
    00190                tempVerts[tempBase + tempIndex + 1].vertY = tempCos[i + 1] * tempScales[j];
    00191                tempVerts[tempBase + tempIndex + 1].vertZ = tempLatitudes[j];
    00192           }
    00193
    00194           tempVerts[tempBase + (inDetail << 1) - 1].vertX = 0.0f;
    00195           tempVerts[tempBase + (inDetail << 1) - 1].vertY = 0.0f;
    00196           tempVerts[tempBase + (inDetail << 1) - 1].vertZ = -1.0f;
    00197
    00198           if(i < (inDetail - 1)) {
    00199                tempBase++;
    00200                tempVerts[tempBase + (inDetail << 1) - 1] = tempVerts[tempBase + (inDetail << 1) - 2];
    00201           }
    00202
    00203           tempBase += (inDetail << 1);
    00204      }
    00205      sceGumDrawArray(GU_TRIANGLE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_3D, tempVertCount, 0, tempVerts);
    00206      #else
    00207      u32 tempIndex;
    00208      for(i = 0; i < inDetail; i++) {
    00209           tempVerts = (vertVf*)sceGuGetMemory((inDetail << 1) * sizeof(vertVf));
    00210
    00211           tempVerts[0].vertX = 0.0f;
    00212           tempVerts[0].vertY = 0.0f;
    00213           tempVerts[0].vertZ = 1.0f;
    00214
    00215           for(j = 1, tempIndex = 1; j < inDetail; j++, tempIndex += 2) {
    00216                tempVerts[tempIndex + 0].vertX = tempSin[i] * tempScales[j];
    00217                tempVerts[tempIndex + 0].vertY = tempCos[i] * tempScales[j];
    00218                tempVerts[tempIndex + 0].vertZ = tempLatitudes[j];
    00219
    00220                tempVerts[tempIndex + 1].vertX = tempSin[i + 1] * tempScales[j];
    00221                tempVerts[tempIndex + 1].vertY = tempCos[i + 1] * tempScales[j];
    00222                tempVerts[tempIndex + 1].vertZ = tempLatitudes[j];
    00223           }
    00224
    00225           tempVerts[(inDetail << 1) - 1].vertX = 0.0f;
    00226           tempVerts[(inDetail << 1) - 1].vertY = 0.0f;
    00227           tempVerts[(inDetail << 1) - 1].vertZ = -1.0f;
    00228
    00229           sceGumDrawArray(GU_TRIANGLE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_3D, (inDetail << 1), 0, tempVerts);
    00230      }
    00231      #endif
    00232
    00233      sceGuEnable(GU_TEXTURE_2D);
    00234
    00235      sceGumPopMatrix();
    00236 }
    00237
    00238 void graphics3dDrawCubeWireframea(vect3f inLocation, vect3f inDimensions, vect3f inRotation, u32 inColor) {
    00239           sceGumPushMatrix();
    00240           sceGumScale(&inDimensions);
    00241           sceGumRotateXYZ(&inRotation);
    00242           sceGumTranslate(&inLocation);
    00243           sceGuColor(inColor);
    00244           graphics3dDrawCubeWireframe();
    00245           sceGumPopMatrix();
    00246 }
    00247
    00248 void graphics3dDrawCubeColoreda(vect3f inLocation, vect3f inDimensions, vect3f inRotation, u32 inColor) {
    00249           if(graphicsWireframe)
    00250                graphics3dDrawCubeWireframea(inLocation, inDimensions, inRotation, inColor);
    00251           sceGumPushMatrix();
    00252           sceGumScale(&inDimensions);
    00253           sceGumRotateXYZ(&inRotation);
    00254           sceGumTranslate(&inLocation);
    00255           sceGuColor(inColor);
    00256           graphics3dDrawCube();
    00257           sceGumPopMatrix();
    00258 }
    00259
    00260
    00261
    00262 #if FL_TEXTURE != 0
    00263 void graphics3dDrawCubeTextured(Texture* inTex) {
    00264      texBind(inTex);
    00265      if(inTex->texMipMaps)
    00266           sceGuTexFilter(GU_LINEAR_MIPMAP_LINEAR, GU_LINEAR_MIPMAP_LINEAR);
    00267      else
    00268           sceGuTexFilter(GU_LINEAR, GU_LINEAR);
    00269
    00270      vertTfVf* tempVerts = (vertTfVf*)sceGuGetMemory(sizeof(vertTfVf) * 24);
    00271
    00272      // Front
    00273      tempVerts[0].vertX = -0.5f; tempVerts[0].vertY = +0.5f; tempVerts[0].vertZ = -0.5f;
    00274      tempVerts[1].vertX = -0.5f; tempVerts[1].vertY = -0.5f; tempVerts[1].vertZ = -0.5f;
    00275      tempVerts[2].vertX = +0.5f; tempVerts[2].vertY = -0.5f; tempVerts[2].vertZ = -0.5f;
    00276      tempVerts[3].vertX = +0.5f; tempVerts[3].vertY = +0.5f; tempVerts[3].vertZ = -0.5f;
    00277
    00278      // Right
    00279      tempVerts[4] = tempVerts[3];
    00280      tempVerts[5] = tempVerts[2];
    00281      tempVerts[6].vertX = +0.5f; tempVerts[6].vertY = -0.5f; tempVerts[6].vertZ = +0.5f;
    00282      tempVerts[7].vertX = +0.5f; tempVerts[7].vertY = +0.5f; tempVerts[7].vertZ = +0.5f;
    00283
    00284      // Back
    00285      tempVerts[8] = tempVerts[7];
    00286      tempVerts[9] = tempVerts[6];
    00287      tempVerts[10].vertX = -0.5f; tempVerts[10].vertY = -0.5f; tempVerts[10].vertZ = +0.5f;
    00288      tempVerts[11].vertX = -0.5f; tempVerts[11].vertY = +0.5f; tempVerts[11].vertZ = +0.5f;
    00289
    00290      // Left
    00291      tempVerts[12] = tempVerts[11];
    00292      tempVerts[13] = tempVerts[10];
    00293      tempVerts[14] = tempVerts[1];
    00294      tempVerts[15] = tempVerts[0];
    00295
    00296      // Bottom
    00297      tempVerts[16].vertX = -0.5f; tempVerts[16].vertY = +0.5f; tempVerts[16].vertZ = +0.5f;
    00298      tempVerts[17].vertX = -0.5f; tempVerts[17].vertY = +0.5f; tempVerts[17].vertZ = -0.5f;
    00299      tempVerts[18].vertX = +0.5f; tempVerts[18].vertY = +0.5f; tempVerts[18].vertZ = -0.5f;
    00300      tempVerts[19].vertX = +0.5f; tempVerts[19].vertY = +0.5f; tempVerts[19].vertZ = +0.5f;
    00301
    00302      // Top
    00303      tempVerts[20].vertX = -0.5f; tempVerts[20].vertY = -0.5f; tempVerts[20].vertZ = -0.5f;
    00304      tempVerts[21].vertX = -0.5f; tempVerts[21].vertY = -0.5f; tempVerts[21].vertZ = +0.5f;
    00305      tempVerts[22].vertX = +0.5f; tempVerts[22].vertY = -0.5f; tempVerts[22].vertZ = +0.5f;
    00306      tempVerts[23].vertX = +0.5f; tempVerts[23].vertY = -0.5f; tempVerts[23].vertZ = -0.5f;
    00307
    00308      int i;
    00309      for(i = 0; i < 24; i += 4) {
    00310           tempVerts[i + 0].vertU = 1.0f;
    00311           tempVerts[i + 0].vertV = 0.0f;
    00312           tempVerts[i + 1].vertU = 1.0f;
    00313           tempVerts[i + 1].vertV = 1.0f;
    00314           tempVerts[i + 2].vertU = 0.0f;
    00315           tempVerts[i + 2].vertV = 1.0f;
    00316           tempVerts[i + 3].vertU = 0.0f;
    00317           tempVerts[i + 3].vertV = 0.0f;
    00318      }
    00319
    00320      sceGumDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, 0, &tempVerts[0]);
    00321      sceGumDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, 0, &tempVerts[4]);
    00322      sceGumDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, 0, &tempVerts[8]);
    00323      sceGumDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, 0, &tempVerts[12]);
    00324      sceGumDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, 0, &tempVerts[16]);
    00325      sceGumDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, 0, &tempVerts[20]);
    00326 }
    00327
    00328 void graphics3dDrawSphereTextured(u32 inDetail, u8 inMapType, Texture* inTex) {
    00329      sceGumPushMatrix();
    00330      vect3f tempScale = (vect3f){ 0.5f, 0.5f, 0.5f };
    00331      sceGumScale(&tempScale);
    00332
    00333      texBind(inTex);
    00334      if(inTex->texMipMaps)
    00335           sceGuTexFilter(GU_LINEAR_MIPMAP_LINEAR, GU_LINEAR_MIPMAP_LINEAR);
    00336      else
    00337           sceGuTexFilter(GU_LINEAR, GU_LINEAR);
    00338
    00339      if(inDetail < 3)
    00340           inDetail = 3;
    00341
    00342      vertTfVf* tempVerts;
    00343      u32 i, j;
    00344
    00345      float tempSin[inDetail + 1];
    00346      float tempCos[inDetail + 1];
    00347      float tempFloat = (MATH_PI * 2.0f) / (float)inDetail;
    00348      for(i = 0; i < inDetail; i++) {
    00349           tempSin[i] = mathSinf((float)i * tempFloat);
    00350           tempCos[i] = mathCosf((float)i * tempFloat);
    00351      }
    00352      tempSin[inDetail] = tempSin[0];
    00353      tempCos[inDetail] = tempCos[0];
    00354
    00355      float tempLatitudes[inDetail];
    00356      for(i = 0; i < inDetail; i++) {
    00357           tempFloat = ((float)i / (float)inDetail);
    00358           tempFloat -= 0.5f;
    00359           tempFloat *= -MATH_PI;
    00360           tempFloat = mathSinf(tempFloat);
    00361           tempLatitudes[i] = tempFloat;
    00362      }
    00363
    00364      float tempScales[inDetail];
    00365      for(i = 0; i < inDetail; i++) {
    00366           tempFloat = ((float)i / (float)inDetail);
    00367           tempFloat -= 0.5f;
    00368           tempFloat *= -MATH_PI;
    00369           tempFloat = mathCosf(tempFloat);
    00370           tempScales[i] = tempFloat;
    00371      }
    00372
    00373      float tempU[2];
    00374      float tempV;
    00375
    00376      #if FL_GRAPHICS_USEDEGENERATETRIS
    00377      u32 tempVertCount = (((inDetail << 1) * inDetail) + (inDetail << 1)) - 2;
    00378      tempVerts = (vertTfVf*)sceGuGetMemory(tempVertCount * sizeof(vertTfVf));
    00379      u32 tempBase = 0;
    00380      u32 tempIndex;
    00381      for(i = 0; i < inDetail; i++) {
    00382
    00383           tempU[0] = 1.0f - ((float)i / (float)inDetail);
    00384           tempU[1] = 1.0f - ((float)(i + 1) / (float)inDetail);
    00385
    00386           tempVerts[tempBase + 0].vertX = 0.0f;
    00387           tempVerts[tempBase + 0].vertY = 0.0f;
    00388           tempVerts[tempBase + 0].vertZ = 1.0f;
    00389           tempVerts[tempBase + 0].vertU = (tempU[0] + tempU[1]) * 0.5f;
    00390           tempVerts[tempBase + 0].vertV = 0.0f;
    00391
    00392           if(i > 0) {
    00393                tempBase++;
    00394                tempVerts[tempBase + 0] = tempVerts[tempBase - 1];
    00395           }
    00396
    00397           for(j = 1, tempIndex = 1; j < inDetail; j++, tempIndex += 2) {
    00398                if(inMapType == SPHERE_MAP_CYLINDER_EQUAL)
    00399                     tempV = 1.0f - ((tempLatitudes[j] + 1.0f) * 0.5f);
    00400                else
    00401                     tempV = ((float)j / (float)inDetail);
    00402
    00403                tempVerts[tempBase + tempIndex + 0].vertX = tempSin[i] * tempScales[j];
    00404                tempVerts[tempBase + tempIndex + 0].vertY = tempCos[i] * tempScales[j];
    00405                tempVerts[tempBase + tempIndex + 0].vertZ = tempLatitudes[j];
    00406                tempVerts[tempBase + tempIndex + 0].vertU = tempU[0];
    00407                tempVerts[tempBase + tempIndex + 0].vertV = tempV;
    00408
    00409                tempVerts[tempBase + tempIndex + 1].vertX = tempSin[i + 1] * tempScales[j];
    00410                tempVerts[tempBase + tempIndex + 1].vertY = tempCos[i + 1] * tempScales[j];
    00411                tempVerts[tempBase + tempIndex + 1].vertZ = tempLatitudes[j];
    00412                tempVerts[tempBase + tempIndex + 1].vertU = tempU[1];
    00413                tempVerts[tempBase + tempIndex + 1].vertV = tempV;
    00414           }
    00415
    00416           tempVerts[tempBase + (inDetail << 1) - 1].vertX = 0.0f;
    00417           tempVerts[tempBase + (inDetail << 1) - 1].vertY = 0.0f;
    00418           tempVerts[tempBase + (inDetail << 1) - 1].vertZ = -1.0f;
    00419           tempVerts[tempBase + (inDetail << 1) - 1].vertU = (tempU[0] + tempU[1]) * 0.5f;
    00420           tempVerts[tempBase + (inDetail << 1) - 1].vertV = 1.0f;
    00421
    00422           if(i < (inDetail - 1)) {
    00423                tempBase++;
    00424                tempVerts[tempBase + (inDetail << 1) - 1] = tempVerts[tempBase + (inDetail << 1) - 2];
    00425           }
    00426
    00427           tempBase += (inDetail << 1);
    00428      }
    00429      sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, tempVertCount, 0, tempVerts);
    00430      #else
    00431      u32 tempIndex;
    00432      for(i = 0; i < inDetail; i++) {
    00433           tempVerts = (vertTfVf*)sceGuGetMemory((inDetail << 1) * sizeof(vertTfVf));
    00434
    00435           tempU[0] = 1.0f - ((float)i / (float)inDetail);
    00436           tempU[1] = 1.0f - ((float)(i + 1) / (float)inDetail);
    00437
    00438           tempVerts[0].vertX = 0.0f;
    00439           tempVerts[0].vertY = 0.0f;
    00440           tempVerts[0].vertZ = 1.0f;
    00441           tempVerts[0].vertU = (tempU[0] + tempU[1]) * 0.5f;
    00442           tempVerts[0].vertV = 0.0f;
    00443
    00444           for(j = 1, tempIndex = 1; j < inDetail; j++, tempIndex += 2) {
    00445                if(inMapType == SPHERE_MAP_CYLINDER_EQUAL)
    00446                     tempV = 1.0f - ((tempLatitudes[j] + 1.0f) * 0.5f);
    00447                else
    00448                     tempV = ((float)j / (float)inDetail);
    00449
    00450                tempVerts[tempIndex + 0].vertX = tempSin[i] * tempScales[j];
    00451                tempVerts[tempIndex + 0].vertY = tempCos[i] * tempScales[j];
    00452                tempVerts[tempIndex + 0].vertZ = tempLatitudes[j];
    00453                tempVerts[tempIndex + 0].vertU = tempU[0];
    00454                tempVerts[tempIndex + 0].vertV = tempV;
    00455
    00456                tempVerts[tempIndex + 1].vertX = tempSin[i + 1] * tempScales[j];
    00457                tempVerts[tempIndex + 1].vertY = tempCos[i + 1] * tempScales[j];
    00458                tempVerts[tempIndex + 1].vertZ = tempLatitudes[j];
    00459                tempVerts[tempIndex + 1].vertU = tempU[1];
    00460                tempVerts[tempIndex + 1].vertV = tempV;
    00461           }
    00462
    00463           tempVerts[(inDetail << 1) - 1].vertX = 0.0f;
    00464           tempVerts[(inDetail << 1) - 1].vertY = 0.0f;
    00465           tempVerts[(inDetail << 1) - 1].vertZ = -1.0f;
    00466           tempVerts[(inDetail << 1) - 1].vertU = (tempU[0] + tempU[1]) * 0.5f;
    00467           tempVerts[(inDetail << 1) - 1].vertV = 1.0f;
    00468
    00469           sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, (inDetail << 1), 0, tempVerts);
    00470      }
    00471      #endif
    00472
    00473      sceGumPopMatrix();
    00474 }
    00475 #endif
    00476
    00477 #endif