Al's Programming Resource Homepage  Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

general.cpp

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include "shared.h"
00003 #include "polygon.h"
00004 #include "camera.h"
00005 #include "texture.h"
00006 #include "light.h"
00007 #include "locmath.h"
00008 #include "bspline.h"
00009 #include "glFont.h"
00010 #include "bsp.h"
00011 #include "tll.h"
00012 #include "plane.h"
00013 #include "mmgr.h"
00014 
00015 extern int numPolygons;
00016 extern int numCameras;
00017 extern int cameraMode;
00018 extern int currentCamera;
00019 extern int numLights;
00020 extern int currentLight;
00021 extern int fps;
00022 extern float multiplier;
00023 extern GLFONT myFont;
00024 extern char HaloTypeName[MAX_PATH];
00025 extern char FireTypeName[MAX_PATH];
00026 extern int numSplines;
00027 extern int lookAtPath;
00028 extern int currentSpline;
00029 extern SPLINE* spline;
00030 extern char SplineFileName[MAX_PATH];
00031 extern PLANE frustum[6];
00032 extern int showportals;
00033 extern int currentleaf;
00034 extern int numcurrentportals;
00035 extern int numleavesvisible;
00036 
00037 
00038 
00039 int SphereInFrustum(VECTOR point, float radius )
00040 {
00041    int p;
00042    int c = 0;
00043    float d;
00044 
00045    for( p = 0; p < 6; p++ )
00046    {
00047       d = frustum[p].nx * point.x + frustum[p].ny * point.y + frustum[p].nz * point.z + frustum[p].Distance;
00048       if( d <= -radius )
00049          return 0;
00050       if( d > radius )
00051          c++;
00052    }
00053    return (c == 6) ? 2 : 1;
00054 }
00055 
00056 bool PointInFrustum(VECTOR point)
00057 {
00058    int p;
00059 
00060    for( p = 0; p < 6; p++ )
00061       if( frustum[p].nx * point.x + frustum[p].ny * point.y + frustum[p].nz * point.z + frustum[p].Distance <= 0 )
00062          return false;
00063    return true;
00064 }
00065 
00066 void ExtractFrustum()
00067 {
00068     float proj[16];
00069     float modl[16];
00070     float clip[16];
00071     float t;
00072     /* Get the current PROJECTION matrix from OpenGL */
00073     glGetFloatv( GL_PROJECTION_MATRIX, proj );
00074     /* Get the current MODELVIEW matrix from OpenGL */
00075     glGetFloatv( GL_MODELVIEW_MATRIX, modl );
00076     /* Combine the two matrices (multiply projection by modelview) */
00077     clip[ 0] = modl[ 0] * proj[ 0] + modl[ 1] * proj[ 4] + modl[ 2] * proj[ 8] + modl[ 3] * proj[12];
00078     clip[ 1] = modl[ 0] * proj[ 1] + modl[ 1] * proj[ 5] + modl[ 2] * proj[ 9] + modl[ 3] * proj[13];
00079     clip[ 2] = modl[ 0] * proj[ 2] + modl[ 1] * proj[ 6] + modl[ 2] * proj[10] + modl[ 3] * proj[14];
00080     clip[ 3] = modl[ 0] * proj[ 3] + modl[ 1] * proj[ 7] + modl[ 2] * proj[11] + modl[ 3] * proj[15];
00081     clip[ 4] = modl[ 4] * proj[ 0] + modl[ 5] * proj[ 4] + modl[ 6] * proj[ 8] + modl[ 7] * proj[12];
00082     clip[ 5] = modl[ 4] * proj[ 1] + modl[ 5] * proj[ 5] + modl[ 6] * proj[ 9] + modl[ 7] * proj[13];
00083     clip[ 6] = modl[ 4] * proj[ 2] + modl[ 5] * proj[ 6] + modl[ 6] * proj[10] + modl[ 7] * proj[14];
00084     clip[ 7] = modl[ 4] * proj[ 3] + modl[ 5] * proj[ 7] + modl[ 6] * proj[11] + modl[ 7] * proj[15];
00085     clip[ 8] = modl[ 8] * proj[ 0] + modl[ 9] * proj[ 4] + modl[10] * proj[ 8] + modl[11] * proj[12];
00086     clip[ 9] = modl[ 8] * proj[ 1] + modl[ 9] * proj[ 5] + modl[10] * proj[ 9] + modl[11] * proj[13];
00087     clip[10] = modl[ 8] * proj[ 2] + modl[ 9] * proj[ 6] + modl[10] * proj[10] + modl[11] * proj[14];
00088     clip[11] = modl[ 8] * proj[ 3] + modl[ 9] * proj[ 7] + modl[10] * proj[11] + modl[11] * proj[15];
00089     clip[12] = modl[12] * proj[ 0] + modl[13] * proj[ 4] + modl[14] * proj[ 8] + modl[15] * proj[12];
00090     clip[13] = modl[12] * proj[ 1] + modl[13] * proj[ 5] + modl[14] * proj[ 9] + modl[15] * proj[13];
00091     clip[14] = modl[12] * proj[ 2] + modl[13] * proj[ 6] + modl[14] * proj[10] + modl[15] * proj[14];
00092     clip[15] = modl[12] * proj[ 3] + modl[13] * proj[ 7] + modl[14] * proj[11] + modl[15] * proj[15];
00093 
00094     /* Extract the numbers for the RIGHT plane */
00095     frustum[0].nx = clip[ 3] - clip[ 0];
00096     frustum[0].ny = clip[ 7] - clip[ 4];
00097     frustum[0].nz = clip[11] - clip[ 8];
00098     frustum[0].Distance = clip[15] - clip[12];
00099     /* Normalize the result */
00100     t = sqrt( frustum[0].nx * frustum[0].nx + frustum[0].ny * frustum[0].ny + frustum[0].nz * frustum[0].nz);
00101     frustum[0].nx /= t;
00102     frustum[0].ny /= t;
00103     frustum[0].nz /= t;
00104     frustum[0].Distance /= t;
00105     /* Extract the numbers for the LEFT plane */
00106     frustum[1].nx = clip[ 3] + clip[ 0];
00107     frustum[1].ny = clip[ 7] + clip[ 4];
00108     frustum[1].nz = clip[11] + clip[ 8];
00109     frustum[1].Distance = clip[15] + clip[12];
00110     /* Normalize the result */
00111     t = sqrt( frustum[1].nx * frustum[1].nx + frustum[1].ny * frustum[1].ny + frustum[1].nz * frustum[1].nz);
00112     frustum[1].nx /= t;
00113     frustum[1].ny /= t;
00114     frustum[1].nz /= t;
00115     frustum[1].Distance /= t;
00116     /* Extract the BOTTOM plane */
00117     frustum[2].nx = clip[ 3] + clip[ 1];
00118     frustum[2].ny = clip[ 7] + clip[ 5];
00119     frustum[2].nz = clip[11] + clip[ 9];
00120     frustum[2].Distance = clip[15] + clip[13];
00121     /* Normalize the result */
00122     t = sqrt( frustum[2].nx * frustum[2].nx + frustum[2].ny * frustum[2].ny + frustum[2].nz * frustum[2].nz);
00123     frustum[2].nx /= t;
00124     frustum[2].ny /= t;
00125     frustum[2].nz /= t;
00126     frustum[2].Distance /= t;
00127     /* Extract the TOP plane */
00128     frustum[3].nx = clip[ 3] - clip[ 1];
00129     frustum[3].ny = clip[ 7] - clip[ 5];
00130     frustum[3].nz = clip[11] - clip[ 9];
00131     frustum[3].Distance = clip[15] - clip[13];
00132     /* Normalize the result */
00133     t = sqrt( frustum[3].nx * frustum[3].nx + frustum[3].ny * frustum[3].ny + frustum[3].nz * frustum[3].nz);
00134     frustum[3].nx /= t;
00135     frustum[3].ny /= t;
00136     frustum[3].nz /= t;
00137     frustum[3].Distance /= t;
00138     /* Extract the FAR plane */
00139     frustum[4].nx = clip[ 3] - clip[ 2];
00140     frustum[4].ny = clip[ 7] - clip[ 6];
00141     frustum[4].nz = clip[11] - clip[10];
00142     frustum[4].Distance = clip[15] - clip[14];
00143     /* Normalize the result */
00144     t = sqrt( frustum[4].nx * frustum[4].nx + frustum[4].ny * frustum[4].ny + frustum[4].nz * frustum[4].nz);
00145     frustum[4].nx /= t;
00146     frustum[4].ny /= t;
00147     frustum[4].nz /= t;
00148     frustum[4].Distance /= t;
00149     /* Extract the NEAR plane */
00150     frustum[5].nx = clip[ 3] + clip[ 2];
00151     frustum[5].ny = clip[ 7] + clip[ 6];
00152     frustum[5].nz = clip[11] + clip[10];
00153     frustum[5].Distance = clip[15] + clip[14];
00154     /* Normalize the result */
00155     t = sqrt( frustum[5].nx * frustum[5].nx + frustum[5].ny * frustum[5].ny + frustum[5].nz * frustum[5].nz);
00156     frustum[5].nx /= t;
00157     frustum[5].ny /= t;
00158     frustum[5].nz /= t;
00159     frustum[5].Distance /= t;
00160 }
00161 
00162 void AddSpline(int Number, LinkedList<SPLINE>& SplineList)
00163 {
00164     SPLINE* spline2 = new SPLINE;
00165     spline2->Active = 1;
00166     spline2->Repeat = 1;
00167     spline2->Degree = 3;
00168     spline2->NumControl = 7;
00169     spline2->NumPoints = 100;
00170     spline2->Control = new VECTOR[100];
00171     spline2->Output = new VECTOR[1000];
00172     spline2->StartTime = 5000;
00173     spline2->EndTime = 25000;
00174     spline2->CopyOfStartTime = spline2->StartTime;
00175     spline2->CopyOfEndTime = spline2->EndTime;
00176 
00177     spline2->Red = ((float)(rand()%226) + 30.0) / 255;
00178     spline2->Green = ((float)(rand()%226) + 30.0) / 255;
00179     spline2->Blue = ((float)(rand()%266) + 30.0) / 255;
00180 
00181     for (int loop = 0; loop < 100; loop++)
00182     {
00183         spline2->Control[loop].x = rand()%60 - 29;  spline2->Control[loop].y = rand()%60 - 29;  spline2->Control[loop].z = rand()%60 - 29;
00184     }
00185 
00186     spline2->linkPosition = Number;   //Set the link position of the spline
00187     SplineList.Insert(spline2);       //Insert spline in linked list
00188 }
00189 
00190 void DeleteSpline(int Number, LinkedList<SPLINE>& SplineList)
00191 {
00192     SPLINE* temp = SplineList.Get(Number);
00193     delete[] temp->Control;
00194     delete[] temp->Output;
00195     SplineList.Delete(Number);
00196     delete temp;
00197 }
00198 
00199 int LoadSplines(char* SplineFileName, LinkedList<SPLINE>& SplineList)
00200 {
00201     const int stringLength = 33;
00202     char tempString[stringLength];
00203     FILE* SplineFile;
00204     SplineFile = fopen(SplineFileName, "rt");
00205     if (!SplineFile)
00206     {
00207         MessageBox(NULL, "Spline File didn't open", "Error", MB_OK | MB_ICONERROR);
00208         return 0;
00209     }
00210     fseek(SplineFile, 0, SEEK_SET);
00211     int InitialNumSplines = numSplines;
00212     if (!fgets(tempString, stringLength, SplineFile))
00213     {
00214         MessageBox(NULL, "Error reading from the spline data file", "Error", MB_OK | MB_ICONERROR);
00215         numSplines = InitialNumSplines;
00216         return FALSE;
00217     }
00218     numSplines = atoi(tempString);
00219     if (InitialNumSplines > numSplines)
00220     {
00221         for (int loop = InitialNumSplines - 1; loop >= numSplines; loop--)
00222         {
00223             DeleteSpline(loop, SplineList);
00224         }
00225     }
00226     if (numSplines > InitialNumSplines)
00227     {
00228         for (int loop = InitialNumSplines; loop < numSplines; loop++)
00229         {
00230             AddSpline(loop, SplineList);
00231         }
00232     }
00233     for (int loop = 0; loop < numSplines; loop++)
00234     {
00235         spline = SplineList.Get(loop);
00236         // Active flag
00237         fgets(tempString, stringLength, SplineFile);
00238         spline->Active = atoi(tempString);
00239         // Repeat flag
00240         fgets(tempString, stringLength, SplineFile);
00241         spline->Repeat = atoi(tempString);
00242         // Degree
00243         fgets(tempString, stringLength, SplineFile);
00244         spline->Degree = atoi(tempString);
00245         // NumControl
00246         fgets(tempString, stringLength, SplineFile);
00247         spline->NumControl = atoi(tempString);
00248         // NumPoints
00249         fgets(tempString, stringLength, SplineFile);
00250         spline->NumPoints = atoi(tempString);
00251         // StartTime
00252         fgets(tempString, stringLength, SplineFile);
00253         spline->StartTime = atof(tempString);
00254         // EndTime
00255         fgets(tempString, stringLength, SplineFile);
00256         spline->EndTime = atof(tempString);
00257         // Red
00258         fgets(tempString, stringLength, SplineFile);
00259         spline->Red = atof(tempString);
00260         // Green
00261         fgets(tempString, stringLength, SplineFile);
00262         spline->Green = atof(tempString);
00263         // Blue
00264         fgets(tempString, stringLength, SplineFile);
00265         spline->Blue = atof(tempString);
00266 
00267         for (int loop2 = 0; loop2 <= spline->NumControl; loop2++)
00268         {
00269             fgets(tempString, stringLength, SplineFile);
00270             spline->Control[loop2].x = atof(tempString);
00271             fgets(tempString, stringLength, SplineFile);
00272             spline->Control[loop2].y = atof(tempString);
00273             fgets(tempString, stringLength, SplineFile);
00274             spline->Control[loop2].z = atof(tempString);
00275         }
00276         spline->CopyOfStartTime = spline->StartTime;
00277         spline->CopyOfEndTime = spline->EndTime;
00278     }
00279 
00280     currentSpline = numSplines - 1;
00281     if (lookAtPath >= numSplines)
00282         lookAtPath = numSplines - 1;
00283     if (fclose(SplineFile))
00284         MessageBox(NULL, "File didn't close", "Error", MB_OK | MB_ICONERROR);
00285     return 1;
00286 }
00287 
00288 void SetSplines(LinkedList<SPLINE>& SplineList)
00289 {
00290     srand((unsigned)time(NULL));
00291     //Create a new spline
00292     for (int loop = 0; loop < numSplines; loop++)
00293     {
00294         AddSpline(loop, SplineList);
00295     }
00296     //Load splines from data file
00297     LoadSplines(SplineFileName, SplineList);
00298 }
00299 
00300 void SetGLLighting(LIGHT* light)         // Loop through and reset all the lights
00301 {
00302     int temp;
00303     for (temp = 0; temp <= numLights; temp++)
00304     {
00305         light[temp].LightNumber = temp;
00306         light[temp].Reset();
00307     }
00308     glEnable(GL_LIGHTING);
00309 }
00310 
00311 void SetGLCamera(CAMERA* camera)          // Loop through and reset all the cameras
00312 {
00313     int temp;
00314     for(temp = 0; temp <= numCameras; temp++)
00315         camera[temp].Reset();
00316 }
00317 
00318 void SetGLVertices(VERTEX* vertex)
00319 {
00320     vertex[0].x = -80;
00321     vertex[0].y = -10;
00322     vertex[0].z = -60;
00323 
00324     vertex[1].x = 20;
00325     vertex[1].y = -10;
00326     vertex[1].z = -60;
00327 
00328     vertex[2].x = 20;
00329     vertex[2].y = -10;
00330     vertex[2].z = -40;
00331 
00332     vertex[3].x = 170;
00333     vertex[3].y = -10;
00334     vertex[3].z = -40;
00335 
00336     vertex[4].x = 170;
00337     vertex[4].y = -10;
00338     vertex[4].z = 40;
00339 
00340     vertex[5].x = 120;
00341     vertex[5].y = -10;
00342     vertex[5].z = 40;
00343 
00344     vertex[6].x = 120;
00345     vertex[6].y = -10;
00346     vertex[6].z = 80;
00347 
00348     vertex[7].x = 160;
00349     vertex[7].y = -10;
00350     vertex[7].z = 80;
00351 
00352     vertex[8].x = 160;
00353     vertex[8].y = -10;
00354     vertex[8].z = 160;
00355 
00356     vertex[9].x = 60;
00357     vertex[9].y = -10;
00358     vertex[9].z = 160;
00359 
00360     vertex[10].x = 60;
00361     vertex[10].y = -10;
00362     vertex[10].z = 80;
00363 
00364     vertex[11].x = 100;
00365     vertex[11].y = -10;
00366     vertex[11].z = 80;
00367 
00368     vertex[12].x = 100;
00369     vertex[12].y = -10;
00370     vertex[12].z = 40;
00371 
00372     vertex[13].x = 20;
00373     vertex[13].y = -10;
00374     vertex[13].z = 40;
00375 
00376     vertex[14].x = 20;
00377     vertex[14].y = -10;
00378     vertex[14].z = 60;
00379 
00380     vertex[15].x = -80;
00381     vertex[15].y = -10;
00382     vertex[15].z = 60;
00383 
00384     vertex[16].x = -80;
00385     vertex[16].y = 10;
00386     vertex[16].z = -60;
00387 
00388     vertex[17].x = 20;
00389     vertex[17].y = 10;
00390     vertex[17].z = -60;
00391 
00392     vertex[18].x = 20;
00393     vertex[18].y = 10;
00394     vertex[18].z = -40;
00395 
00396     vertex[19].x = 170;
00397     vertex[19].y = 10;
00398     vertex[19].z = -40;
00399 
00400     vertex[20].x = 170;
00401     vertex[20].y = 10;
00402     vertex[20].z = 40;
00403 
00404     vertex[21].x = 120;
00405     vertex[21].y = 10;
00406     vertex[21].z = 40;
00407 
00408     vertex[22].x = 120;
00409     vertex[22].y = 10;
00410     vertex[22].z = 80;
00411 
00412     vertex[23].x = 160;
00413     vertex[23].y = 10;
00414     vertex[23].z = 80;
00415 
00416     vertex[24].x = 160;
00417     vertex[24].y = 10;
00418     vertex[24].z = 160;
00419 
00420     vertex[25].x = 60;
00421     vertex[25].y = 10;
00422     vertex[25].z = 160;
00423 
00424     vertex[26].x = 60;
00425     vertex[26].y = 10;
00426     vertex[26].z = 80;
00427 
00428     vertex[27].x = 100;
00429     vertex[27].y = 10;
00430     vertex[27].z = 80;
00431 
00432     vertex[28].x = 100;
00433     vertex[28].y = 10;
00434     vertex[28].z = 40;
00435 
00436     vertex[29].x = 20;
00437     vertex[29].y = 10;
00438     vertex[29].z = 40;
00439 
00440     vertex[30].x = 20;
00441     vertex[30].y = 10;
00442     vertex[30].z = 60;
00443 
00444     vertex[31].x = -80;
00445     vertex[31].y = 10;
00446     vertex[31].z = 60;
00447 
00448     vertex[32].x = -80;
00449     vertex[32].y = 10;
00450     vertex[32].z = 40;
00451 
00452     vertex[33].x = -80;
00453     vertex[33].y = 40;
00454     vertex[33].z = 0;
00455 
00456     vertex[34].x = -80;
00457     vertex[34].y = 10;
00458     vertex[34].z = -40;
00459 
00460     vertex[35].x = 20;
00461     vertex[35].y = 40;
00462     vertex[35].z = 0;
00463 
00464     vertex[36].x = 170;
00465     vertex[36].y = 40;
00466     vertex[36].z = 0;
00467 }
00468 
00469 // Initialize the world data
00470 void SetGLWorld(POLYGON* polygon, TEXTURE* texture, VERTEX* vertex)
00471 {
00472     SetGLVertices(vertex);
00473 
00474     polygon[0].Scale[0] = 6.0;
00475     polygon[0].Scale[1] = 1.0;
00476     polygon[0].Shift[0] = 0.0;
00477     polygon[0].Shift[1] = 0.0;
00478     polygon[0].Rotate = 0.0;
00479     polygon[0].Vertex[0] = vertex[0];
00480     polygon[0].Vertex[1] = vertex[17];
00481     polygon[0].Vertex[2] = vertex[16];
00482     polygon[0].Texture = texture[2].TexID;
00483     polygon[0].Vertex[0].u = 0.0;
00484     polygon[0].Vertex[0].v = 0.0;
00485     polygon[0].Vertex[1].u = 1.0;
00486     polygon[0].Vertex[1].v = 1.0;
00487     polygon[0].Vertex[2].u = 0.0;
00488     polygon[0].Vertex[2].v = 1.0;
00489 
00490     polygon[1].Scale[0] = 6.0;
00491     polygon[1].Scale[1] = 1.0;
00492     polygon[1].Shift[0] = 0.0;
00493     polygon[1].Shift[1] = 0.0;
00494     polygon[1].Rotate = 0.0;
00495     polygon[1].Vertex[0] = vertex[0];
00496     polygon[1].Vertex[1] = vertex[1];
00497     polygon[1].Vertex[2] = vertex[17];
00498     polygon[1].Texture = texture[2].TexID;
00499     polygon[1].Vertex[0].u = 0.0;
00500     polygon[1].Vertex[0].v = 0.0;
00501     polygon[1].Vertex[1].u = 1.0;
00502     polygon[1].Vertex[1].v = 0.0;
00503     polygon[1].Vertex[2].u = 1.0;
00504     polygon[1].Vertex[2].v = 1.0;
00505 
00506     polygon[2].Scale[0] = 1.0;
00507     polygon[2].Scale[1] = 1.0;
00508     polygon[2].Shift[0] = 0.0;
00509     polygon[2].Shift[1] = 0.0;
00510     polygon[2].Rotate = 0.0;
00511     polygon[2].Vertex[0] = vertex[1];
00512     polygon[2].Vertex[1] = vertex[18];
00513     polygon[2].Vertex[2] = vertex[17];
00514     polygon[2].Texture = texture[2].TexID;
00515     polygon[2].Vertex[0].u = 0.0;
00516     polygon[2].Vertex[0].v = 0.0;
00517     polygon[2].Vertex[1].u = 1.0;
00518     polygon[2].Vertex[1].v = 1.0;
00519     polygon[2].Vertex[2].u = 0.0;
00520     polygon[2].Vertex[2].v = 1.0;
00521 
00522     polygon[3].Scale[0] = 1.0;
00523     polygon[3].Scale[1] = 1.0;
00524     polygon[3].Shift[0] = 0.0;
00525     polygon[3].Shift[1] = 0.0;
00526     polygon[3].Rotate = 0.0;
00527     polygon[3].Vertex[0] = vertex[1];
00528     polygon[3].Vertex[1] = vertex[2];
00529     polygon[3].Vertex[2] = vertex[18];
00530     polygon[3].Texture = texture[2].TexID;
00531     polygon[3].Vertex[0].u = 0.0;
00532     polygon[3].Vertex[0].v = 0.0;
00533     polygon[3].Vertex[1].u = 1.0;
00534     polygon[3].Vertex[1].v = 0.0;
00535     polygon[3].Vertex[2].u = 1.0;
00536     polygon[3].Vertex[2].v = 1.0;
00537 
00538     polygon[4].Scale[0] = 5.0;
00539     polygon[4].Scale[1] = 1.0;
00540     polygon[4].Shift[0] = 0.0;
00541     polygon[4].Shift[1] = 0.0;
00542     polygon[4].Rotate = 0.0;
00543     polygon[4].Vertex[0] = vertex[2];
00544     polygon[4].Vertex[1] = vertex[19];
00545     polygon[4].Vertex[2] = vertex[18];
00546     polygon[4].Texture = texture[2].TexID;
00547     polygon[4].Vertex[0].u = 0.0;
00548     polygon[4].Vertex[0].v = 0.0;
00549     polygon[4].Vertex[1].u = 1.0;
00550     polygon[4].Vertex[1].v = 1.0;
00551     polygon[4].Vertex[2].u = 0.0;
00552     polygon[4].Vertex[2].v = 1.0;
00553 
00554     polygon[5].Scale[0] = 5.0;
00555     polygon[5].Scale[1] = 1.0;
00556     polygon[5].Shift[0] = 0.0;
00557     polygon[5].Shift[1] = 0.0;
00558     polygon[5].Rotate = 0.0;
00559     polygon[5].Vertex[0] = vertex[2];
00560     polygon[5].Vertex[1] = vertex[3];
00561     polygon[5].Vertex[2] = vertex[19];
00562     polygon[5].Texture = texture[2].TexID;
00563     polygon[5].Vertex[0].u = 0.0;
00564     polygon[5].Vertex[0].v = 0.0;
00565     polygon[5].Vertex[1].u = 1.0;
00566     polygon[5].Vertex[1].v = 0.0;
00567     polygon[5].Vertex[2].u = 1.0;
00568     polygon[5].Vertex[2].v = 1.0;
00569 
00570     polygon[6].Scale[0] = 4.0;
00571     polygon[6].Scale[1] = 1.0;
00572     polygon[6].Shift[0] = 0.0;
00573     polygon[6].Shift[1] = 0.0;
00574     polygon[6].Rotate = 0.0;
00575     polygon[6].Vertex[0] = vertex[3];
00576     polygon[6].Vertex[1] = vertex[20];
00577     polygon[6].Vertex[2] = vertex[19];
00578     polygon[6].Texture = texture[2].TexID;
00579     polygon[6].Vertex[0].u = 0.0;
00580     polygon[6].Vertex[0].v = 0.0;
00581     polygon[6].Vertex[1].u = 1.0;
00582     polygon[6].Vertex[1].v = 1.0;
00583     polygon[6].Vertex[2].u = 0.0;
00584     polygon[6].Vertex[2].v = 1.0;
00585 
00586     polygon[7].Scale[0] = 4.0;
00587     polygon[7].Scale[1] = 1.0;
00588     polygon[7].Shift[0] = 0.0;
00589     polygon[7].Shift[1] = 0.0;
00590     polygon[7].Rotate = 0.0;
00591     polygon[7].Vertex[0] = vertex[3];
00592     polygon[7].Vertex[1] = vertex[4];
00593     polygon[7].Vertex[2] = vertex[20];
00594     polygon[7].Texture = texture[2].TexID;
00595     polygon[7].Vertex[0].u = 0.0;
00596     polygon[7].Vertex[0].v = 0.0;
00597     polygon[7].Vertex[1].u = 1.0;
00598     polygon[7].Vertex[1].v = 0.0;
00599     polygon[7].Vertex[2].u = 1.0;
00600     polygon[7].Vertex[2].v = 1.0;
00601 
00602     polygon[8].Scale[0] = 2.0;
00603     polygon[8].Scale[1] = 1.0;
00604     polygon[8].Shift[0] = 0.0;
00605     polygon[8].Shift[1] = 0.0;
00606     polygon[8].Rotate = 0.0;
00607     polygon[8].Vertex[0] = vertex[4];
00608     polygon[8].Vertex[1] = vertex[21];
00609     polygon[8].Vertex[2] = vertex[20];
00610     polygon[8].Texture = texture[2].TexID;
00611     polygon[8].Vertex[0].u = 0.0;
00612     polygon[8].Vertex[0].v = 0.0;
00613     polygon[8].Vertex[1].u = 1.0;
00614     polygon[8].Vertex[1].v = 1.0;
00615     polygon[8].Vertex[2].u = 0.0;
00616     polygon[8].Vertex[2].v = 1.0;
00617 
00618     polygon[9].Scale[0] = 2.0;
00619     polygon[9].Scale[1] = 1.0;
00620     polygon[9].Shift[0] = 0.0;
00621     polygon[9].Shift[1] = 0.0;
00622     polygon[9].Rotate = 0.0;
00623     polygon[9].Vertex[0] = vertex[4];
00624     polygon[9].Vertex[1] = vertex[5];
00625     polygon[9].Vertex[2] = vertex[21];
00626     polygon[9].Texture = texture[2].TexID;
00627     polygon[9].Vertex[0].u = 0.0;
00628     polygon[9].Vertex[0].v = 0.0;
00629     polygon[9].Vertex[1].u = 1.0;
00630     polygon[9].Vertex[1].v = 0.0;
00631     polygon[9].Vertex[2].u = 1.0;
00632     polygon[9].Vertex[2].v = 1.0;
00633 
00634     polygon[10].Scale[0] = 2.0;
00635     polygon[10].Scale[1] = 1.0;
00636     polygon[10].Shift[0] = 0.0;
00637     polygon[10].Shift[1] = 0.0;
00638     polygon[10].Rotate = 0.0;
00639     polygon[10].Vertex[0] = vertex[5];
00640     polygon[10].Vertex[1] = vertex[22];
00641     polygon[10].Vertex[2] = vertex[21];
00642     polygon[10].Texture = texture[2].TexID;
00643     polygon[10].Vertex[0].u = 0.0;
00644     polygon[10].Vertex[0].v = 0.0;
00645     polygon[10].Vertex[1].u = 1.0;
00646     polygon[10].Vertex[1].v = 1.0;
00647     polygon[10].Vertex[2].u = 0.0;
00648     polygon[10].Vertex[2].v = 1.0;
00649 
00650     polygon[11].Scale[0] = 2.0;
00651     polygon[11].Scale[1] = 1.0;
00652     polygon[11].Shift[0] = 0.0;
00653     polygon[11].Shift[1] = 0.0;
00654     polygon[11].Rotate = 0.0;
00655     polygon[11].Vertex[0] = vertex[5];
00656     polygon[11].Vertex[1] = vertex[6];
00657     polygon[11].Vertex[2] = vertex[22];
00658     polygon[11].Texture = texture[2].TexID;
00659     polygon[11].Vertex[0].u = 0.0;
00660     polygon[11].Vertex[0].v = 0.0;
00661     polygon[11].Vertex[1].u = 1.0;
00662     polygon[11].Vertex[1].v = 0.0;
00663     polygon[11].Vertex[2].u = 1.0;
00664     polygon[11].Vertex[2].v = 1.0;
00665 
00666     polygon[12].Scale[0] = 2.0;
00667     polygon[12].Scale[1] = 1.0;
00668     polygon[12].Shift[0] = 0.0;
00669     polygon[12].Shift[1] = 0.0;
00670     polygon[12].Rotate = 0.0;
00671     polygon[12].Vertex[0] = vertex[6];
00672     polygon[12].Vertex[1] = vertex[23];
00673     polygon[12].Vertex[2] = vertex[22];
00674     polygon[12].Texture = texture[2].TexID;
00675     polygon[12].Vertex[0].u = 0.0;
00676     polygon[12].Vertex[0].v = 0.0;
00677     polygon[12].Vertex[1].u = 1.0;
00678     polygon[12].Vertex[1].v = 1.0;
00679     polygon[12].Vertex[2].u = 0.0;
00680     polygon[12].Vertex[2].v = 1.0;
00681 
00682     polygon[13].Scale[0] = 2.0;
00683     polygon[13].Scale[1] = 1.0;
00684     polygon[13].Shift[0] = 0.0;
00685     polygon[13].Shift[1] = 0.0;
00686     polygon[13].Rotate = 0.0;
00687     polygon[13].Vertex[0] = vertex[6];
00688     polygon[13].Vertex[1] = vertex[7];
00689     polygon[13].Vertex[2] = vertex[23];
00690     polygon[13].Texture = texture[2].TexID;
00691     polygon[13].Vertex[0].u = 0.0;
00692     polygon[13].Vertex[0].v = 0.0;
00693     polygon[13].Vertex[1].u = 1.0;
00694     polygon[13].Vertex[1].v = 0.0;
00695     polygon[13].Vertex[2].u = 1.0;
00696     polygon[13].Vertex[2].v = 1.0;
00697 
00698     polygon[14].Scale[0] = 2.0;
00699     polygon[14].Scale[1] = 1.0;
00700     polygon[14].Shift[0] = 0.0;
00701     polygon[14].Shift[1] = 0.0;
00702     polygon[14].Rotate = 0.0;
00703     polygon[14].Vertex[0] = vertex[7];
00704     polygon[14].Vertex[1] = vertex[24];
00705     polygon[14].Vertex[2] = vertex[23];
00706     polygon[14].Texture = texture[2].TexID;
00707     polygon[14].Vertex[0].u = 0.0;
00708     polygon[14].Vertex[0].v = 0.0;
00709     polygon[14].Vertex[1].u = 1.0;
00710     polygon[14].Vertex[1].v = 1.0;
00711     polygon[14].Vertex[2].u = 0.0;
00712     polygon[14].Vertex[2].v = 1.0;
00713 
00714     polygon[15].Scale[0] = 2.0;
00715     polygon[15].Scale[1] = 1.0;
00716     polygon[15].Shift[0] = 0.0;
00717     polygon[15].Shift[1] = 0.0;
00718     polygon[15].Rotate = 0.0;
00719     polygon[15].Vertex[0] = vertex[7];
00720     polygon[15].Vertex[1] = vertex[8];
00721     polygon[15].Vertex[2] = vertex[24];
00722     polygon[15].Texture = texture[2].TexID;
00723     polygon[15].Vertex[0].u = 0.0;
00724     polygon[15].Vertex[0].v = 0.0;
00725     polygon[15].Vertex[1].u = 1.0;
00726     polygon[15].Vertex[1].v = 0.0;
00727     polygon[15].Vertex[2].u = 1.0;
00728     polygon[15].Vertex[2].v = 1.0;
00729 
00730     polygon[16].Scale[0] = 2.0;
00731     polygon[16].Scale[1] = 1.0;
00732     polygon[16].Shift[0] = 0.0;
00733     polygon[16].Shift[1] = 0.0;
00734     polygon[16].Rotate = 0.0;
00735     polygon[16].Vertex[0] = vertex[8];
00736     polygon[16].Vertex[1] = vertex[25];
00737     polygon[16].Vertex[2] = vertex[24];
00738     polygon[16].Texture = texture[2].TexID;
00739     polygon[16].Vertex[0].u = 0.0;
00740     polygon[16].Vertex[0].v = 0.0;
00741     polygon[16].Vertex[1].u = 1.0;
00742     polygon[16].Vertex[1].v = 1.0;
00743     polygon[16].Vertex[2].u = 0.0;
00744     polygon[16].Vertex[2].v = 1.0;
00745 
00746     polygon[17].Scale[0] = 2.0;
00747     polygon[17].Scale[1] = 1.0;
00748     polygon[17].Shift[0] = 0.0;
00749     polygon[17].Shift[1] = 0.0;
00750     polygon[17].Rotate = 0.0;
00751     polygon[17].Vertex[0] = vertex[8];
00752     polygon[17].Vertex[1] = vertex[9];
00753     polygon[17].Vertex[2] = vertex[25];
00754     polygon[17].Texture = texture[2].TexID;
00755     polygon[17].Vertex[0].u = 0.0;
00756     polygon[17].Vertex[0].v = 0.0;
00757     polygon[17].Vertex[1].u = 1.0;
00758     polygon[17].Vertex[1].v = 0.0;
00759     polygon[17].Vertex[2].u = 1.0;
00760     polygon[17].Vertex[2].v = 1.0;
00761 
00762     polygon[18].Scale[0] = 2.0;
00763     polygon[18].Scale[1] = 1.0;
00764     polygon[18].Shift[0] = 0.0;
00765     polygon[18].Shift[1] = 20.0;
00766     polygon[18].Rotate = 0.0;
00767     polygon[18].Vertex[0] = vertex[9];
00768     polygon[18].Vertex[1] = vertex[26];
00769     polygon[18].Vertex[2] = vertex[25];
00770     polygon[18].Texture = texture[2].TexID;
00771     polygon[18].Vertex[0].u = 0.0;
00772     polygon[18].Vertex[0].v = 0.0;
00773     polygon[18].Vertex[1].u = 1.0;
00774     polygon[18].Vertex[1].v = 1.0;
00775     polygon[18].Vertex[2].u = 0.0;
00776     polygon[18].Vertex[2].v = 1.0;
00777 
00778     polygon[19].Scale[0] = 2.0;
00779     polygon[19].Scale[1] = 1.0;
00780     polygon[19].Shift[0] = 0.0;
00781     polygon[19].Shift[1] = 20.0;
00782     polygon[19].Rotate = 0.0;
00783     polygon[19].Vertex[0] = vertex[9];
00784     polygon[19].Vertex[1] = vertex[10];
00785     polygon[19].Vertex[2] = vertex[26];
00786     polygon[19].Texture = texture[2].TexID;
00787     polygon[19].Vertex[0].u = 0.0;
00788     polygon[19].Vertex[0].v = 0.0;
00789     polygon[19].Vertex[1].u = 1.0;
00790     polygon[19].Vertex[1].v = 0.0;
00791     polygon[19].Vertex[2].u = 1.0;
00792     polygon[19].Vertex[2].v = 1.0;
00793 
00794     polygon[20].Scale[0] = 2.0;
00795     polygon[20].Scale[1] = 1.0;
00796     polygon[20].Shift[0] = 0.0;
00797     polygon[20].Shift[1] = 0.0;
00798     polygon[20].Rotate = 0.0;
00799     polygon[20].Vertex[0] = vertex[10];
00800     polygon[20].Vertex[1] = vertex[27];
00801     polygon[20].Vertex[2] = vertex[26];
00802     polygon[20].Texture = texture[2].TexID;
00803     polygon[20].Vertex[0].u = 0.0;
00804     polygon[20].Vertex[0].v = 0.0;
00805     polygon[20].Vertex[1].u = 1.0;
00806     polygon[20].Vertex[1].v = 1.0;
00807     polygon[20].Vertex[2].u = 0.0;
00808     polygon[20].Vertex[2].v = 1.0;
00809 
00810     polygon[21].Scale[0] = 2.0;
00811     polygon[21].Scale[1] = 1.0;
00812     polygon[21].Shift[0] = 0.0;
00813     polygon[21].Shift[1] = 0.0;
00814     polygon[21].Rotate = 0.0;
00815     polygon[21].Vertex[0] = vertex[10];
00816     polygon[21].Vertex[1] = vertex[11];
00817     polygon[21].Vertex[2] = vertex[27];
00818     polygon[21].Texture = texture[2].TexID;
00819     polygon[21].Vertex[0].u = 0.0;
00820     polygon[21].Vertex[0].v = 0.0;
00821     polygon[21].Vertex[1].u = 1.0;
00822     polygon[21].Vertex[1].v = 0.0;
00823     polygon[21].Vertex[2].u = 1.0;
00824     polygon[21].Vertex[2].v = 1.0;
00825 
00826     polygon[22].Scale[0] = 2.0;
00827     polygon[22].Scale[1] = 1.0;
00828     polygon[22].Shift[0] = 0.0;
00829     polygon[22].Shift[1] = 0.0;
00830     polygon[22].Rotate = 0.0;
00831     polygon[22].Vertex[0] = vertex[11];
00832     polygon[22].Vertex[1] = vertex[28];
00833     polygon[22].Vertex[2] = vertex[27];
00834     polygon[22].Texture = texture[2].TexID;
00835     polygon[22].Vertex[0].u = 0.0;
00836     polygon[22].Vertex[0].v = 0.0;
00837     polygon[22].Vertex[1].u = 1.0;
00838     polygon[22].Vertex[1].v = 1.0;
00839     polygon[22].Vertex[2].u = 0.0;
00840     polygon[22].Vertex[2].v = 1.0;
00841 
00842     polygon[23].Scale[0] = 2.0;
00843     polygon[23].Scale[1] = 1.0;
00844     polygon[23].Shift[0] = 0.0;
00845     polygon[23].Shift[1] = 0.0;
00846     polygon[23].Rotate = 0.0;
00847     polygon[23].Vertex[0] = vertex[11];
00848     polygon[23].Vertex[1] = vertex[12];
00849     polygon[23].Vertex[2] = vertex[28];
00850     polygon[23].Texture = texture[2].TexID;
00851     polygon[23].Vertex[0].u = 0.0;
00852     polygon[23].Vertex[0].v = 0.0;
00853     polygon[23].Vertex[1].u = 1.0;
00854     polygon[23].Vertex[1].v = 0.0;
00855     polygon[23].Vertex[2].u = 1.0;
00856     polygon[23].Vertex[2].v = 1.0;
00857 
00858 
00859     polygon[24].Scale[0] = 2.0;
00860     polygon[24].Scale[1] = 1.0;
00861     polygon[24].Shift[0] = 0.0;
00862     polygon[24].Shift[1] = 0.0;
00863     polygon[24].Rotate = 0.0;
00864     polygon[24].Vertex[0] = vertex[12];
00865     polygon[24].Vertex[1] = vertex[29];
00866     polygon[24].Vertex[2] = vertex[28];
00867     polygon[24].Texture = texture[2].TexID;
00868     polygon[24].Vertex[0].u = 0.0;
00869     polygon[24].Vertex[0].v = 0.0;
00870     polygon[24].Vertex[1].u = 1.0;
00871     polygon[24].Vertex[1].v = 1.0;
00872     polygon[24].Vertex[2].u = 0.0;
00873     polygon[24].Vertex[2].v = 1.0;
00874 
00875     polygon[25].Scale[0] = 2.0;
00876     polygon[25].Scale[1] = 1.0;
00877     polygon[25].Shift[0] = 0.0;
00878     polygon[25].Shift[1] = 0.0;
00879     polygon[25].Rotate = 0.0;
00880     polygon[25].Vertex[0] = vertex[12];
00881     polygon[25].Vertex[1] = vertex[13];
00882     polygon[25].Vertex[2] = vertex[29];
00883     polygon[25].Texture = texture[2].TexID;
00884     polygon[25].Vertex[0].u = 0.0;
00885     polygon[25].Vertex[0].v = 0.0;
00886     polygon[25].Vertex[1].u = 1.0;
00887     polygon[25].Vertex[1].v = 0.0;
00888     polygon[25].Vertex[2].u = 1.0;
00889     polygon[25].Vertex[2].v = 1.0;
00890 
00891     polygon[26].Scale[0] = 1.0;
00892     polygon[26].Scale[1] = 1.0;
00893     polygon[26].Shift[0] = 0.0;
00894     polygon[26].Shift[1] = 0.0;
00895     polygon[26].Rotate = 0.0;
00896     polygon[26].Vertex[0] = vertex[13];
00897     polygon[26].Vertex[1] = vertex[30];
00898     polygon[26].Vertex[2] = vertex[29];
00899     polygon[26].Texture = texture[2].TexID;
00900     polygon[26].Vertex[0].u = 0.0;
00901     polygon[26].Vertex[0].v = 0.0;
00902     polygon[26].Vertex[1].u = 1.0;
00903     polygon[26].Vertex[1].v = 1.0;
00904     polygon[26].Vertex[2].u = 0.0;
00905     polygon[26].Vertex[2].v = 1.0;
00906 
00907     polygon[27].Scale[0] = 1.0;
00908     polygon[27].Scale[1] = 1.0;
00909     polygon[27].Shift[0] = 0.0;
00910     polygon[27].Shift[1] = 0.0;
00911     polygon[27].Rotate = 0.0;
00912     polygon[27].Vertex[0] = vertex[13];
00913     polygon[27].Vertex[1] = vertex[14];
00914     polygon[27].Vertex[2] = vertex[30];
00915     polygon[27].Texture = texture[2].TexID;
00916     polygon[27].Vertex[0].u = 0.0;
00917     polygon[27].Vertex[0].v = 0.0;
00918     polygon[27].Vertex[1].u = 1.0;
00919     polygon[27].Vertex[1].v = 0.0;
00920     polygon[27].Vertex[2].u = 1.0;
00921     polygon[27].Vertex[2].v = 1.0;
00922 
00923     polygon[28].Scale[0] = 6.0;
00924     polygon[28].Scale[1] = 1.0;
00925     polygon[28].Shift[0] = 0.0;
00926     polygon[28].Shift[1] = 0.0;
00927     polygon[28].Rotate = 0.0;
00928     polygon[28].Vertex[0] = vertex[14];
00929     polygon[28].Vertex[1] = vertex[31];
00930     polygon[28].Vertex[2] = vertex[30];
00931     polygon[28].Texture = texture[2].TexID;
00932     polygon[28].Vertex[0].u = 0.0;
00933     polygon[28].Vertex[0].v = 0.0;
00934     polygon[28].Vertex[1].u = 1.0;
00935     polygon[28].Vertex[1].v = 1.0;
00936     polygon[28].Vertex[2].u = 0.0;
00937     polygon[28].Vertex[2].v = 1.0;
00938 
00939     polygon[29].Scale[0] = 6.0;
00940     polygon[29].Scale[1] = 1.0;
00941     polygon[29].Shift[0] = 0.0;
00942     polygon[29].Shift[1] = 0.0;
00943     polygon[29].Rotate = 0.0;
00944     polygon[29].Vertex[0] = vertex[14];
00945     polygon[29].Vertex[1] = vertex[15];
00946     polygon[29].Vertex[2] = vertex[31];
00947     polygon[29].Texture = texture[2].TexID;
00948     polygon[29].Vertex[0].u = 0.0;
00949     polygon[29].Vertex[0].v = 0.0;
00950     polygon[29].Vertex[1].u = 1.0;
00951     polygon[29].Vertex[1].v = 0.0;
00952     polygon[29].Vertex[2].u = 1.0;
00953     polygon[29].Vertex[2].v = 1.0;
00954 
00955     polygon[30].Scale[0] = 5.0;
00956     polygon[30].Scale[1] = 1.0;
00957     polygon[30].Shift[0] = 0.0;
00958     polygon[30].Shift[1] = 0.0;
00959     polygon[30].Rotate = 0.0;
00960     polygon[30].Vertex[0] = vertex[15];
00961     polygon[30].Vertex[1] = vertex[16];
00962     polygon[30].Vertex[2] = vertex[31];
00963     polygon[30].Texture = texture[2].TexID;
00964     polygon[30].Vertex[0].u = 0.0;
00965     polygon[30].Vertex[0].v = 0.0;
00966     polygon[30].Vertex[1].u = 1.0;
00967     polygon[30].Vertex[1].v = 1.0;
00968     polygon[30].Vertex[2].u = 0.0;
00969     polygon[30].Vertex[2].v = 1.0;
00970 
00971     polygon[31].Scale[0] = 5.0;
00972     polygon[31].Scale[1] = 1.0;
00973     polygon[31].Shift[0] = 0.0;
00974     polygon[31].Shift[1] = 0.0;
00975     polygon[31].Rotate = 0.0;
00976     polygon[31].Vertex[0] = vertex[15];
00977     polygon[31].Vertex[1] = vertex[0];
00978     polygon[31].Vertex[2] = vertex[16];
00979     polygon[31].Texture = texture[2].TexID;
00980     polygon[31].Vertex[0].u = 0.0;
00981     polygon[31].Vertex[0].v = 0.0;
00982     polygon[31].Vertex[1].u = 1.0;
00983     polygon[31].Vertex[1].v = 0.0;
00984     polygon[31].Vertex[2].u = 1.0;
00985     polygon[31].Vertex[2].v = 1.0;
00986 
00987     polygon[32].Scale[0] = 5.0;
00988     polygon[32].Scale[1] = 5.0;
00989     polygon[32].Shift[0] = 0.0;
00990     polygon[32].Shift[1] = 0.0;
00991     polygon[32].Rotate = 0.0;
00992     polygon[32].Vertex[0] = vertex[15];
00993     polygon[32].Vertex[1] = vertex[1];
00994     polygon[32].Vertex[2] = vertex[0];
00995     polygon[32].Texture = texture[0].TexID;
00996     polygon[32].Vertex[0].u = 0.0;
00997     polygon[32].Vertex[0].v = 0.0;
00998     polygon[32].Vertex[1].u = 1.0;
00999     polygon[32].Vertex[1].v = 1.0;
01000     polygon[32].Vertex[2].u = 0.0;
01001     polygon[32].Vertex[2].v = 1.0;
01002 
01003     polygon[33].Scale[0] = 5.0;
01004     polygon[33].Scale[1] = 5.0;
01005     polygon[33].Shift[0] = 0.0;
01006     polygon[33].Shift[1] = 0.0;
01007     polygon[33].Rotate = 0.0;
01008     polygon[33].Vertex[0] = vertex[15];
01009     polygon[33].Vertex[1] = vertex[14];
01010     polygon[33].Vertex[2] = vertex[1];
01011     polygon[33].Texture = texture[0].TexID;
01012     polygon[33].Vertex[0].u = 0.0;
01013     polygon[33].Vertex[0].v = 0.0;
01014     polygon[33].Vertex[1].u = 1.0;
01015     polygon[33].Vertex[1].v = 0.0;
01016     polygon[33].Vertex[2].u = 1.0;
01017     polygon[33].Vertex[2].v = 1.0;
01018 
01019     polygon[34].Scale[0] = 5.0;
01020     polygon[34].Scale[1] = 5.0;
01021     polygon[34].Shift[0] = 0.0;
01022     polygon[34].Shift[1] = 0.0;
01023     polygon[34].Rotate = 0.0;
01024     polygon[34].Vertex[0] = vertex[13];
01025     polygon[34].Vertex[1] = vertex[3];
01026     polygon[34].Vertex[2] = vertex[2];
01027     polygon[34].Texture = texture[0].TexID;
01028     polygon[34].Vertex[0].u = 0.0;
01029     polygon[34].Vertex[0].v = 0.0;
01030     polygon[34].Vertex[1].u = 1.0;
01031     polygon[34].Vertex[1].v = 1.0;
01032     polygon[34].Vertex[2].u = 0.0;
01033     polygon[34].Vertex[2].v = 1.0;
01034 
01035     polygon[35].Scale[0] = 5.0;
01036     polygon[35].Scale[1] = 5.0;
01037     polygon[35].Shift[0] = 0.0;
01038     polygon[35].Shift[1] = 0.0;
01039     polygon[35].Rotate = 0.0;
01040     polygon[35].Vertex[0] = vertex[13];
01041     polygon[35].Vertex[1] = vertex[4];
01042     polygon[35].Vertex[2] = vertex[3];
01043     polygon[35].Texture = texture[0].TexID;
01044     polygon[35].Vertex[0].u = 0.0;
01045     polygon[35].Vertex[0].v = 0.0;
01046     polygon[35].Vertex[1].u = 1.0;
01047     polygon[35].Vertex[1].v = 0.0;
01048     polygon[35].Vertex[2].u = 1.0;
01049     polygon[35].Vertex[2].v = 1.0;
01050 
01051     polygon[36].Scale[0] = 1.0;
01052     polygon[36].Scale[1] = 2.0;
01053     polygon[36].Shift[0] = 0.0;
01054     polygon[36].Shift[1] = 0.0;
01055     polygon[36].Rotate = 0.0;
01056     polygon[36].Vertex[0] = vertex[11];
01057     polygon[36].Vertex[1] = vertex[5];
01058     polygon[36].Vertex[2] = vertex[12];
01059     polygon[36].Texture = texture[0].TexID;
01060     polygon[36].Vertex[0].u = 0.0;
01061     polygon[36].Vertex[0].v = 0.0;
01062     polygon[36].Vertex[1].u = 1.0;
01063     polygon[36].Vertex[1].v = 1.0;
01064     polygon[36].Vertex[2].u = 0.0;
01065     polygon[36].Vertex[2].v = 1.0;
01066 
01067     polygon[37].Scale[0] = 1.0;
01068     polygon[37].Scale[1] = 2.0;
01069     polygon[37].Shift[0] = 0.0;
01070     polygon[37].Shift[1] = 0.0;
01071     polygon[37].Rotate = 0.0;
01072     polygon[37].Vertex[0] = vertex[11];
01073     polygon[37].Vertex[1] = vertex[6];
01074     polygon[37].Vertex[2] = vertex[5];
01075     polygon[37].Texture = texture[0].TexID;
01076     polygon[37].Vertex[0].u = 0.0;
01077     polygon[37].Vertex[0].v = 0.0;
01078     polygon[37].Vertex[1].u = 1.0;
01079     polygon[37].Vertex[1].v = 0.0;
01080     polygon[37].Vertex[2].u = 1.0;
01081     polygon[37].Vertex[2].v = 1.0;
01082 
01083     polygon[38].Scale[0] = 5.0;
01084     polygon[38].Scale[1] = 5.0;
01085     polygon[38].Shift[0] = 0.0;
01086     polygon[38].Shift[1] = 0.0;
01087     polygon[38].Rotate = 0.0;
01088     polygon[38].Vertex[0] = vertex[9];
01089     polygon[38].Vertex[1] = vertex[7];
01090     polygon[38].Vertex[2] = vertex[10];
01091     polygon[38].Texture = texture[0].TexID;
01092     polygon[38].Vertex[0].u = 0.0;
01093     polygon[38].Vertex[0].v = 0.0;
01094     polygon[38].Vertex[1].u = 1.0;
01095     polygon[38].Vertex[1].v = 1.0;
01096     polygon[38].Vertex[2].u = 0.0;
01097     polygon[38].Vertex[2].v = 1.0;
01098 
01099     polygon[39].Scale[0] = 5.0;
01100     polygon[39].Scale[1] = 5.0;
01101     polygon[39].Shift[0] = 0.0;
01102     polygon[39].Shift[1] = 0.0;
01103     polygon[39].Rotate = 0.0;
01104     polygon[39].Vertex[0] = vertex[9];
01105     polygon[39].Vertex[1] = vertex[8];
01106     polygon[39].Vertex[2] = vertex[7];
01107     polygon[39].Texture = texture[0].TexID;
01108     polygon[39].Vertex[0].u = 0.0;
01109     polygon[39].Vertex[0].v = 0.0;
01110     polygon[39].Vertex[1].u = 1.0;
01111     polygon[39].Vertex[1].v = 0.0;
01112     polygon[39].Vertex[2].u = 1.0;
01113     polygon[39].Vertex[2].v = 1.0;
01114 
01115     polygon[40].Scale[0] = 5.0;
01116     polygon[40].Scale[1] = 1.0;
01117     polygon[40].Shift[0] = 0.0;
01118     polygon[40].Shift[1] = 0.0;
01119     polygon[40].Rotate = 0.0;
01120     polygon[40].Vertex[0] = vertex[18];
01121     polygon[40].Vertex[1] = vertex[16];
01122     polygon[40].Vertex[2] = vertex[17];
01123     polygon[40].Texture = texture[1].TexID;
01124     polygon[40].Vertex[0].u = 0.0;
01125     polygon[40].Vertex[0].v = 0.0;
01126     polygon[40].Vertex[1].u = 1.0;
01127     polygon[40].Vertex[1].v = 1.0;
01128     polygon[40].Vertex[2].u = 0.0;
01129     polygon[40].Vertex[2].v = 1.0;
01130 
01131     polygon[41].Scale[0] = 5.0;
01132     polygon[41].Scale[1] = 1.0;
01133     polygon[41].Shift[0] = 0.0;
01134     polygon[41].Shift[1] = 0.0;
01135     polygon[41].Rotate = 0.0;
01136     polygon[41].Vertex[0] = vertex[18];
01137     polygon[41].Vertex[1] = vertex[34];
01138     polygon[41].Vertex[2] = vertex[16];
01139     polygon[41].Texture = texture[1].TexID;
01140     polygon[41].Vertex[0].u = 0.0;
01141     polygon[41].Vertex[0].v = 0.0;
01142     polygon[41].Vertex[1].u = 1.0;
01143     polygon[41].Vertex[1].v = 0.0;
01144     polygon[41].Vertex[2].u = 1.0;
01145     polygon[41].Vertex[2].v = 1.0;
01146 
01147     polygon[42].Scale[0] = 3.0;
01148     polygon[42].Scale[1] = 2.0;
01149     polygon[42].Shift[0] = 0.0;
01150     polygon[42].Shift[1] = 0.0;
01151     polygon[42].Rotate = 0.0;
01152     polygon[42].Vertex[0] = vertex[36];
01153     polygon[42].Vertex[1] = vertex[18];
01154     polygon[42].Vertex[2] = vertex[19];
01155     polygon[42].Texture = texture[3].TexID;
01156     polygon[42].Vertex[0].u = 0.0;
01157     polygon[42].Vertex[0].v = 0.0;
01158     polygon[42].Vertex[1].u = 1.0;
01159     polygon[42].Vertex[1].v = 1.0;
01160     polygon[42].Vertex[2].u = 0.0;
01161     polygon[42].Vertex[2].v = 1.0;
01162 
01163     polygon[43].Scale[0] = 3.0;
01164     polygon[43].Scale[1] = 2.0;
01165     polygon[43].Shift[0] = 0.0;
01166     polygon[43].Shift[1] = 0.0;
01167     polygon[43].Rotate = 0.0;
01168     polygon[43].Vertex[0] = vertex[36];
01169     polygon[43].Vertex[1] = vertex[35];
01170     polygon[43].Vertex[2] = vertex[18];
01171     polygon[43].Texture = texture[3].TexID;
01172     polygon[43].Vertex[0].u = 0.0;
01173     polygon[43].Vertex[0].v = 0.0;
01174     polygon[43].Vertex[1].u = 1.0;
01175     polygon[43].Vertex[1].v = 0.0;
01176     polygon[43].Vertex[2].u = 1.0;
01177     polygon[43].Vertex[2].v = 1.0;
01178 
01179     polygon[44].Scale[0] = 1.0;
01180     polygon[44].Scale[1] = 2.0;
01181     polygon[44].Shift[0] = 0.0;
01182     polygon[44].Shift[1] = 0.0;
01183     polygon[44].Rotate = 0.0;
01184     polygon[44].Vertex[0] = vertex[22];
01185     polygon[44].Vertex[1] = vertex[28];
01186     polygon[44].Vertex[2] = vertex[21];
01187     polygon[44].Texture = texture[1].TexID;
01188     polygon[44].Vertex[0].u = 0.0;
01189     polygon[44].Vertex[0].v = 0.0;
01190     polygon[44].Vertex[1].u = 1.0;
01191     polygon[44].Vertex[1].v = 1.0;
01192     polygon[44].Vertex[2].u = 0.0;
01193     polygon[44].Vertex[2].v = 1.0;
01194 
01195     polygon[45].Scale[0] = 1.0;
01196     polygon[45].Scale[1] = 2.0;
01197     polygon[45].Shift[0] = 0.0;
01198     polygon[45].Shift[1] = 0.0;
01199     polygon[45].Rotate = 0.0;
01200     polygon[45].Vertex[0] = vertex[22];
01201     polygon[45].Vertex[1] = vertex[27];
01202     polygon[45].Vertex[2] = vertex[28];
01203     polygon[45].Texture = texture[1].TexID;
01204     polygon[45].Vertex[0].u = 0.0;
01205     polygon[45].Vertex[0].v = 0.0;
01206     polygon[45].Vertex[1].u = 1.0;
01207     polygon[45].Vertex[1].v = 0.0;
01208     polygon[45].Vertex[2].u = 1.0;
01209     polygon[45].Vertex[2].v = 1.0;
01210 
01211     polygon[46].Scale[0] = 5.0;
01212     polygon[46].Scale[1] = 5.0;
01213     polygon[46].Shift[0] = 0.0;
01214     polygon[46].Shift[1] = 0.0;
01215     polygon[46].Rotate = 0.0;
01216     polygon[46].Vertex[0] = vertex[24];
01217     polygon[46].Vertex[1] = vertex[26];
01218     polygon[46].Vertex[2] = vertex[23];
01219     polygon[46].Texture = texture[1].TexID;
01220     polygon[46].Vertex[0].u = 0.0;
01221     polygon[46].Vertex[0].v = 0.0;
01222     polygon[46].Vertex[1].u = 1.0;
01223     polygon[46].Vertex[1].v = 1.0;
01224     polygon[46].Vertex[2].u = 0.0;
01225     polygon[46].Vertex[2].v = 1.0;
01226 
01227     polygon[47].Scale[0] = 5.0;
01228     polygon[47].Scale[1] = 5.0;
01229     polygon[47].Shift[0] = 0.0;
01230     polygon[47].Shift[1] = 0.0;
01231     polygon[47].Rotate = 0.0;
01232     polygon[47].Vertex[0] = vertex[24];
01233     polygon[47].Vertex[1] = vertex[25];
01234     polygon[47].Vertex[2] = vertex[26];
01235     polygon[47].Texture = texture[1].TexID;
01236     polygon[47].Vertex[0].u = 0.0;
01237     polygon[47].Vertex[0].v = 0.0;
01238     polygon[47].Vertex[1].u = 1.0;
01239     polygon[47].Vertex[1].v = 0.0;
01240     polygon[47].Vertex[2].u = 1.0;
01241     polygon[47].Vertex[2].v = 1.0;
01242 
01243     polygon[48].Scale[0] = 3.0;
01244     polygon[48].Scale[1] = 2.0;
01245     polygon[48].Shift[0] = 0.0;
01246     polygon[48].Shift[1] = 0.0;
01247     polygon[48].Rotate = 0.0;
01248     polygon[48].Vertex[0] = vertex[20];
01249     polygon[48].Vertex[1] = vertex[35];
01250     polygon[48].Vertex[2] = vertex[36];
01251     polygon[48].Texture = texture[3].TexID;
01252     polygon[48].Vertex[0].u = 0.0;
01253     polygon[48].Vertex[0].v = 0.0;
01254     polygon[48].Vertex[1].u = 1.0;
01255     polygon[48].Vertex[1].v = 1.0;
01256     polygon[48].Vertex[2].u = 0.0;
01257     polygon[48].Vertex[2].v = 1.0;
01258 
01259     polygon[49].Scale[0] = 3.0;
01260     polygon[49].Scale[1] = 2.0;
01261     polygon[49].Shift[0] = 0.0;
01262     polygon[49].Shift[1] = 0.0;
01263     polygon[49].Rotate = 0.0;
01264     polygon[49].Vertex[0] = vertex[20];
01265     polygon[49].Vertex[1] = vertex[29];
01266     polygon[49].Vertex[2] = vertex[35];
01267     polygon[49].Texture = texture[3].TexID;
01268     polygon[49].Vertex[0].u = 0.0;
01269     polygon[49].Vertex[0].v = 0.0;
01270     polygon[49].Vertex[1].u = 1.0;
01271     polygon[49].Vertex[1].v = 0.0;
01272     polygon[49].Vertex[2].u = 1.0;
01273     polygon[49].Vertex[2].v = 1.0;
01274 
01275     polygon[50].Scale[0] = 5.0;
01276     polygon[50].Scale[1] = 5.0;
01277     polygon[50].Shift[0] = 0.0;
01278     polygon[50].Shift[1] = 0.0;
01279     polygon[50].Rotate = 0.0;
01280     polygon[50].Vertex[0] = vertex[30];
01281     polygon[50].Vertex[1] = vertex[32];
01282     polygon[50].Vertex[2] = vertex[29];
01283     polygon[50].Texture = texture[1].TexID;
01284     polygon[50].Vertex[0].u = 0.0;
01285     polygon[50].Vertex[0].v = 0.0;
01286     polygon[50].Vertex[1].u = 1.0;
01287     polygon[50].Vertex[1].v = 1.0;
01288     polygon[50].Vertex[2].u = 0.0;
01289     polygon[50].Vertex[2].v = 1.0;
01290 
01291     polygon[51].Scale[0] = 5.0;
01292     polygon[51].Scale[1] = 5.0;
01293     polygon[51].Shift[0] = 0.0;
01294     polygon[51].Shift[1] = 0.0;
01295     polygon[51].Rotate = 0.0;
01296     polygon[51].Vertex[0] = vertex[30];
01297     polygon[51].Vertex[1] = vertex[31];
01298     polygon[51].Vertex[2] = vertex[32];
01299     polygon[51].Texture = texture[1].TexID;
01300     polygon[51].Vertex[0].u = 0.0;
01301     polygon[51].Vertex[0].v = 0.0;
01302     polygon[51].Vertex[1].u = 1.0;
01303     polygon[51].Vertex[1].v = 0.0;
01304     polygon[51].Vertex[2].u = 1.0;
01305     polygon[51].Vertex[2].v = 1.0;
01306 
01307     polygon[52].Scale[0] = 3.0;
01308     polygon[52].Scale[1] = 2.0;
01309     polygon[52].Shift[0] = 0.0;
01310     polygon[52].Shift[1] = 0.0;
01311     polygon[52].Rotate = 0.0;
01312     polygon[52].Vertex[0] = vertex[29];
01313     polygon[52].Vertex[1] = vertex[33];
01314     polygon[52].Vertex[2] = vertex[35];
01315     polygon[52].Texture = texture[3].TexID;
01316     polygon[52].Vertex[0].u = 0.0;
01317     polygon[52].Vertex[0].v = 0.0;
01318     polygon[52].Vertex[1].u = 1.0;
01319     polygon[52].Vertex[1].v = 1.0;
01320     polygon[52].Vertex[2].u = 0.0;
01321     polygon[52].Vertex[2].v = 1.0;
01322 
01323     polygon[53].Scale[0] = 3.0;
01324     polygon[53].Scale[1] = 2.0;
01325     polygon[53].Shift[0] = 0.0;
01326     polygon[53].Shift[1] = 0.0;
01327     polygon[53].Rotate = 0.0;
01328     polygon[53].Vertex[0] = vertex[29];
01329     polygon[53].Vertex[1] = vertex[32];
01330     polygon[53].Vertex[2] = vertex[33];
01331     polygon[53].Texture = texture[3].TexID;
01332     polygon[53].Vertex[0].u = 0.0;
01333     polygon[53].Vertex[0].v = 0.0;
01334     polygon[53].Vertex[1].u = 1.0;
01335     polygon[53].Vertex[1].v = 0.0;
01336     polygon[53].Vertex[2].u = 1.0;
01337     polygon[53].Vertex[2].v = 1.0;
01338 
01339     polygon[54].Scale[0] = 3.0;
01340     polygon[54].Scale[1] = 2.0;
01341     polygon[54].Shift[0] = 0.0;
01342     polygon[54].Shift[1] = 0.0;
01343     polygon[54].Rotate = 0.0;
01344     polygon[54].Vertex[0] = vertex[35];
01345     polygon[54].Vertex[1] = vertex[34];
01346     polygon[54].Vertex[2] = vertex[18];
01347     polygon[54].Texture = texture[3].TexID;
01348     polygon[54].Vertex[0].u = 0.0;
01349     polygon[54].Vertex[0].v = 0.0;
01350     polygon[54].Vertex[1].u = 1.0;
01351     polygon[54].Vertex[1].v = 1.0;
01352     polygon[54].Vertex[2].u = 0.0;
01353     polygon[54].Vertex[2].v = 1.0;
01354 
01355     polygon[55].Scale[0] = 3.0;
01356     polygon[55].Scale[1] = 2.0;
01357     polygon[55].Shift[0] = 0.0;
01358     polygon[55].Shift[1] = 0.0;
01359     polygon[55].Rotate = 0.0;
01360     polygon[55].Vertex[0] = vertex[35];
01361     polygon[55].Vertex[1] = vertex[33];
01362     polygon[55].Vertex[2] = vertex[34];
01363     polygon[55].Texture = texture[3].TexID;
01364     polygon[55].Vertex[0].u = 0.0;
01365     polygon[55].Vertex[0].v = 0.0;
01366     polygon[55].Vertex[1].u = 1.0;
01367     polygon[55].Vertex[1].v = 0.0;
01368     polygon[55].Vertex[2].u = 1.0;
01369     polygon[55].Vertex[2].v = 1.0;
01370 
01371     polygon[56].Scale[0] = 4.0;
01372     polygon[56].Scale[1] = 3.0;
01373     polygon[56].Shift[0] = 0.0;
01374     polygon[56].Shift[1] = 0.0;
01375     polygon[56].Rotate = 0.0;
01376     polygon[56].Vertex[0] = vertex[32];
01377     polygon[56].Vertex[1] = vertex[34];
01378     polygon[56].Vertex[2] = vertex[33];
01379     polygon[56].Texture = texture[2].TexID;
01380     polygon[56].Vertex[0].u = 0.0;
01381     polygon[56].Vertex[0].v = 0.0;
01382     polygon[56].Vertex[1].u = 1.0;
01383     polygon[56].Vertex[1].v = 0.0;
01384     polygon[56].Vertex[2].u = 0.5;
01385     polygon[56].Vertex[2].v = 0.5;
01386 
01387     polygon[57].Scale[0] = 4.0;
01388     polygon[57].Scale[1] = 3.0;
01389     polygon[57].Shift[0] = 0.0;
01390     polygon[57].Shift[1] = 0.0;
01391     polygon[57].Rotate = 0;
01392     polygon[57].Vertex[0] = vertex[19];
01393     polygon[57].Vertex[1] = vertex[20];
01394     polygon[57].Vertex[2] = vertex[36];
01395     polygon[57].Texture = texture[2].TexID;
01396     polygon[57].Vertex[0].u = 0.0;
01397     polygon[57].Vertex[0].v = 0.0;
01398     polygon[57].Vertex[1].u = 1.0;
01399     polygon[57].Vertex[1].v = 0.0;
01400     polygon[57].Vertex[2].u = 0.5;
01401     polygon[57].Vertex[2].v = 0.5;
01402 
01403     for (int loop = 0; loop < numPolygons; loop++)
01404         polygon[loop].SetNormal();
01405 }
01406 
01407 void SetGLProperties()
01408 {
01409     glCullFace(GL_BACK);
01410     glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
01411     glClearDepth(1.0);
01412     glDepthFunc(GL_LESS);
01413     glEnable(GL_DEPTH_TEST);
01414     glShadeModel(GL_SMOOTH);
01415     glEnable(GL_NORMALIZE);
01416     glEnable(GL_CULL_FACE);
01417 }
01418 
01419 void SetGLProjection(int Width, int Height)
01420 {
01421     if (Height==0)
01422         Height=1;
01423     glViewport(0, 0, Width, Height);
01424     glMatrixMode(GL_PROJECTION);
01425     glLoadIdentity();
01426     gluPerspective(45.0,(float)Width/(float)Height, 0.8, 500.0);
01427 }
01428 
01429 void SetGLView(int Width, int Height)
01430 {
01431     SetGLProjection(Width, Height);
01432     glMatrixMode(GL_MODELVIEW);
01433     glLoadIdentity();
01434 }
01435 
01436 void SetGLMaterial()
01437 {
01438     float mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
01439     float mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
01440     float mat_specular[] = { 0.9, 0.9, 0.9, 1.0 };
01441     float mat_emission[] = { 0.0, 0.0, 0.0, 1.0 };
01442     float mat_shininess[] = { 80.0 };
01443 
01444     glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
01445     glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
01446     glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
01447     glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission);
01448     glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
01449 }
01450 
01451 int SetGLTexture(TEXTURE* texture)
01452 {
01453     glEnable(GL_TEXTURE_2D);
01454 
01455     sprintf(texture[0].TexName, "%s", "floor.tga");
01456     if (!texture[0].LoadTGA())
01457     {
01458         MessageBox(NULL,"Failed to load floor image","Error",MB_OK|MB_ICONERROR);
01459         return FALSE;
01460     }
01461     sprintf(texture[1].TexName, "%s", "roof.tga");
01462     if (!texture[1].LoadTGA())
01463     {
01464         MessageBox(NULL,"Failed to load roof image","Error",MB_OK|MB_ICONERROR);
01465         return FALSE;
01466     }
01467     sprintf(texture[2].TexName, "%s", "wall.tga");
01468     if (!texture[2].LoadTGA())
01469     {
01470         MessageBox(NULL,"Failed to load wall image","Error",MB_OK|MB_ICONERROR);
01471         return FALSE;
01472     }
01473     sprintf(texture[3].TexName, "%s", "tile.tga");
01474     if (!texture[3].LoadTGA())
01475     {
01476         MessageBox(NULL,"Failed to load tile image","Error",MB_OK|MB_ICONERROR);
01477         return FALSE;
01478     }
01479     return TRUE;
01480 }
01481 
01482 void DrawMyText()
01483 {
01484     glBlendFunc(GL_ONE,  GL_ONE_MINUS_SRC_ALPHA) ;
01485     glDisable(GL_LIGHTING);
01486     glColor3f(0.0, 1.0, 0.0);
01487     glEnable(GL_BLEND);
01488     glDisable(GL_DEPTH_TEST);
01489     glPushMatrix();
01490     glLoadIdentity();
01491     glFontBegin(&myFont);
01492     char text[256];
01493 
01494     glFontTextOut("Tutorial #15  (3D Sound)", -52, 40, -100);
01495 
01496     sprintf(text, "FPS = %d", fps);
01497     glFontTextOut(text, -52, 38, -100);
01498 
01499     sprintf(text, "%s", "Press Enter for non-timer based sound");
01500     glFontTextOut(text, -52, 34, -100);
01501 
01502     glFontEnd();
01503     glPopMatrix();
01504     glEnable(GL_DEPTH_TEST);
01505     glDisable(GL_BLEND);
01506     glEnable(GL_LIGHTING);
01507 }
01508 
01509 void DrawGrid()
01510 {
01511     glDisable(GL_TEXTURE_2D);
01512     glDisable(GL_LIGHTING);
01513     glPushMatrix();
01514     glTranslatef(0,-2.0,0);
01515     glColor3f(0.0f,1.0f,0.0f);
01516 
01517     float Line = -10;
01518     int Grid;
01519     glBegin(GL_LINES);
01520     for(Grid = 0; Grid <= 20; Grid += 1)
01521     {
01522         glVertex3f(Line + Grid, 0, -10);
01523         glVertex3f(Line + Grid, 0, 10);
01524         glVertex3f(-10, 0, Line + Grid);
01525         glVertex3f(10, 0, Line + Grid);
01526     }
01527     glEnd();
01528     glPopMatrix();
01529     glEnable(GL_TEXTURE_2D);
01530     glEnable(GL_LIGHTING);
01531 }
01532 
01533 void DrawWorld(BSP_node* root)
01534 {
01535     float mat_ambient[] = { 0.8, 0.8, 0.8, 1.0 };
01536     float mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 };
01537     glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
01538     glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
01539 
01540     glPushMatrix();
01541 
01542     glDisable (GL_DEPTH_TEST);
01543     RenderBSP(root);
01544     glEnable (GL_DEPTH_TEST);
01545 
01546     glPopMatrix();
01547 
01548 /*
01549     //Draw polygons that are in the leaf
01550     for (int loop = 0; loop < numPolygons; loop++)
01551     {
01552         glMatrixMode(GL_TEXTURE);
01553         glPushMatrix();
01554 
01555 
01556         glScalef(polygon[loop].Scale[0], polygon[loop].Scale[1], 1.0f);
01557         glTranslatef(polygon[loop].Shift[0], polygon[loop].Shift[1], 0.0f);
01558         glRotatef(polygon[loop].Rotate, 0.0f, 0.0f, 1.0f);
01559 
01560         glBindTexture(GL_TEXTURE_2D, polygon[loop].Texture);
01561         glBegin(GL_TRIANGLES);
01562         glNormal3fv(&polygon[loop].Vertex[0].nx);
01563         glTexCoord2f(polygon[loop].Vertex[0].u, polygon[loop].Vertex[0].v);
01564         glVertex3fv(&polygon[loop].Vertex[0].x);
01565         glTexCoord2f(polygon[loop].Vertex[1].u, polygon[loop].Vertex[1].v);
01566         glVertex3fv(&polygon[loop].Vertex[1].x);
01567         glTexCoord2f(polygon[loop].Vertex[2].u, polygon[loop].Vertex[2].v);
01568         glVertex3fv(&polygon[loop].Vertex[2].x);
01569         glEnd();
01570 
01571         glPopMatrix();
01572         glMatrixMode(GL_MODELVIEW);
01573     }
01574 */
01575 }
01576 
01577 void DrawGreenSphere()
01578 {
01579     float mat_ambient[] = { 0.2, 1.0, 0.1, 1.0 };
01580     float mat_diffuse[] = { 0.2, 1.0, 0.1, 1.0 };
01581     glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
01582     glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
01583 //    glDisable(GL_TEXTURE_2D);
01584     glPushMatrix();
01585     glLoadIdentity();
01586     glTranslatef(-2.0, -2.0, -8.0);
01587     GLUquadricObj * sphere = gluNewQuadric();
01588     gluQuadricOrientation(sphere, GLU_OUTSIDE);
01589     gluSphere(sphere,0.3,20,20);
01590     glPopMatrix();
01591 //    glEnable(GL_TEXTURE_2D);
01592 }
01593 
01594 void DrawSphere()
01595 {
01596     float mat_ambient[] = { 0.8, 0.5, 0.1, 1.0 };
01597     float mat_diffuse[] = { 0.8, 0.5, 0.1, 1.0 };
01598     glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
01599     glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
01600 
01601     glDisable(GL_TEXTURE_2D);
01602     glPushMatrix();
01603     glTranslatef(-3.0f,-1.0f,-8.0f);
01604     GLUquadricObj * sphere = gluNewQuadric();
01605     gluQuadricOrientation(sphere, GLU_OUTSIDE);
01606     gluSphere(sphere, 1.0, 50, 50);
01607     glPopMatrix();
01608     glEnable(GL_TEXTURE_2D);
01609 }
01610 
01611 void DrawCone()
01612 {
01613     float mat_ambient[] = { 0.1, 0.5, 1.0, 1.0 };
01614     float mat_diffuse[] = { 0.1, 0.5, 1.0, 1.0 };
01615     glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
01616     glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
01617 
01618     glDisable(GL_TEXTURE_2D);
01619     glDisable(GL_CULL_FACE);
01620     glPushMatrix();
01621     glTranslatef(3.0f,-2.0f,-8.0f);
01622     glRotatef(-90,1,0,0);
01623     GLUquadricObj * cylinder = gluNewQuadric();
01624     gluQuadricOrientation(cylinder, GLU_OUTSIDE);
01625     gluCylinder(cylinder,1.0,0.0,2.0,20,20);
01626     glPopMatrix();
01627     glEnable(GL_CULL_FACE);
01628     glEnable(GL_TEXTURE_2D);
01629 }
01630 
01631 float GetTimePassed(float& lasttime, int average, float* lastmultiplier)
01632 {
01633     float timeoffset;
01634     float currenttime;
01635 /*
01636 If the program has just started, set last tickcount to the current tickcount.
01637 This prevents the program from thinking that several hours have passed since the last frame.
01638 */
01639     if (lasttime == 0)
01640         lasttime = (float)GetTickCount();
01641         // Get the current time
01642     currenttime = (float)GetTickCount();
01643         // Calculate the offset
01644     timeoffset = currenttime - lasttime;
01645     // If timeoffset less than 1/120 of a second (in milliseconds) then set to minimum offset
01646     if (timeoffset < 8.333333)
01647     {
01648         timeoffset = 8.333333;
01649         currenttime = lasttime + timeoffset;
01650     }
01651     // Put the current time in the lasttime variable
01652         lasttime = currenttime;
01653     // return the time offset in seconds per frame
01654         multiplier = timeoffset / 1000;
01655     for (int loop = 0; loop < average - 1; loop++)
01656     {
01657         lastmultiplier[loop] = lastmultiplier[loop + 1];
01658     }
01659     lastmultiplier[average - 1] = multiplier;
01660     for (int loop = 0; loop < average - 1; loop++)
01661         multiplier += lastmultiplier[loop];
01662     multiplier /= (float)average; 
01663         if (multiplier)
01664         fps = (int)(1.0 / multiplier);
01665     return multiplier;
01666 }
01667 
01668 bool CheckClipPlanes(CAMERA Camera, VECTOR Vect)
01669 {
01670   float ProjectionMatrix[16];
01671   float ModelViewMatrix[16];
01672   float A, B, C, Distance;
01673   int Counter = 0;
01674   glGetFloatv(GL_PROJECTION_MATRIX, ProjectionMatrix);
01675   glGetFloatv(GL_MODELVIEW_MATRIX, ModelViewMatrix);
01676 
01677   MultMatrix(ProjectionMatrix, ModelViewMatrix);
01678 
01679   //right clipping plane
01680   A = ProjectionMatrix[0] - ProjectionMatrix[3];
01681   B = ProjectionMatrix[4] - ProjectionMatrix[7];
01682   C = ProjectionMatrix[8] - ProjectionMatrix[11];
01683 
01684   Distance = -1 * (A * (-Camera.Position.x + Vect.x) + B * (-Camera.Position.y + Vect.y) + C * (-Camera.Position.z + Vect.z));
01685   if (Distance > 0)
01686     Counter++;
01687 
01688   //left clipping plane
01689   A = ProjectionMatrix[0] + ProjectionMatrix[3];
01690   B = ProjectionMatrix[4] + ProjectionMatrix[7];
01691   C = ProjectionMatrix[8] + ProjectionMatrix[11];
01692 
01693   Distance = A * (-Camera.Position.x + Vect.x) + B * (-Camera.Position.y + Vect.y) + C * (-Camera.Position.z + Vect.z);
01694   if (Distance > 0)
01695     Counter++;
01696 
01697   //top clipping plane
01698   A = ProjectionMatrix[1] - ProjectionMatrix[3];
01699   B = ProjectionMatrix[5] - ProjectionMatrix[7];
01700   C = ProjectionMatrix[9] - ProjectionMatrix[11];
01701 
01702   Distance = -1 * (A * (-Camera.Position.x + Vect.x) + B * (-Camera.Position.y + Vect.y) + C * (-Camera.Position.z + Vect.z));
01703   if (Distance > 0)
01704     Counter++;
01705 
01706   //bottom clipping plane
01707   A = ProjectionMatrix[1] + ProjectionMatrix[3];
01708   B = ProjectionMatrix[5] + ProjectionMatrix[7];
01709   C = ProjectionMatrix[9] + ProjectionMatrix[11];
01710 
01711   Distance = A * (-Camera.Position.x + Vect.x) + B * (-Camera.Position.y + Vect.y) + C * (-Camera.Position.z + Vect.z);
01712   if (Distance > 0)
01713     Counter++;
01714 
01715   // near clipping plane (might not be necessary when the near frustrum plane is close, but just in case)
01716   A = ProjectionMatrix[2] - ProjectionMatrix[3];
01717   B = ProjectionMatrix[6] - ProjectionMatrix[7];
01718   C = ProjectionMatrix[10] - ProjectionMatrix[11];
01719 
01720   Distance = A * (-Camera.Position.x + Vect.x) + B * (-Camera.Position.y + Vect.y) + C * (-Camera.Position.z + Vect.z);
01721   if (Distance > 0)
01722     Counter++;
01723 
01724   // far clipping plane (the equation didn't work for the far plane, so I'll just use a distance test)
01725   VECTOR Vect2;
01726   Vect2.x = Vect.x - Camera.Position.x;
01727   Vect2.y = Vect.y - Camera.Position.y;
01728   Vect2.z = Vect.z - Camera.Position.z;
01729   if (MagnitudeVector(Vect2) < 200)
01730     Counter++;
01731 
01732   if (Counter == 6)
01733     return 1;
01734   else
01735     return 0;
01736 }
01737 
01738 //  A halo type billboard that always faces the camera
01739 void DrawHalo(TEXTURE* texture, LIGHT* light, CAMERA* camera)
01740 {
01741     float halfwidth = 2;
01742     float halfheight = 2;
01743 
01744     MATRIX mat;
01745     glGetFloatv(GL_MODELVIEW_MATRIX, mat.Element);
01746 
01747     VECTOR right;
01748     right.x = mat.Element[0];
01749     right.y = mat.Element[4];
01750     right.z = mat.Element[8];
01751     right.Normalize();
01752     right.x *= halfwidth;
01753     right.y *= halfwidth;
01754     right.z *= halfwidth;
01755 
01756     VECTOR up;
01757     up.x = mat.Element[1];
01758     up.y = mat.Element[5];
01759     up.z = mat.Element[9];
01760     up.Normalize();
01761     up.x *= halfheight;
01762     up.y *= halfheight;
01763     up.z *= halfheight;
01764 
01765 /*
01766    If you are using a quake style camera that doesn't roll
01767    then you can use the following commented code to make a conventional
01768    billboard remain vertical. If you are using a camera with 6DOF however,
01769    then this will not work.
01770 */
01771 
01772 /*
01773     up.x = 0.0;
01774     up.z = 0.0;
01775     right.y = 0.0;
01776 //*/
01777 
01778     float mat_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
01779     float mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 };
01780     glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
01781     glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
01782     glEnable(GL_BLEND);
01783     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
01784     glEnable(GL_ALPHA_TEST);
01785     glAlphaFunc(GL_GREATER, 0);
01786     glDisable(GL_LIGHTING);
01787     glColor4f(1.0, 1.0, 1.0, 1.0);
01788     glBindTexture(GL_TEXTURE_2D, texture[1].TexID);
01789     glPopMatrix();
01790         glBegin(GL_QUADS);
01791             glTexCoord2f(0.0f, 0.0f); glVertex3f(light[currentLight].Position.x + (-right.x - up.x), light[currentLight].Position.y + (-right.y - up.y), light[currentLight].Position.z + (-right.z - up.z));
01792             glTexCoord2f(1.0f, 0.0f); glVertex3f(light[currentLight].Position.x + (right.x - up.x), light[currentLight].Position.y + (right.y - up.y), light[currentLight].Position.z + (right.z - up.z));
01793             glTexCoord2f(1.0f, 1.0f); glVertex3f(light[currentLight].Position.x + (right.x + up.x), light[currentLight].Position.y + (right.y + up.y), light[currentLight].Position.z + (right.z + up.z));
01794             glTexCoord2f(0.0f, 1.0f); glVertex3f(light[currentLight].Position.x + (up.x - right.x), light[currentLight].Position.y + (up.y - right.y), light[currentLight].Position.z + (up.z - right.z));
01795         glEnd();
01796     glPopMatrix();
01797     glEnable(GL_LIGHTING);
01798     glDisable(GL_ALPHA);
01799     glDisable(GL_BLEND);
01800 }
01801 
01802 //  A fire type billboard that rotates to face the camera but remains vertical
01803 void DrawFire(TEXTURE* texture, LIGHT* light, CAMERA* camera)
01804 {
01805     float halfwidth = 1.0;
01806     float halfheight = 2.0;
01807     VECTOR FirePosition(3.0, -2.0 + halfheight, -8.0);
01808 //  Get the vector from the billboard position to the camera
01809     VECTOR A;
01810     A.x = (camera[currentCamera].Position.x - FirePosition.x);
01811     A.y = (camera[currentCamera].Position.y - FirePosition.y);
01812     A.z = (camera[currentCamera].Position.z - FirePosition.z);
01813     A.Normalize();
01814 // Set a vector to the standard up vector
01815     VECTOR B;
01816     B.x = (0);
01817     B.y = (1);
01818     B.z = (0);
01819     B.Normalize();
01820 // Take the cross product of these vectors to find a vector perpendicular to the camera
01821     VECTOR C = CrossVector(A, B);
01822     C.Normalize();
01823 
01824 // Negate the perpendicular vector to make the billboard face the front
01825     VECTOR right;
01826     right.x = -C.x * halfwidth;
01827     right.y = -C.y * halfwidth;
01828     right.z = -C.z * halfwidth;
01829 
01830     VECTOR up;
01831     up.x = 0;
01832     up.y = 1 * halfheight;
01833     up.z = 0;
01834 
01835 // Continue as normal
01836     float mat_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
01837     float mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 };
01838     glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
01839     glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
01840     glEnable(GL_BLEND);
01841     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
01842     glEnable(GL_ALPHA_TEST);
01843     glAlphaFunc(GL_GREATER, 0);
01844     glDisable(GL_LIGHTING);
01845     glColor4f(1.0, 1.0, 1.0, 1.0);
01846     glBindTexture(GL_TEXTURE_2D, texture[2].TexID);
01847     glPopMatrix();
01848         glBegin(GL_QUADS);
01849             glTexCoord2f(0.0f, 0.0f); glVertex3f(FirePosition.x + (-right.x - up.x), FirePosition.y + (-right.y - up.y), FirePosition.z + (-right.z - up.z));
01850             glTexCoord2f(1.0f, 0.0f); glVertex3f(FirePosition.x + (right.x - up.x), FirePosition.y + (right.y - up.y), FirePosition.z + (right.z - up.z));
01851             glTexCoord2f(1.0f, 1.0f); glVertex3f(FirePosition.x + (right.x + up.x), FirePosition.y + (right.y + up.y), FirePosition.z + (right.z + up.z));
01852             glTexCoord2f(0.0f, 1.0f); glVertex3f(FirePosition.x + (up.x - right.x), FirePosition.y + (up.y - right.y), FirePosition.z + (up.z - right.z));
01853         glEnd();
01854     glPopMatrix();
01855     glEnable(GL_LIGHTING);
01856     glDisable(GL_ALPHA);
01857     glDisable(GL_BLEND);
01858 }
01859 
01860 void DrawBillboards(TEXTURE* texture, LIGHT* light, CAMERA* camera)
01861 {
01862         DrawHalo(texture, light, camera);
01863 
01864 /*
01865 // Draw depth sorted billboards
01866     VECTOR FirePosition(3.0, -2.0, -8.0);
01867 
01868     VECTOR VectorToCone;
01869     VectorToCone.x = FirePosition.x - camera[currentCamera].Position.x;
01870     VectorToCone.y = FirePosition.y - camera[currentCamera].Position.y;
01871     VectorToCone.z = FirePosition.z - camera[currentCamera].Position.z;
01872     float FireDistance = VectorToCone.GetMagnitude();
01873 
01874     VECTOR VectorToLight;
01875     VectorToLight.x = light[currentLight].Position.x - camera[currentCamera].Position.x;
01876     VectorToLight.y = light[currentLight].Position.y - camera[currentCamera].Position.y;
01877     VectorToLight.z = light[currentLight].Position.z - camera[currentCamera].Position.z;
01878     float LightDistance = VectorToLight.GetMagnitude();
01879 
01880     if(LightDistance < FireDistance)
01881     {
01882         DrawFire();
01883         DrawHalo();
01884     }
01885     else
01886     {
01887         DrawHalo();
01888         DrawFire();
01889     }
01890 //*/
01891 }

Generated on Fri Dec 23 05:21:38 2005 for Sound by doxygen1.2.15