-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriPiece.CC
76 lines (59 loc) · 1.53 KB
/
TriPiece.CC
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
// Greg Kaiser
//
// CS290 with Prof. Francis
// 4D Tetris
//
// TriPiece.C
// Last modified: April 22, 1996
//
// (C) 1996 Board of Trustees University of Illinois
#include "Pieces.h"
extern int *DIM;
extern float *LEN;
extern float *botcorner;
TriPiece::TriPiece() : GenPiece(3)
{
centerstat = -1;
int *dudeman = new int[4];
for (int i = 0; i < 3; i++)
dudeman[i] = (DIM[i] / 2);
dudeman[VW] = DIM[VW];
int **newpos = new int*[3];
for (int i = 0; i < 3; i++)
newpos[i] = new int[4];
for (int i = 0; i < 4; i++) // cube 0
newpos[0][i] = dudeman[i] + ((i== VW) ? 1 : 0);
for (int i = 0; i < 4; i++) // cube 1
newpos[1][i] = dudeman[i];
for (int i = 0; i < 4; i++) // cube 2
newpos[2][i] = dudeman[i] + ((i == VX) ? 1 : 0);
float **low = new float*[3];
float **high = new float*[3];
for (int i = 0; i < 3; i++) {
low[i] = new float[4];
high[i] = new float[4];
}
for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++) {
low[i][j] = botcorner[j] + newpos[i][j] * LEN[j];
high[i][j] = low[i][j] + LEN[j];
}
float *temp = new float[4];
for (int i = 0; i < 4; i++)
temp[i] = botcorner[i] + dudeman[i]*LEN[i]+(((i == VW)||(i == VX))?LEN[i]:0);
center = new FourD(temp);
delete temp;
for (int i = 0; i < 3; i++) {
cubes[i] = new Hyper(low[i], high[i], newpos[i]);
cubes[i]->SetColor(0x99ff66);
}
delete dudeman;
for (int i = 0; i < 3; i++) {
delete newpos[i];
delete low[i];
delete high[i];
}
delete newpos;
delete low;
delete high;
}