Repository navigation
Expand file tree
/
Copy pathprocedural.cpp
More file actions
executable file
·651 lines (528 loc) · 17.6 KB
/
Copy pathprocedural.cpp
File metadata and controls
executable file
·651 lines (528 loc) · 17.6 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
#include "procedural.h"
#include "../grinliz/glvector.h"
#include "../game/gameitem.h"
#include "../xegame/istringconst.h"
#include "../game/team.h"
using namespace grinliz;
HumanGen::HumanGen( bool female, U32 seed, int team, bool electric )
{
this->female = female;
this->seed = seed;
this->team = team;
this->electric = electric;
}
void HumanGen::GetSkinColor( int index, Color4F* color )
{
static const int NUM_SKIN_COLORS = 4;
static const Vector2I c[NUM_SKIN_COLORS] = {
{ PAL_PURPLE*2, PAL_TANGERINE },
{ PAL_TANGERINE*2+1, PAL_PURPLE },
{ PAL_TANGERINE*2+1, PAL_GRAY },
{ PAL_GRAY*2, PAL_TANGERINE }
};
int i = abs(index) % NUM_SKIN_COLORS;
const Game::Palette* palette = Game::GetMainPalette();
*color = palette->Get4F(c[i].x, c[i].y);
}
void HumanGen::GetGlassesColor( int index, Color4F* color )
{
static const int NUM_GLASSES_COLORS = 6;
static const Vector2I c[NUM_GLASSES_COLORS] = {
{ PAL_BLUE*2, PAL_ZERO },
{ PAL_BLUE*2, PAL_RED },
{ PAL_BLUE*2, PAL_GREEN },
{ PAL_ZERO*2+1, PAL_BLUE },
{ PAL_RED*2+1, PAL_BLUE },
{ PAL_RED*2+1, PAL_PURPLE }
};
int i = abs(index) % NUM_GLASSES_COLORS;
const Game::Palette* palette = Game::GetMainPalette();
*color = palette->Get4F(c[i].x, c[i].y);
}
void HumanGen::GetHairColor( int index, Color4F* color )
{
static const int N_FEMALE = 9;
static const int N_MALE = 7;
static const Vector2I cFemale[N_FEMALE] = {
// natural
{ PAL_GREEN*2, PAL_RED },
{ PAL_RED*2+0, PAL_TANGERINE },
{ PAL_PURPLE*2, PAL_TANGERINE },
{ PAL_RED*2+1, PAL_GREEN },
{ PAL_TANGERINE*2+1, PAL_PURPLE },
// intense
{ PAL_RED*2+1, PAL_RED },
{ PAL_ZERO*2+1, PAL_TANGERINE },
{ PAL_ZERO*2+1, PAL_BLUE },
{ PAL_GRAY*2, PAL_GRAY }
};
static const Vector2I cMale[N_MALE] = {
// natural
{ PAL_GREEN*2, PAL_RED },
{ PAL_RED*2+0, PAL_TANGERINE },
{ PAL_PURPLE*2, PAL_TANGERINE },
{ PAL_RED*2+1, PAL_GREEN },
{ PAL_TANGERINE*2+1, PAL_PURPLE },
// intense
{ PAL_ZERO*2+1, PAL_TANGERINE },
{ PAL_GRAY*2, PAL_GRAY }
};
const Game::Palette* palette = Game::GetMainPalette();
if ( female ) {
int index0 = abs(index) % N_FEMALE;
*color = palette->Get4F( cFemale[index0].x, cFemale[index0].y );
}
else {
int index0 = abs(index) % N_MALE;
*color = palette->Get4F( cMale[index0].x, cMale[index0].y );
}
}
void HumanGen::GetSuitColor( grinliz::Vector4F* c )
{
// Suits are at the right column and bottom row
// of the color palette. Just to be a little fancy,
// ony use colors that are in the team palette
// somewhere.
Vector2I cvec[3];
TeamGen::TeamBuildColors(team, cvec + 0, cvec + 1, cvec + 2);
static const int N = 3;
Vector2I arr[N];
arr[0].Set(PAL_GRAY * 2, cvec[0].y);
arr[1].Set(cvec[0].x, PAL_GRAY);
arr[2].Set(cvec[0].x + 1, PAL_GRAY);
int teamID, teamGroup;
Team::SplitID(team, &teamGroup, &teamID);
int index = abs(teamID + int(seed)) % N;
const Game::Palette* palette = Game::GetMainPalette();
*c = palette->Get4F(arr[index]);
c->w = 0.7f;
}
void HumanGen::GetColors(grinliz::Vector4F* c)
{
Random random(seed);
random.Rand();
GetSkinColor(random.Rand(), c + SKIN);
GetHairColor(random.Rand(), c + HAIR);
GetGlassesColor(random.Rand(), c + GLASSES);
if (electric) {
c[SKIN] = c[SKIN] + c[HAIR] * 0.5f + c[GLASSES] * 0.5f;
c[HAIR] = c[HAIR] + c[GLASSES] * 0.5f;
}
}
void HumanGen::AssignFace( ProcRenderInfo* info )
{
Random random( seed );
random.Rand();
Vector4F vcol[3];
GetColors( vcol );
// Get the texture to get the the metadata
Texture* texture = 0;
if ( female ) {
texture = TextureManager::Instance()->GetTexture( "humanFemaleFaceAtlas" );
}
else {
texture = TextureManager::Instance()->GetTexture( "humanMaleFaceAtlas" );
}
GLASSERT( texture );
info->texture = texture;
texture->GetTableEntry( random.Rand( texture->NumTableEntries() ), &info->te );
info->color.SetCol( 0, vcol[0] );
info->color.SetCol( 1, vcol[1] );
info->color.SetCol( 2, vcol[2] );
// Alpha information solely from the alpha channel.
//info->color.m41 = 0;
//info->color.m42 = 0;
//info->color.m43 = 0;
//info->color.m44 = 1;
info->color.SetRow(3, 0, 0, 0, 1);
}
void HumanGen::AssignSuit( ProcRenderInfo* info )
{
Random random( seed );
random.Rand();
Vector4F vcol[3];
GetColors( vcol );
GetSuitColor( &vcol[2] );
// Get the texture to get the the metadata
Texture* texture = 0;
if ( female ) {
texture = TextureManager::Instance()->GetTexture( "femsuit0" );
}
else {
texture = TextureManager::Instance()->GetTexture( "suit0" );
}
GLASSERT( texture );
info->texture = texture;
//texture->GetTableEntry( random.Rand( texture->NumTableEntries() ), &info->te );
vcol[2].w = 0.7f; // suit glow
info->color.SetCol( 0, vcol[0] );
info->color.SetCol( 1, vcol[1] );
info->color.SetCol( 2, vcol[2] );
// alpha interpreted as emissive; comes from color2
info->color.SetRow(3, 0, 0, 0, 1);
// info->color.m41 = 0;
// info->color.m42 = 0;
// info->color.m43 = 0;
// info->color.m44 = 1;
}
WeaponGen::WeaponGen(U32 _seed, int _team, int _effectFlags, int _features) : seed(_seed), team(_team), effectFlags(_effectFlags), features(_features)
{
}
Color4F WeaponGen::GetEffectColor(int flags)
{
Vector2I effect = { 0, 0 };
float alpha = 0.0;
switch ( flags & (GameItem::EFFECT_FIRE | GameItem::EFFECT_SHOCK)) {
case 0: effect.Set( 1, PAL_GREEN ); break;
case GameItem::EFFECT_FIRE: effect.Set( 1, PAL_RED ); alpha=0.7f; break;
case GameItem::EFFECT_SHOCK: effect.Set( 1, PAL_BLUE ); alpha=1.0f; break;
case GameItem::EFFECT_FIRE | GameItem::EFFECT_SHOCK: effect.Set( PAL_PURPLE*2+1, PAL_GRAY ); alpha=0.7f; break;
default:
GLASSERT( 0 );
break;
}
const Game::Palette* palette = Game::GetMainPalette();
Color4F effectColor = palette->Get4F( effect.x, effect.y );
effectColor.a() = alpha;
return effectColor;
}
void WeaponGen::GetColors( int flags, grinliz::Color4F* array )
{
// red for fire
// green for shock/corruption?
static const Vector2I c[NUM_COLORS*3] = {
{ PAL_GREEN*2, PAL_ZERO }, { PAL_GREEN*2, PAL_ZERO }, { PAL_BLUE*2+1, PAL_GRAY },
{ PAL_GREEN*2, PAL_ZERO }, { PAL_GREEN*2, PAL_RED }, { PAL_BLUE*2+1, PAL_GRAY },
{ PAL_GREEN*2+1, PAL_BLUE }, { PAL_GREEN*2+1, PAL_BLUE }, { PAL_BLUE*2+1, PAL_GRAY },
{ PAL_GREEN*2+1, PAL_BLUE }, { PAL_GREEN*2+1, PAL_PURPLE }, { PAL_BLUE*2+1, PAL_GRAY },
{ PAL_GREEN*2+1, PAL_PURPLE }, { PAL_GREEN*2+1, PAL_PURPLE }, { PAL_GREEN*2, PAL_GRAY },
{ PAL_BLUE*2, PAL_RED }, { PAL_BLUE*2, PAL_RED }, { PAL_BLUE*2+1, PAL_GRAY },
{ PAL_PURPLE*2, PAL_RED }, { PAL_BLUE*2, PAL_RED }, { PAL_PURPLE*2+1, PAL_GRAY },
{ PAL_GRAY*2, PAL_GRAY }, { PAL_GRAY*2, PAL_GRAY }, { PAL_BLUE*2+1, PAL_GRAY },
{ PAL_GRAY*2, PAL_GRAY }, { PAL_GRAY*2, PAL_PURPLE }, { PAL_BLUE*2+1, PAL_GRAY },
{ PAL_GRAY*2, PAL_GRAY }, { PAL_GRAY*2, PAL_BLUE }, { PAL_BLUE*2+1, PAL_GRAY },
{ PAL_GRAY*2, PAL_GRAY }, { PAL_GRAY*2, PAL_TANGERINE }, { PAL_BLUE*2+1, PAL_GRAY },
};
int i = seed % NUM_COLORS;
Color4F effectColor = GetEffectColor(flags);
float alpha = effectColor.a();
const Game::Palette* palette = Game::GetMainPalette();
// Add in explosive as a modifying color to the main 2.
// At the time of this code being written, I don't
// expect exlposive to be very common.
if ( flags & GameItem::EFFECT_EXPLOSIVE ) {
Color4F ec = palette->Get4F( PAL_TANGERINE*2, 0 );
for( int i=0; i<3; ++i )
effectColor.X(i) = Mean( effectColor.X(i), ec.X(i) );
alpha = Max( 0.7f, alpha );
}
effectColor.a() = alpha;
Color4F base = palette->Get4F( c[i*3+0].x, c[i*3+0].y );
array[BASE] = base;
Color4F contrast = palette->Get4F( c[i*3+1].x, c[i*3+1].y );
static const float LERP = 0.65f;
array[CONTRAST].Set( Lerp( base.r(), contrast.r(), LERP ),
Lerp( base.g(), contrast.g(), LERP ),
Lerp( base.b(), contrast.b(), LERP ),
Lerp( base.a(), contrast.a(), LERP ) );
// Handle special cases.
if (Team::Group(team) == TEAM_TROLL) {
static const Vector2I TROLL_CONTRAST[] = {
{ 2, 3 }, { 2, 2 }, { 4, 2 }, { 10, 0 }, { 10, 2 }, { 10, 5 }
};
static const int NUM_TROLL_CONTRAST = GL_C_ARRAY_SIZE(TROLL_CONTRAST);
int index = seed % NUM_TROLL_CONTRAST;
array[BASE] = palette->Get4F(PAL_GRAY * 2, PAL_GREEN);
array[CONTRAST] = palette->Get4F(TROLL_CONTRAST[index]);
}
else if (Team::Group(team) == TEAM_GOB) {
base = palette->Get4F(PAL_GRAY * 2, PAL_PURPLE);
contrast = palette->Get4F(PAL_RED * 2, PAL_PURPLE);
}
array[EFFECT] = effectColor;
array[BASE].a() = 0;
array[CONTRAST].a() = 0;
array[EFFECT].a() = alpha;
}
void WeaponGen::AssignRing( ProcRenderInfo* info )
{
Random random( seed );
random.Rand();
Color4F c[3];
GetColors(effectFlags, c );
for( int i=0; i<3; ++i ) {
info->color.SetCol( i, c[i] );
}
//info->color.m44 = 0;
info->color.X(Matrix4::M44) = 0;
Texture* texture = TextureManager::Instance()->GetTexture( "ringAtlas" );
GLASSERT( texture );
info->texture = texture;
texture->GetTableEntry( random.Rand( texture->NumTableEntries() ), &info->te );
info->filter[0] = true;
info->filter[1] = (features & RING_GUARD) != 0;
info->filter[2] = (features & RING_TRIAD) != 0;
info->filter[3] = (features & RING_BLADE) != 0;
static const char* procNames[4] = {
"main",
"guard",
"triad",
"blade"
};
for( int i=0; i<4; ++i ) {
info->filterName[i] = StringPool::Intern( procNames[i] );
}
}
void WeaponGen::AssignShield( ProcRenderInfo* info )
{
Random random( seed );
random.Rand();
Color4F c[3];
Vector4F v[3] = { V4F_ZERO, V4F_ZERO, V4F_ZERO };
GetColors( effectFlags, c );
for( int i=0; i<3; ++i ) {
v[i] = c[i];
}
v[CONTRAST].w = Max( v[CONTRAST].w, 0.7f );
// Red: outer
info->color.SetCol( 0, v[BASE] );
// Blue: ring
info->color.SetCol( 2, v[CONTRAST] );
// Effect: inner
info->color.SetCol( 1, v[EFFECT] );
//info->color.m44 = 0;
info->color.X(Matrix4::M44) = 0;
Texture* texture = TextureManager::Instance()->GetTexture( "structure" );
GLASSERT( texture );
info->texture = texture;
}
void WeaponGen::AssignGun( ProcRenderInfo* info )
{
Random random( seed );
random.Rand();
Color4F c[3];
GetColors( effectFlags, c );
for( int i=0; i<3; ++i ) {
info->color.SetCol( i, c[i] );
}
info->color.X(Matrix4::M44) = 0;
// info->color.m44 = 0;
Texture* texture = TextureManager::Instance()->GetTexture( "structure" );
GLASSERT( texture );
info->texture = texture;
info->filter[0] = true;
info->filter[1] = (features & GUN_CELL) != 0;
info->filter[2] = (features & GUN_DRIVER) != 0;
info->filter[3] = (features & GUN_SCOPE) != 0;
static const char* GUN_PARTS[4] = { "body", "cell", "driver", "scope" };
for( int i=0; i<4; ++i ) {
info->filterName[i] = StringPool::Intern( GUN_PARTS[i] );
}
}
void TeamGen::TeamBuildColors(int team, grinliz::Vector2I* base, grinliz::Vector2I* contrast, grinliz::Vector2I* glow)
{
static const Vector2I NEUTRAL_COLORS[] = {
{ 0, PAL_GRAY }, { 0, PAL_GRAY }, { 0, PAL_GRAY }
};
static const Vector2I TROLL_COLORS[] = {
{ PAL_GRAY * 2, PAL_GREEN }, { PAL_RED * 2, PAL_GREEN }, { PAL_TANGERINE * 2, PAL_GREEN }
};
static const Vector2I GREEN_MANTIS_COLORS[] = {
{ PAL_GREEN * 2, PAL_GREEN }, { PAL_TANGERINE * 2, PAL_TANGERINE }, { PAL_TANGERINE * 2, PAL_TANGERINE }
};
static const Vector2I RED_MANTIS_COLORS[] = {
{ PAL_RED * 2, PAL_RED }, { PAL_TANGERINE * 2, PAL_TANGERINE }, {PAL_TANGERINE*2, PAL_TANGERINE}
};
static const Vector2I TRILOBYTE_COLORS[] = {
{ PAL_TANGERINE * 2 + 1, PAL_PURPLE }, { PAL_BLUE * 2, PAL_GREEN }, { PAL_BLUE * 2, PAL_GREEN }
};
static const Vector2I GOB_COLORS[] = {
{ PAL_GRAY * 2, PAL_PURPLE }, { PAL_RED * 2, PAL_PURPLE }, { PAL_GRAY * 2, PAL_PURPLE }
};
static const Vector2I KAMAKIRI_COLORS[] = {
{ 4, 1 }, { 6, 0 }, {4, 1},
{ 4, 1 }, { 6, 0 }, {10, 3},
{ 6, 0 }, { 4, 2 }, { 7, 5 },
{ 6, 0 }, { 10, 3 }, {4,0}
};
static const Vector2I HUMAN_COLORS[] = {
{ 8, 3 }, { 6, 3 }, { 8, 3 },
{8, 3}, {12, 5}, {8, 3},
{10, 3}, {7, 4}, {8, 3},
{10, 3}, {6, 1}, {10, 3},
{10, 3}, {4, 2}, {3, 2},
{6, 1}, {8, 3}, {6, 1},
//{8, 1}, {6, 0}, {7, 4},
//{8, 1}, {12, 5}, {8, 2},
{10, 1}, {6, 4}, {10, 1},
{6, 2}, {8, 2}, {8, 2},
{6, 2}, {10, 2}, {6, 2},
{8, 2}, {10, 3}, {10, 3},
{10, 2}, {10, 3}, {10, 3},
{6, 3}, {6, 1}, {6, 1},
//{10, 3}, {3, 4}, {3, 4},
{10, 3}, {1, 3}, {10, 3}
};
const Vector2I* colors = HUMAN_COLORS;
int nColors = GL_C_ARRAY_SIZE(HUMAN_COLORS) / 3;
int teamGroup = 0;
int teamID = 0;
Team::SplitID(team, &teamGroup, &teamID);
switch (teamGroup) {
case TEAM_HOUSE:
case TEAM_CHAOS:
case TEAM_ID_LEFT:
colors = HUMAN_COLORS;
nColors = GL_C_ARRAY_SIZE(HUMAN_COLORS) / 3;
break;
case TEAM_TROLL:
case DEITY_TRUULGA:
colors = TROLL_COLORS;
nColors = GL_C_ARRAY_SIZE(TROLL_COLORS) / 3;
break;
case TEAM_GREEN_MANTIS:
colors = GREEN_MANTIS_COLORS;
nColors = GL_C_ARRAY_SIZE(GREEN_MANTIS_COLORS) / 3;
break;
case TEAM_RED_MANTIS:
colors = RED_MANTIS_COLORS;
nColors = GL_C_ARRAY_SIZE(RED_MANTIS_COLORS) / 3;
break;
case TEAM_TRILOBYTE:
colors = TRILOBYTE_COLORS;
nColors = GL_C_ARRAY_SIZE(TRILOBYTE_COLORS) / 3;
break;
case TEAM_GOB:
colors = GOB_COLORS;
nColors = GL_C_ARRAY_SIZE(GOB_COLORS) / 3;
break;
case TEAM_KAMAKIRI:
case TEAM_ID_RIGHT:
colors = KAMAKIRI_COLORS;
nColors = GL_C_ARRAY_SIZE(KAMAKIRI_COLORS) / 3;
break;
case TEAM_NEUTRAL:
case DEITY_MOTHER_CORE:
case DEITY_Q:
case DEITY_R1K:
case DEITY_KAXA:
colors = NEUTRAL_COLORS;
nColors = GL_C_ARRAY_SIZE(NEUTRAL_COLORS) / 3;
break;
default:
GLASSERT(0); // team not implemented? may be fine; just need to check.
break;
}
int index = abs(teamID) % nColors;
if (base) *base = colors[index * 3 + 0];
if (contrast) *contrast = colors[index * 3 + 1];
if (glow) *glow = colors[index * 3 + 2];
}
void TeamGen::TeamWeaponColors(int team, grinliz::Vector2I* base, grinliz::Vector2I* contrast)
{
static const Vector2I TROLL_COLORS[] = {
{ PAL_GRAY * 2, PAL_GREEN }, { PAL_RED * 2, PAL_GREEN }, { PAL_TANGERINE * 2, PAL_GREEN }
};
static const Vector2I KAMAKIRI_COLORS[] = {
{ 4, 2 }, { 6, 0 },
{ 4, 2 }, { 10, 3 },
{ 4, 2 }, { 7, 5 },
};
static const Vector2I GENERAL_COLORS[] = {
{4,0}, {6,0}, {4,1}, {8,1}, {6,1}, {6,0}, {8,1}, {10,0},
{3,2}, {10,0}, {8,2}, {8,3}, {8,2}, {6,4}, {8,2}, {7,4},
{10,2}, {3,2}, {6,3}, {8,2}, {8,3}, {4,1}, {8,3}, {4,2},
{8,3}, {8,2}, {8,3}, {7,4}, {8,3}, {7,5}, {8,3}, {10,5},
{3,4}, {8,3}, {3,4}, {3,2}, {3,4}, {1,3}, {4,4}, {4,2},
{4,4}, {6,2}, {4,4}, {8,2}, {4,4}, {10,2}, {4,4}, {7,4},
{5,4}, {8,3}, {5,4}, {8,2}, {6,4}, {4,2}, {6,4}, {7,4},
{6,4}, {5,4}
};
const Vector2I* colors = GENERAL_COLORS;
int nColors = GL_C_ARRAY_SIZE(GENERAL_COLORS) / 2;
int teamGroup = 0;
int teamID = 0;
Team::SplitID(team, &teamGroup, &teamID);
switch (teamGroup) {
case TEAM_HOUSE:
case TEAM_GOB:
colors = GENERAL_COLORS;
nColors = GL_C_ARRAY_SIZE(GENERAL_COLORS) / 2;
break;
case TEAM_TROLL:
colors = TROLL_COLORS;
nColors = GL_C_ARRAY_SIZE(TROLL_COLORS) / 2;
break;
case TEAM_KAMAKIRI:
colors = KAMAKIRI_COLORS;
nColors = GL_C_ARRAY_SIZE(KAMAKIRI_COLORS) / 2;
break;
case TEAM_NEUTRAL:
default:
GLASSERT(0); // team not implemented? unexpected?
break;
}
int index = abs(teamID) % nColors;
*base = colors[index * 2 + 0];
*contrast = colors[index * 2 + 1];
}
void TeamGen::Assign(int team, ProcRenderInfo* info)
{
info->texture = TextureManager::Instance()->GetTexture( "structure" );
Vector2I vbase, vcontrast, vglow;
TeamGen::TeamBuildColors(team, &vbase, &vcontrast, &vglow);
const Game::Palette* palette = Game::GetMainPalette();
Vector4F base = palette->Get4F(vbase);
Vector4F contrast = palette->Get4F(vcontrast);
Vector4F glow = palette->Get4F(vglow);
base.w = 0;
contrast.w = 0;
glow.w = 0.7f;
info->color.SetCol( 0, base );
info->color.SetCol( 1, contrast );
info->color.SetCol( 2, glow );
info->color.X(Matrix4::M44) = 0;
// info->color.m44 = 0;
}
void AssignProcedural(const GameItem* item, ProcRenderInfo* info)
{
if (!item) return;
IString proc = item->keyValues.GetIString("procedural");
if (proc.empty()) return;
bool female = item->IsFemale();
U32 seed = item->ID();
int team = item->Team();
bool electric = false; // not using; FIXME revisit 'electric'
int effects = item->Effects();
int features = 0;
item->keyValues.Get(ISC::features, &features);
AssignProcedural(proc, female, seed, team, electric, effects, features, info);
}
void AssignProcedural( const IString& proc,
bool female, U32 seed, int team, bool electric, int effectFlags, int features,
ProcRenderInfo* info )
{
if ( proc == ISC::team) {
TeamGen::Assign( team, info );
}
else if ( proc == ISC::suit) {
HumanGen gen( female, seed, team, electric );
gen.AssignSuit( info );
}
else if (proc == ISC::ring) {
WeaponGen gen( seed, team, effectFlags, features );
gen.AssignRing( info );
}
else if (proc == ISC::gun )
{
WeaponGen gen( seed, team, effectFlags, features );
gen.AssignGun( info );
}
else if ( proc == ISC::shield) {
WeaponGen gen( seed, team, effectFlags, features );
gen.AssignShield( info );
}
else {
GLASSERT( 0 );
}
}