-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cxx
138 lines (118 loc) · 3.4 KB
/
main.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* bzflag-model-writer
* Copyright (c) 2021 Scott Wichser
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the license found in the file
* named LICENSE.md that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "TankGeometryMgr.h"
#include "glwriter.h"
enum TeamColor
{
RogueTeam = 0,
RedTeam = 1,
GreenTeam = 2,
BlueTeam = 3,
PurpleTeam = 4,
ObserverTeam = 5,
RabbitTeam = 6,
HunterTeam = 7
};
static float tankColors[8][3] =
{
{ 1.0f, 1.0f, 0.0f }, // rogue
{ 1.0f, 0.0f, 0.0f }, // red
{ 0.0f, 1.0f, 0.0f }, // green
{ 0.1f, 0.2f, 1.0f }, // blue
{ 1.0f, 0.0f, 1.0f }, // purple
{ 1.0f, 1.0f, 1.0f }, // observer
{ 0.8f, 0.8f, 0.8f }, // rabbit
{ 1.0f, 0.5f, 0.0f } // hunter orange
};
int main()
{
// Enable textures
bool textured = true;
// Pick a team, any team
TeamColor team = RedTeam;
// Convert that team to a string
std::string teamString;
switch(team)
{
case RedTeam:
teamString = "red";
break;
case GreenTeam:
teamString = "green";
break;
case BlueTeam:
teamString = "blue";
break;
case PurpleTeam:
teamString = "purple";
break;
case ObserverTeam:
teamString = "observer";
break;
case RabbitTeam:
teamString = "rabbit";
break;
case HunterTeam:
teamString = "hunter";
break;
default:
teamString = "rogue";
break;
}
float color[3] = { tankColors[team][0], tankColors[team][1], tankColors[team][2] };
// do not use color modulation with tank textures
if (textured)
color[0] = color[1] = color[2] = 1.0f;
// Create materials
MaterialInfo body, barrel, turret, casing, tread, wheel;
int i;
// Body material
for (i = 0; i <= 2; ++i)
body.diffuse[i] = color[i];
if (textured)
body.diffuseTexture = "data/" + teamString + "_tank.png";
// Barrel material
for (i = 0; i <= 2; ++i)
barrel.diffuse[i] = 0.25f;
// Turret material
for (i = 0; i <= 2; ++i)
turret.diffuse[i] = 0.9f * color[i];
if (textured)
turret.diffuseTexture = "data/" + teamString + "_tank.png";
// (Tread) casing material
for (i = 0; i <= 2; ++i)
casing.diffuse[i] = 0.7f * color[i];
if (textured)
casing.diffuseTexture = "data/" + teamString + "_tank.png";
// Tread material
for (i = 0; i <= 2; ++i)
tread.diffuse[i] = 0.3f * color[i];
if (textured)
tread.diffuseTexture = "data/treads.png";
// Wheel material
for (i = 0; i <= 2; ++i)
wheel.diffuse[i] = 0.4f * color[i];
if (textured)
wheel.diffuseTexture = "data/" + teamString + "_tank.png";
// Add our materials
glWriterAddMaterial("body", body);
glWriterAddMaterial("barrel", barrel);
glWriterAddMaterial("turret", turret);
glWriterAddMaterial("casing", casing);
glWriterAddMaterial("tread", tread);
glWriterAddMaterial("wheel", wheel);
// Build all the tank sizes
TankGeometryMgr::init();
TankGeometryMgr::buildLists();
TankGeometryMgr::kill();
return 0;
}