#include "ModelManager.h" #include "Settings.h" void InitModel(VModel * m) { m->PrimitiveType = GL_POINTS; m->NumberOfVertices = 0; m->Vertices = NULL; m->WireFrame = false; m->Color[0] = m->Color[1] = m->Color[2] = m->Color[3] = 1.0; } void CleanUpModel(VModel * m) { m->Vertices = NULL; m->NumberOfVertices = 0; } Boolean AllocateVertices(VModel * m, int numberOfVertices) { m->Vertices = (Vector *) NewPtrClear(sizeof(Vector) * numberOfVertices); if (m->Vertices == NULL) return 0; m->NumberOfVertices = numberOfVertices; return 1; } Boolean AllocateMaskVertices(VModel * m, int numberOfVertices) { m->MaskVertices = (Vector *) NewPtrClear(sizeof(Vector) * numberOfVertices); if (m->MaskVertices == NULL) return 0; m->NumberOfMaskVertices = numberOfVertices; return 1; } void DrawModel(VModel * m) { int wVertex; VSettings * s; s = GetSettings(); if (!m->WireFrame && (s == NULL || !s->NoFilledPolys)) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonOffset(1.0, 2.0); glColor4f(0.0, 0.0, 0.0, m->Color[3]); if (m->NumberOfMaskVertices > 0) { /* Separate model for mask */ glBegin(m->MaskPrimitiveType); for (wVertex = 0; wVertex < m->NumberOfMaskVertices; wVertex++) { glVertex3f(m->MaskVertices[wVertex].x, m->MaskVertices[wVertex].y, m->MaskVertices[wVertex].z); } } else { /* Same model for mask as lines */ glBegin(m->PrimitiveType); for (wVertex = 0; wVertex < m->NumberOfVertices; wVertex++) { glVertex3f(m->Vertices[wVertex].x, m->Vertices[wVertex].y, m->Vertices[wVertex].z); } } glEnd(); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } glColor4f(m->Color[0], m->Color[1], m->Color[2], m->Color[3]); glBegin(m->PrimitiveType); for (wVertex = 0; wVertex < m->NumberOfVertices; wVertex++) { glVertex3f(m->Vertices[wVertex].x, m->Vertices[wVertex].y, m->Vertices[wVertex].z); } glEnd(); } void BuildCrossHairModel(VModel * m) { static Vector * myVertices = NULL; m->PrimitiveType = GL_QUADS; m->WireFrame = 1; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 12; return; } if (AllocateVertices(m, 12)) { m->Vertices[0].x = -0.1; m->Vertices[0].y = 0.1; m->Vertices[0].z = -1.6; m->Vertices[1].x = 0.1; m->Vertices[1].y = 0.1; m->Vertices[1].z = -1.6; m->Vertices[2].x = 0.1; m->Vertices[2].y = -0.1; m->Vertices[2].z = -1.6; m->Vertices[3].x = -0.1; m->Vertices[3].y = -0.1; m->Vertices[3].z = -1.6; m->Vertices[4].x = 0.0; m->Vertices[4].y = 0.2; m->Vertices[4].z = -1.6; m->Vertices[5].x = 0.0; m->Vertices[5].y = 0.2; m->Vertices[5].z = -1.6; m->Vertices[6].x = 0.0; m->Vertices[6].y = -0.2; m->Vertices[6].z = -1.6; m->Vertices[7].x = 0.0; m->Vertices[7].y = -0.2; m->Vertices[7].z = -1.6; m->Vertices[8].x = -0.2; m->Vertices[8].y = 0.0; m->Vertices[8].z = -1.6; m->Vertices[9].x = -0.2; m->Vertices[9].y = 0.0; m->Vertices[9].z = -1.6; m->Vertices[10].x = 0.2; m->Vertices[10].y = 0.0; m->Vertices[10].z = -1.6; m->Vertices[11].x = 0.2; m->Vertices[11].y = 0.0; m->Vertices[11].z = -1.6; myVertices = m->Vertices; } } void BuildBulletModel(VModel * m) { static Vector * myVertices = NULL; m->PrimitiveType = GL_QUADS; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 12; return; } if (AllocateVertices(m, 12)) { m->Vertices[0].x = -0.1; m->Vertices[0].y = 0.1; m->Vertices[0].z = 0.0; m->Vertices[1].x = -0.1; m->Vertices[1].y = -0.1; m->Vertices[1].z = 0.0; m->Vertices[2].x = 0.1; m->Vertices[2].y = -0.1; m->Vertices[2].z = 0.0; m->Vertices[3].x = 0.1; m->Vertices[3].y = 0.1; m->Vertices[3].z = 0.0; m->Vertices[4].x = 0.0; m->Vertices[4].y = 0.1; m->Vertices[4].z = -0.1; m->Vertices[5].x = 0.0; m->Vertices[5].y = -0.1; m->Vertices[5].z = -0.1; m->Vertices[6].x = 0.0; m->Vertices[6].y = -0.1; m->Vertices[6].z = 0.1; m->Vertices[7].x = 0.0; m->Vertices[7].y = 0.1; m->Vertices[7].z = 0.1; m->Vertices[8].x = -0.1; m->Vertices[8].y = 0.0; m->Vertices[8].z = -0.1; m->Vertices[9].x = -0.1; m->Vertices[9].y = 0.0; m->Vertices[9].z = 0.1; m->Vertices[10].x = 0.1; m->Vertices[10].y = 0.0; m->Vertices[10].z = 0.1; m->Vertices[11].x = 0.1; m->Vertices[11].y = 0.0; m->Vertices[11].z = -0.1; myVertices = m->Vertices; } } void BuildTargetModel(VModel * m) { static Vector * myVertices = NULL; m->PrimitiveType = GL_QUADS; m->Color[0] = 1.0; m->Color[1] = 1.0; m->Color[2] = 0.0; m->Color[3] = 1.0; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 12; return; } if (AllocateVertices(m, 12)) { m->Vertices[0].x = -0.5; m->Vertices[0].y = 0.5; m->Vertices[0].z = 0.0; m->Vertices[1].x = -0.5; m->Vertices[1].y = -0.5; m->Vertices[1].z = 0.0; m->Vertices[2].x = 0.5; m->Vertices[2].y = -0.5; m->Vertices[2].z = 0.0; m->Vertices[3].x = 0.5; m->Vertices[3].y = 0.5; m->Vertices[3].z = 0.0; m->Vertices[4].x = 0.0; m->Vertices[4].y = 0.5; m->Vertices[4].z = -0.5; m->Vertices[5].x = 0.0; m->Vertices[5].y = -0.5; m->Vertices[5].z = -0.5; m->Vertices[6].x = 0.0; m->Vertices[6].y = -0.5; m->Vertices[6].z = 0.5; m->Vertices[7].x = 0.0; m->Vertices[7].y = 0.5; m->Vertices[7].z = 0.5; m->Vertices[8].x = -0.5; m->Vertices[8].y = 0.0; m->Vertices[8].z = -0.5; m->Vertices[9].x = -0.5; m->Vertices[9].y = 0.0; m->Vertices[9].z = 0.5; m->Vertices[10].x = 0.5; m->Vertices[10].y = 0.0; m->Vertices[10].z = 0.5; m->Vertices[11].x = 0.5; m->Vertices[11].y = 0.0; m->Vertices[11].z = -0.5; myVertices = m->Vertices; } } void BuildRocketModel(VModel * m) { static Vector * myVertices = NULL; m->PrimitiveType = GL_QUADS; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 76; return; } if (AllocateVertices(m, 76)) { int surface; for (surface = 0; surface < 8; surface++) { m->Vertices[(surface * 4)].x = (cos(((pi * 2) / 8) * surface) / 50.0); m->Vertices[(surface * 4)].y = (sin(((pi * 2) / 8) * surface) / 50.0); m->Vertices[(surface * 4)].z = -0.2; m->Vertices[(surface * 4) + 1].x = (cos(((pi * 2) / 8) * (surface + 1)) / 50.0); m->Vertices[(surface * 4) + 1].y = (sin(((pi * 2) / 8) * (surface + 1)) / 50.0); m->Vertices[(surface * 4) + 1].z = -0.2; m->Vertices[(surface * 4) + 2].x = (cos(((pi * 2) / 8) * (surface + 1)) / 50.0); m->Vertices[(surface * 4) + 2].y = (sin(((pi * 2) / 8) * (surface + 1)) / 50.0); m->Vertices[(surface * 4) + 2].z = 0.14; m->Vertices[(surface * 4) + 3].x = (cos(((pi * 2) / 8) * surface) / 50.0); m->Vertices[(surface * 4) + 3].y = (sin(((pi * 2) / 8) * surface) / 50.0); m->Vertices[(surface * 4) + 3].z = 0.14; } for (surface = 0; surface < 3; surface++) { m->Vertices[32 + (surface * 4)].x = (cos(((pi * 2) / 3) * surface) / 50.0); m->Vertices[32 + (surface * 4)].y = (sin(((pi * 2) / 3) * surface) / 50.0); m->Vertices[32 + (surface * 4)].z = -0.10; m->Vertices[32 + (surface * 4) + 1].x = (cos(((pi * 2) / 3) * surface) / 10.0); m->Vertices[32 + (surface * 4) + 1].y = (sin(((pi * 2) / 3) * surface) / 10.0); m->Vertices[32 + (surface * 4) + 1].z = -0.15; m->Vertices[32 + (surface * 4) + 2].x = (cos(((pi * 2) / 3) * surface) / 10.0); m->Vertices[32 + (surface * 4) + 2].y = (sin(((pi * 2) / 3) * surface) / 10.0); m->Vertices[32 + (surface * 4) + 2].z = -0.25; m->Vertices[32 + (surface * 4) + 3].x = (cos(((pi * 2) / 3) * surface) / 50.0); m->Vertices[32 + (surface * 4) + 3].y = (sin(((pi * 2) / 3) * surface) / 50.0); m->Vertices[32 + (surface * 4) + 3].z = -0.2; } /* Kind of a pain to specify these triangles as quads... We need a way to switch primitive type in the middle of the vertex list, methinks. */ for (surface = 0; surface < 8; surface++) { m->Vertices[44 + (surface * 4)].x = (cos(((pi * 2) / 8) * surface) / 50.0); m->Vertices[44 + (surface * 4)].y = (sin(((pi * 2) / 8) * surface) / 50.0); m->Vertices[44 + (surface * 4)].z = 0.14; m->Vertices[44 + (surface * 4) + 1].x = (cos(((pi * 2) / 8) * (surface + 1)) / 50.0); m->Vertices[44 + (surface * 4) + 1].y = (sin(((pi * 2) / 8) * (surface + 1)) / 50.0); m->Vertices[44 + (surface * 4) + 1].z = 0.14; m->Vertices[44 + (surface * 4) + 2].x = 0.0; m->Vertices[44 + (surface * 4) + 2].y = 0.0; m->Vertices[44 + (surface * 4) + 2].z = 0.2; m->Vertices[44 + (surface * 4) + 3] = m->Vertices[44 + (surface * 4) + 2]; } myVertices = m->Vertices; } } void BuildExplosionModel(VModel * m) { static Vector * myVertices = NULL; m->PrimitiveType = GL_TRIANGLES; m->WireFrame = false; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 6; return; } if (AllocateVertices(m, 6)) { /* Triangle #1 */ m->Vertices[0].x = 0.0; m->Vertices[0].y = 0.0; m->Vertices[0].z = 0.3; m->Vertices[1].x = 0.3; m->Vertices[1].y = 0.1; m->Vertices[1].z = -0.2; m->Vertices[2].x = 0.3; m->Vertices[2].y = -0.1; m->Vertices[2].z = -0.1; /* Triangle #2 */ m->Vertices[3].x = 0.0; m->Vertices[3].y = 0.0; m->Vertices[3].z = 0.4; m->Vertices[4].x = -0.3; m->Vertices[4].y = 0.1; m->Vertices[4].z = 0.1; m->Vertices[5].x = -0.3; m->Vertices[5].y = -0.1; m->Vertices[5].z = -0.2; /*m->Vertices[3].x = -0.2; m->Vertices[3].y = 0.1; m->Vertices[3].z = 0.1;*/ myVertices = m->Vertices; } } void BuildEnemyModel(VModel * m) { static Vector * myVertices = NULL; m->PrimitiveType = GL_QUADS; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 20; return; } if (AllocateVertices(m, 20)) { m->Vertices[0].x = -0.5; m->Vertices[0].y = 0.5; m->Vertices[0].z = -0.5; m->Vertices[1].x = 0.5; m->Vertices[1].y = 0.5; m->Vertices[1].z = -0.5; m->Vertices[2].x = 0.5; m->Vertices[2].y = -0.5; m->Vertices[2].z = -0.5; m->Vertices[3].x = -0.5; m->Vertices[3].y = -0.5; m->Vertices[3].z = -0.5; m->Vertices[4].x = -0.5; m->Vertices[4].y = 0.5; m->Vertices[4].z = -0.5; m->Vertices[5].x = 0; m->Vertices[5].y = 0; m->Vertices[5].z = 0.5; m->Vertices[6].x = 0; m->Vertices[6].y = 0; m->Vertices[6].z = 0.5; m->Vertices[7].x = -0.5; m->Vertices[7].y = -0.5; m->Vertices[7].z = -0.5; m->Vertices[8].x = 0.5; m->Vertices[8].y = 0.5; m->Vertices[8].z = -0.5; m->Vertices[9].x = 0; m->Vertices[9].y = 0; m->Vertices[9].z = 0.5; m->Vertices[10].x = 0; m->Vertices[10].y = 0; m->Vertices[10].z = 0.5; m->Vertices[11].x = 0.5; m->Vertices[11].y = -0.5; m->Vertices[11].z = -0.5; m->Vertices[12].x = -0.5; m->Vertices[12].y = 0.5; m->Vertices[12].z = -0.5; m->Vertices[13].x = 0; m->Vertices[13].y = 0; m->Vertices[13].z = 0.5; m->Vertices[14].x = 0; m->Vertices[14].y = 0; m->Vertices[14].z = 0.5; m->Vertices[15].x = 0.5; m->Vertices[15].y = 0.5; m->Vertices[15].z = -0.5; m->Vertices[16].x = -0.5; m->Vertices[16].y = -0.5; m->Vertices[16].z = -0.5; m->Vertices[17].x = 0; m->Vertices[17].y = 0; m->Vertices[17].z = 0.5; m->Vertices[18].x = 0; m->Vertices[18].y = 0; m->Vertices[18].z = 0.5; m->Vertices[19].x = 0.5; m->Vertices[19].y = -0.5; m->Vertices[19].z = -0.5; myVertices = m->Vertices; } } void BuildGrassModel(VModel * m) { static Vector * myVertices = NULL; float xOffset, yOffset, zOffset; int wBladeX, wBladeZ; m->PrimitiveType = GL_LINES; m->WireFrame = 1; m->Color[0] = 0.0; m->Color[1] = 1.0; m->Color[2] = 0.0; m->Color[3] = 1.0; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 12800; return; } if (AllocateVertices(m, 12800)) { for (wBladeZ = 0; wBladeZ < 80; wBladeZ++) { for (wBladeX = 0; wBladeX < 80; wBladeX++) { xOffset = (((Random() % 40) * 0.02) - 0.01); zOffset = (((Random() % 40) * 0.02) - 0.01); yOffset = (((Random() % 40) * 0.005) - 0.0002); m->Vertices[(wBladeZ * 160) + (wBladeX * 2)].x = (((wBladeX - 40) * 0.60) + xOffset); m->Vertices[(wBladeZ * 160) + (wBladeX * 2)].z = (((wBladeZ - 40) * 0.60) + zOffset); m->Vertices[(wBladeZ * 160) + (wBladeX * 2)].y = 0.0; m->Vertices[(wBladeZ * 160) + ((wBladeX * 2) + 1)].x = (((wBladeX - 40) * 0.60) + xOffset); m->Vertices[(wBladeZ * 160) + ((wBladeX * 2) + 1)].z = (((wBladeZ - 40) * 0.60) + zOffset); m->Vertices[(wBladeZ * 160) + ((wBladeX * 2) + 1)].y = (0.15 + yOffset); } } myVertices = m->Vertices; } } void BuildDirtModel(VModel * m) { static Vector * myVertices = NULL; float xOffset, yOffset, zOffset; int wBladeX, wBladeZ; m->PrimitiveType = GL_POINTS; m->WireFrame = 1; m->Color[0] = 0.4; m->Color[1] = 0.2; m->Color[2] = 0.1; m->Color[3] = 1.0; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 6400; return; } if (AllocateVertices(m, 6400)) { for (wBladeZ = 0; wBladeZ < 80; wBladeZ++) { for (wBladeX = 0; wBladeX < 80; wBladeX++) { xOffset = (((Random() % 40) * 0.02) - 0.01); zOffset = (((Random() % 40) * 0.02) - 0.01); yOffset = (((Random() % 40) * 0.005) - 0.0002); m->Vertices[(wBladeZ * 80) + wBladeX].x = (((wBladeX - 40) * 0.60) + xOffset); m->Vertices[(wBladeZ * 80) + wBladeX].z = (((wBladeZ - 40) * 0.60) + zOffset); m->Vertices[(wBladeZ * 80) + wBladeX].y = 0.0; } } myVertices = m->Vertices; } } void BuildTrailModel(VModel * m) { static Vector * myVertices = NULL; m->PrimitiveType = GL_TRIANGLES; m->WireFrame = false; m->Color[0] = 1.0; m->Color[1] = 0.0; m->Color[2] = 0.0; m->Color[3] = 1.0; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 12; return; } if (AllocateVertices(m, 12)) { /* Pre-computed vertices for perfect tetrahedron */ m->Vertices[0].x = 0.0; m->Vertices[0].y = 0.027974350452423097507237; m->Vertices[0].z = 0.0; m->Vertices[1].x = -0.017320506572723388949431; m->Vertices[1].y = 0.0; m->Vertices[1].z = 0.01; m->Vertices[2].x = 0.017320506572723388949431; m->Vertices[2].y = 0.0; m->Vertices[2].z = 0.01; m->Vertices[3].x = 0.0; m->Vertices[3].y = 0.027974350452423097507237; m->Vertices[3].z = 0.0; m->Vertices[4].x = 0.0; m->Vertices[4].y = 0.0; m->Vertices[4].z = -0.02; m->Vertices[5].x = -0.017320506572723388949431; m->Vertices[5].y = 0.0; m->Vertices[5].z = 0.01; m->Vertices[6].x = 0.0; m->Vertices[6].y = 0.027974350452423097507237; m->Vertices[6].z = 0.0; m->Vertices[7].x = 0.017320506572723388949431; m->Vertices[7].y = 0.0; m->Vertices[7].z = 0.01; m->Vertices[8].x = 0.0; m->Vertices[8].y = 0.0; m->Vertices[8].z = -0.02; m->Vertices[9].x = 0.0; m->Vertices[9].y = 0.0; m->Vertices[9].z = -0.02; m->Vertices[10].x = 0.017320506572723388949431; m->Vertices[10].y = 0.0; m->Vertices[10].z = 0.01; m->Vertices[11].x = -0.017320506572723388949431; m->Vertices[11].y = 0.0; m->Vertices[11].z = 0.01; myVertices = m->Vertices; } } void BuildCockpitModel(VModel * m) { static Vector * myVertices = NULL; m->PrimitiveType = GL_QUADS; m->WireFrame = 0; m->Color[0] = 0.5; m->Color[1] = 0.2; m->Color[2] = 0.0; m->Color[3] = 0.6; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 24; return; } if (AllocateVertices(m, 24)) { m->Vertices[0].x = -1.0; m->Vertices[0].y = 2.0; m->Vertices[0].z = -1.6; m->Vertices[1].x = -0.4; m->Vertices[1].y = 0.9; m->Vertices[1].z = -1.6; m->Vertices[2].x = 0.4; m->Vertices[2].y = 0.9; m->Vertices[2].z = -1.6; m->Vertices[3].x = 1.0; m->Vertices[3].y = 2.0; m->Vertices[3].z = -1.6; m->Vertices[4].x = -2.0; m->Vertices[4].y = 2.0; m->Vertices[4].z = -1.6; m->Vertices[5].x = -2.0; m->Vertices[5].y = 0.7; m->Vertices[5].z = -1.6; m->Vertices[6].x = -0.4; m->Vertices[6].y = 0.9; m->Vertices[6].z = -1.6; m->Vertices[7].x = -1.0; m->Vertices[7].y = 2.0; m->Vertices[7].z = -1.6; m->Vertices[8].x = 1.0; m->Vertices[8].y = 2.0; m->Vertices[8].z = -1.6; m->Vertices[9].x = 0.4; m->Vertices[9].y = 0.9; m->Vertices[9].z = -1.6; m->Vertices[10].x = 2.0; m->Vertices[10].y = 0.7; m->Vertices[10].z = -1.6; m->Vertices[11].x = 2.0; m->Vertices[11].y = 2.0; m->Vertices[11].z = -1.6; m->Vertices[12].x = -1.0; m->Vertices[12].y = -0.7; m->Vertices[12].z = -1.6; m->Vertices[13].x = -0.4; m->Vertices[13].y = -2.0; m->Vertices[13].z = -1.6; m->Vertices[14].x = 0.4; m->Vertices[14].y = -2.0; m->Vertices[14].z = -1.6; m->Vertices[15].x = 1.0; m->Vertices[15].y = -0.7; m->Vertices[15].z = -1.6; m->Vertices[16].x = -2.0; m->Vertices[16].y = -0.9; m->Vertices[16].z = -1.6; m->Vertices[17].x = -2.0; m->Vertices[17].y = -2.0; m->Vertices[17].z = -1.6; m->Vertices[18].x = -0.4; m->Vertices[18].y = -2.0; m->Vertices[18].z = -1.6; m->Vertices[19].x = -1.0; m->Vertices[19].y = -0.7; m->Vertices[19].z = -1.6; m->Vertices[20].x = 1.0; m->Vertices[20].y = -0.7; m->Vertices[20].z = -1.6; m->Vertices[21].x = 0.4; m->Vertices[21].y = -2.0; m->Vertices[21].z = -1.6; m->Vertices[22].x = 2.0; m->Vertices[22].y = -2.0; m->Vertices[22].z = -1.6; m->Vertices[23].x = 2.0; m->Vertices[23].y = -0.9; m->Vertices[23].z = -1.6; myVertices = m->Vertices; } } void BuildRocketPowerupModel(VModel * m) { BuildRocketModel(m); m->Color[0] = 0.5; m->Color[1] = 0.5; m->Color[2] = 1.0; m->Color[3] = 1.0; } void BuildHealthPowerupModel(VModel * m) { static Vector * myVertices = NULL; m->Color[0] = 1.0; m->Color[1] = 0.6; m->Color[2] = 0.2; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; m->PrimitiveType = GL_TRIANGLES; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 24; return; } if (AllocateVertices(m, 24)) { m->Vertices[0].x = 0.0; m->Vertices[0].y = 0.2; m->Vertices[0].z = 0.0; m->Vertices[1].x = -0.2; m->Vertices[1].y = 0.0; m->Vertices[1].z = 0.0; m->Vertices[2].x = 0.0; m->Vertices[2].y = 0.0; m->Vertices[2].z = 0.05; m->Vertices[3].x = 0.2; m->Vertices[3].y = 0.0; m->Vertices[3].z = 0.0; m->Vertices[4].x = 0.0; m->Vertices[4].y = 0.2; m->Vertices[4].z = 0.0; m->Vertices[5].x = 0.0; m->Vertices[5].y = 0.0; m->Vertices[5].z = 0.05; m->Vertices[6].x = 0.0; m->Vertices[6].y = -0.2; m->Vertices[6].z = 0.0; m->Vertices[7].x = -0.2; m->Vertices[7].y = 0.0; m->Vertices[7].z = 0.0; m->Vertices[8].x = 0.0; m->Vertices[8].y = 0.0; m->Vertices[8].z = 0.05; m->Vertices[9].x = 0.0; m->Vertices[9].y = -0.2; m->Vertices[9].z = 0.0; m->Vertices[10].x = 0.2; m->Vertices[10].y = 0.0; m->Vertices[10].z = 0.0; m->Vertices[11].x = 0.0; m->Vertices[11].y = 0.0; m->Vertices[11].z = 0.05; m->Vertices[12].x = 0.0; m->Vertices[12].y = 0.2; m->Vertices[12].z = 0.0; m->Vertices[13].x = -0.2; m->Vertices[13].y = 0.0; m->Vertices[13].z = 0.0; m->Vertices[14].x = 0.0; m->Vertices[14].y = 0.0; m->Vertices[14].z = -0.05; m->Vertices[15].x = 0.2; m->Vertices[15].y = 0.0; m->Vertices[15].z = 0.0; m->Vertices[16].x = 0.0; m->Vertices[16].y = 0.2; m->Vertices[16].z = 0.0; m->Vertices[17].x = 0.0; m->Vertices[17].y = 0.0; m->Vertices[17].z = -0.05; m->Vertices[18].x = 0.0; m->Vertices[18].y = -0.2; m->Vertices[18].z = 0.0; m->Vertices[19].x = -0.2; m->Vertices[19].y = 0.0; m->Vertices[19].z = 0.0; m->Vertices[20].x = 0.0; m->Vertices[20].y = 0.0; m->Vertices[20].z = -0.05; m->Vertices[21].x = 0.0; m->Vertices[21].y = -0.2; m->Vertices[21].z = 0.0; m->Vertices[22].x = 0.2; m->Vertices[22].y = 0.0; m->Vertices[22].z = 0.0; m->Vertices[23].x = 0.0; m->Vertices[23].y = 0.0; m->Vertices[23].z = -0.05; myVertices = m->Vertices; } } void BuildTurboPowerupModel(VModel * m) { static Vector * myVertices = NULL, * myMaskVertices = NULL; Vector LightningVertices[] = {{0.02, 0.25, 0.05}, {-0.1, -0.05, 0.05}, {-0.01, -0.05, 0.05}, {-0.02, -0.25, 0.05}, {0.1, 0.05, 0.05}, {0.01, 0.05, 0.05}, {0.02, 0.25, -0.05}, {-0.1, -0.05, -0.05}, {-0.01, -0.05, -0.05}, {-0.02, -0.25, -0.05}, {0.1, 0.05, -0.05}, {0.01, 0.05, -0.05}}; m->Color[0] = 1.0; m->Color[1] = 1.0; m->Color[2] = 0.2; m->PrimitiveType = GL_LINES; m->MaskPrimitiveType = GL_QUADS; if (myVertices != NULL && myMaskVertices != NULL) { m->NumberOfVertices = 36; m->Vertices = myVertices; m->NumberOfMaskVertices = 40; m->MaskVertices = myMaskVertices; return; } if (AllocateVertices(m, 36)) { m->Vertices[0] = LightningVertices[0]; m->Vertices[1] = LightningVertices[1]; m->Vertices[2] = LightningVertices[1]; m->Vertices[3] = LightningVertices[2]; m->Vertices[4] = LightningVertices[2]; m->Vertices[5] = LightningVertices[3]; m->Vertices[6] = LightningVertices[3]; m->Vertices[7] = LightningVertices[4]; m->Vertices[8] = LightningVertices[4]; m->Vertices[9] = LightningVertices[5]; m->Vertices[10] = LightningVertices[5]; m->Vertices[11] = LightningVertices[0]; m->Vertices[12] = LightningVertices[0]; m->Vertices[13] = LightningVertices[6]; m->Vertices[14] = LightningVertices[1]; m->Vertices[15] = LightningVertices[7]; m->Vertices[16] = LightningVertices[2]; m->Vertices[17] = LightningVertices[8]; m->Vertices[18] = LightningVertices[3]; m->Vertices[19] = LightningVertices[9]; m->Vertices[20] = LightningVertices[4]; m->Vertices[21] = LightningVertices[10]; m->Vertices[22] = LightningVertices[5]; m->Vertices[23] = LightningVertices[11]; m->Vertices[24] = LightningVertices[6]; m->Vertices[25] = LightningVertices[7]; m->Vertices[26] = LightningVertices[7]; m->Vertices[27] = LightningVertices[8]; m->Vertices[28] = LightningVertices[8]; m->Vertices[29] = LightningVertices[9]; m->Vertices[30] = LightningVertices[9]; m->Vertices[31] = LightningVertices[10]; m->Vertices[32] = LightningVertices[10]; m->Vertices[33] = LightningVertices[11]; m->Vertices[34] = LightningVertices[11]; m->Vertices[35] = LightningVertices[6]; myVertices = m->Vertices; } if (AllocateMaskVertices(m, 40)) { m->MaskVertices[0] = LightningVertices[0]; m->MaskVertices[1] = LightningVertices[6]; m->MaskVertices[2] = LightningVertices[7]; m->MaskVertices[3] = LightningVertices[1]; m->MaskVertices[4] = LightningVertices[1]; m->MaskVertices[5] = LightningVertices[7]; m->MaskVertices[6] = LightningVertices[8]; m->MaskVertices[7] = LightningVertices[2]; m->MaskVertices[8] = LightningVertices[2]; m->MaskVertices[9] = LightningVertices[8]; m->MaskVertices[10] = LightningVertices[9]; m->MaskVertices[11] = LightningVertices[3]; m->MaskVertices[12] = LightningVertices[3]; m->MaskVertices[13] = LightningVertices[9]; m->MaskVertices[14] = LightningVertices[10]; m->MaskVertices[15] = LightningVertices[4]; m->MaskVertices[16] = LightningVertices[4]; m->MaskVertices[17] = LightningVertices[10]; m->MaskVertices[18] = LightningVertices[11]; m->MaskVertices[19] = LightningVertices[5]; m->MaskVertices[20] = LightningVertices[5]; m->MaskVertices[21] = LightningVertices[11]; m->MaskVertices[22] = LightningVertices[6]; m->MaskVertices[23] = LightningVertices[0]; m->MaskVertices[24] = LightningVertices[0]; m->MaskVertices[25] = LightningVertices[1]; m->MaskVertices[26] = LightningVertices[2]; m->MaskVertices[27] = LightningVertices[5]; m->MaskVertices[28] = LightningVertices[2]; m->MaskVertices[29] = LightningVertices[3]; m->MaskVertices[30] = LightningVertices[4]; m->MaskVertices[31] = LightningVertices[5]; m->MaskVertices[32] = LightningVertices[6]; m->MaskVertices[33] = LightningVertices[7]; m->MaskVertices[34] = LightningVertices[8]; m->MaskVertices[35] = LightningVertices[11]; m->MaskVertices[36] = LightningVertices[8]; m->MaskVertices[37] = LightningVertices[9]; m->MaskVertices[38] = LightningVertices[10]; m->MaskVertices[39] = LightningVertices[11]; myMaskVertices = m->MaskVertices; } } void BuildMachineGunPowerupModel(VModel * m) { #pragma unused(m) return; } void BuildBackWallModel(VModel * m) { static Vector * myVertices = NULL, * myMaskVertices = NULL; int Tile; m->PrimitiveType = GL_LINES; m->WireFrame = false; m->Color[0] = 0.5; m->Color[1] = 0.5; m->Color[2] = 0.5; m->Color[3] = 1.0; m->NumberOfMaskVertices = 0; m->MaskPrimitiveType = GL_QUADS; if (myVertices != NULL && myMaskVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 22; m->MaskVertices = myMaskVertices; m->NumberOfMaskVertices = 4; return; } if(AllocateVertices(m, 22)) { for (Tile = 0; Tile < 11; Tile++) { m->Vertices[(Tile * 2)].x = (Tile * 4); m->Vertices[(Tile * 2)].y = 0; m->Vertices[(Tile * 2)].z = 40; m->Vertices[(Tile * 2) + 1].x = (Tile * 4); m->Vertices[(Tile * 2) + 1].y = 40; m->Vertices[(Tile * 2) + 1].z = 40; } myVertices = m->Vertices; } if(AllocateMaskVertices(m, 4)) { m->MaskVertices[0].x = 0; m->MaskVertices[0].y = 0; m->MaskVertices[0].z = 40; m->MaskVertices[1].x = 40; m->MaskVertices[1].y = 0; m->MaskVertices[1].z = 40; m->MaskVertices[2].x = 40; m->MaskVertices[2].y = 40; m->MaskVertices[2].z = 40; m->MaskVertices[3].x = 0; m->MaskVertices[3].y = 40; m->MaskVertices[3].z = 40; myMaskVertices = m->MaskVertices; } } void BuildFrontWallModel(VModel * m) { static Vector * myVertices = NULL, * myMaskVertices = NULL; int Tile; m->PrimitiveType = GL_LINES; m->WireFrame = false; m->Color[0] = 0.5; m->Color[1] = 0.5; m->Color[2] = 0.5; m->Color[3] = 1.0; m->NumberOfMaskVertices = 0; m->MaskPrimitiveType = GL_QUADS; if (myVertices != NULL && myMaskVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 22; m->MaskVertices = myMaskVertices; m->NumberOfMaskVertices = 4; return; } if(AllocateVertices(m, 22)) { for (Tile = 0; Tile < 11; Tile++) { m->Vertices[(Tile * 2)].x = (Tile * 4); m->Vertices[(Tile * 2)].y = 0; m->Vertices[(Tile * 2)].z = 0; m->Vertices[(Tile * 2) + 1].x = (Tile * 4); m->Vertices[(Tile * 2) + 1].y = 40; m->Vertices[(Tile * 2) + 1].z = 0; } myVertices = m->Vertices; } if(AllocateMaskVertices(m, 4)) { m->MaskVertices[0].x = 0; m->MaskVertices[0].y = 0; m->MaskVertices[0].z = 0; m->MaskVertices[1].x = 40; m->MaskVertices[1].y = 0; m->MaskVertices[1].z = 0; m->MaskVertices[2].x = 40; m->MaskVertices[2].y = 40; m->MaskVertices[2].z = 0; m->MaskVertices[3].x = 0; m->MaskVertices[3].y = 40; m->MaskVertices[3].z = 0; myMaskVertices = m->MaskVertices; } } void BuildLeftWallModel(VModel * m) { static Vector * myVertices = NULL, * myMaskVertices = NULL; int Tile; m->PrimitiveType = GL_LINES; m->WireFrame = false; m->Color[0] = 0.5; m->Color[1] = 0.5; m->Color[2] = 0.5; m->Color[3] = 1.0; m->NumberOfMaskVertices = 0; m->MaskPrimitiveType = GL_QUADS; if (myVertices != NULL && myMaskVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 22; m->MaskVertices = myMaskVertices; m->NumberOfMaskVertices = 4; return; } if(AllocateVertices(m, 22)) { for (Tile = 0; Tile < 11; Tile++) { m->Vertices[(Tile * 2)].x = 0; m->Vertices[(Tile * 2)].y = 0; m->Vertices[(Tile * 2)].z = (Tile * 4); m->Vertices[(Tile * 2) + 1].x = 0; m->Vertices[(Tile * 2) + 1].y = 40; m->Vertices[(Tile * 2) + 1].z = (Tile * 4); } myVertices = m->Vertices; } if(AllocateMaskVertices(m, 4)) { m->MaskVertices[0].x = 0; m->MaskVertices[0].y = 0; m->MaskVertices[0].z = 0; m->MaskVertices[1].x = 0; m->MaskVertices[1].y = 40; m->MaskVertices[1].z = 0; m->MaskVertices[2].x = 0; m->MaskVertices[2].y = 40; m->MaskVertices[2].z = 40; m->MaskVertices[3].x = 0; m->MaskVertices[3].y = 0; m->MaskVertices[3].z = 40; myMaskVertices = m->MaskVertices; } } void BuildRightWallModel(VModel * m) { static Vector * myVertices = NULL, * myMaskVertices = NULL; int Tile; m->PrimitiveType = GL_LINES; m->WireFrame = false; m->Color[0] = 0.5; m->Color[1] = 0.5; m->Color[2] = 0.5; m->Color[3] = 1.0; m->NumberOfMaskVertices = 0; m->MaskPrimitiveType = GL_QUADS; if (myVertices != NULL && myMaskVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 22; m->MaskVertices = myMaskVertices; m->NumberOfMaskVertices = 4; return; } if(AllocateVertices(m, 22)) { for (Tile = 0; Tile < 11; Tile++) { m->Vertices[(Tile * 2)].x = 40; m->Vertices[(Tile * 2)].y = 0; m->Vertices[(Tile * 2)].z = (Tile * 4); m->Vertices[(Tile * 2) + 1].x = 40; m->Vertices[(Tile * 2) + 1].y = 40; m->Vertices[(Tile * 2) + 1].z = (Tile * 4); } myVertices = m->Vertices; } if(AllocateMaskVertices(m, 4)) { m->MaskVertices[0].x = 40; m->MaskVertices[0].y = 0; m->MaskVertices[0].z = 0; m->MaskVertices[1].x = 40; m->MaskVertices[1].y = 40; m->MaskVertices[1].z = 0; m->MaskVertices[2].x = 40; m->MaskVertices[2].y = 40; m->MaskVertices[2].z = 40; m->MaskVertices[3].x = 40; m->MaskVertices[3].y = 0; m->MaskVertices[3].z = 40; myMaskVertices = m->MaskVertices; } } void BuildFloorModel(VModel * m) { static Vector * myVertices = NULL, * myMaskVertices = NULL; int Tile; m->PrimitiveType = GL_LINES; m->WireFrame = false; m->Color[0] = 0.5; m->Color[1] = 0.5; m->Color[2] = 0.5; m->Color[3] = 1.0; m->MaskPrimitiveType = GL_QUADS; if (myVertices != NULL && myMaskVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 44; m->MaskVertices = myMaskVertices; m->NumberOfMaskVertices = 4; return; } if(AllocateVertices(m, 44)) { for (Tile = 0; Tile < 11; Tile++) { m->Vertices[(Tile * 2)].x = 0; m->Vertices[(Tile * 2)].y = 0; m->Vertices[(Tile * 2)].z = (Tile * 4); m->Vertices[(Tile * 2) + 1].x = 40; m->Vertices[(Tile * 2) + 1].y = 0; m->Vertices[(Tile * 2) + 1].z = (Tile * 4); } for (Tile = 0; Tile < 11; Tile++) { m->Vertices[(Tile * 2) + 22].x = (Tile * 4); m->Vertices[(Tile * 2) + 22].y = 0; m->Vertices[(Tile * 2) + 22].z = 0; m->Vertices[(Tile * 2) + 23].x = (Tile * 4); m->Vertices[(Tile * 2) + 23].y = 0; m->Vertices[(Tile * 2) + 23].z = 40; } myVertices = m->Vertices; } if(AllocateMaskVertices(m, 4)) { m->MaskVertices[0].x = 40; m->MaskVertices[0].y = 0; m->MaskVertices[0].z = 0; m->MaskVertices[1].x = 0; m->MaskVertices[1].y = 0; m->MaskVertices[1].z = 0; m->MaskVertices[2].x = 0; m->MaskVertices[2].y = 0; m->MaskVertices[2].z = 40; m->MaskVertices[3].x = 40; m->MaskVertices[3].y = 0; m->MaskVertices[3].z = 40; myMaskVertices = m->MaskVertices; } } void BuildCeilingModel(VModel * m) { static Vector * myVertices = NULL, * myMaskVertices = NULL; int Tile; m->PrimitiveType = GL_LINES; m->WireFrame = false; m->Color[0] = 0.5; m->Color[1] = 0.5; m->Color[2] = 0.5; m->Color[3] = 1.0; m->MaskPrimitiveType = GL_QUADS; if (myVertices != NULL && myMaskVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 44; m->MaskVertices = myMaskVertices; m->NumberOfMaskVertices = 4; return; } if(AllocateVertices(m, 44)) { for (Tile = 0; Tile < 11; Tile++) { m->Vertices[(Tile * 2)].x = 0; m->Vertices[(Tile * 2)].y = 40; m->Vertices[(Tile * 2)].z = (Tile * 4); m->Vertices[(Tile * 2) + 1].x = 40; m->Vertices[(Tile * 2) + 1].y = 40; m->Vertices[(Tile * 2) + 1].z = (Tile * 4); } for (Tile = 0; Tile < 11; Tile++) { m->Vertices[(Tile * 2) + 22].x = (Tile * 4); m->Vertices[(Tile * 2) + 22].y = 40; m->Vertices[(Tile * 2) + 22].z = 0; m->Vertices[(Tile * 2) + 23].x = (Tile * 4); m->Vertices[(Tile * 2) + 23].y = 40; m->Vertices[(Tile * 2) + 23].z = 40; } myVertices = m->Vertices; } if(AllocateMaskVertices(m, 4)) { m->MaskVertices[0].x = 40; m->MaskVertices[0].y = 40; m->MaskVertices[0].z = 0; m->MaskVertices[1].x = 0; m->MaskVertices[1].y = 40; m->MaskVertices[1].z = 0; m->MaskVertices[2].x = 0; m->MaskVertices[2].y = 40; m->MaskVertices[2].z = 40; m->MaskVertices[3].x = 40; m->MaskVertices[3].y = 40; m->MaskVertices[3].z = 40; myMaskVertices = m->MaskVertices; } } void BuildTargetBoxModel(VModel * m) { static Vector * myVertices = NULL, * myMaskVertices = NULL; int segment; m->PrimitiveType = GL_LINE_LOOP; m->WireFrame = true; m->Color[0] = 0.0; m->Color[1] = 0.0; m->Color[2] = 1.0; m->Color[3] = 0.7; m->NumberOfMaskVertices = 0; m->MaskVertices = NULL; if (myVertices != NULL) { m->Vertices = myVertices; m->NumberOfVertices = 32; return; } if (AllocateVertices(m, 32)) { for (segment = 0; segment < 32; segment++) { m->Vertices[segment].x = (cos(((pi * 2) * segment) / 32.0) / 4.0); m->Vertices[segment].y = (sin(((pi * 2) * segment) / 32.0) / 4.0); m->Vertices[segment].z = 0.0; } myVertices = m->Vertices; } }