-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCornerPiece.CC
85 lines (66 loc) · 1.76 KB
/
CornerPiece.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
76
77
78
79
80
81
82
83
84
85
// Greg Kaiser
//
// CS290 with Prof. Francis
// 4D Tetris
//
// CornerPiece.C
// Last modified: April 17, 1996
//
// (C) 1996 Board of Trustees University of Illinois
#include "Pieces.h"
extern int *DIM;
extern float *LEN;
extern float *botcorner;
CornerPiece::CornerPiece() : GenPiece(4)
{
centerstat = 2;
int *dudeman = new int[4];
for (int i = 0; i < 3; i++)
dudeman[i] = (DIM[i] / 2);
dudeman[VW] = (DIM[VW] + 1);
int **newpos = new int*[4];
for (int i = 0; i < 4; 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] + ((i == VX) ? -1 : 0);
for (int i = 0; i < 4; i++) // cube 2
newpos[2][i] = dudeman[i];
for (int i = 0; i < 4; i++) // cube 3
newpos[3][i] = dudeman[i] + ((i == VY) ? -1 : 0);
/*
for (int i = 0; i < 4; i++)
for (int k = 0; k < 4; k++)
cout << "newpos["<<i<<"]["<<k<<"] = " << newpos[i][k] << endl;
*/
float **low = new float*[4];
float **high = new float*[4];
for (int i = 0; i < 4; i++) {
low[i] = new float[4];
high[i] = new float[4];
}
for (int i = 0; i < 4; 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] = (low[centerstat][i] + high[centerstat][i]) / 2;
center = new FourD(temp);
delete temp;
for (int i = 0; i < 4; i++) {
cubes[i] = new Hyper(low[i], high[i], newpos[i]);
cubes[i]->SetColor(0x00ffff);
}
delete dudeman;
for (int i = 0; i < 4; i++) {
delete newpos[i];
delete low[i];
delete high[i];
}
delete newpos;
delete low;
delete high;
}