Revision e782e026
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/MovementCornerTwisting.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.objects; |
|
21 |
|
|
22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
class MovementCornerTwisting extends Movement6 |
|
25 |
{ |
|
26 |
MovementCornerTwisting() |
|
27 |
{ |
|
28 |
super(TwistySkewb.ROT_AXIS); |
|
29 |
} |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
|
34 |
{ |
|
35 |
return offset<0 ? 0 : numLayers-1; |
|
36 |
} |
|
37 |
|
|
38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
// _____________ |
|
40 |
// | \ 0 / | |
|
41 |
// | \ / | |
|
42 |
// | 3 | | 1 | |
|
43 |
// | / \ | |
|
44 |
// | / 2 \ | |
|
45 |
// ------------- |
|
46 |
|
|
47 |
private int getQuarter(float[] touchPoint) |
|
48 |
{ |
|
49 |
boolean p0 = touchPoint[1] >= touchPoint[0]; |
|
50 |
boolean p1 = touchPoint[1] >=-touchPoint[0]; |
|
51 |
|
|
52 |
if( p0 ) return p1 ? 0:3; |
|
53 |
else return p1 ? 1:2; |
|
54 |
} |
|
55 |
|
|
56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
57 |
|
|
58 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
|
59 |
{ |
|
60 |
enabled[0] = 2; |
|
61 |
|
|
62 |
int quarter = getQuarter(touchPoint); |
|
63 |
|
|
64 |
switch(face) |
|
65 |
{ |
|
66 |
case 0: switch(quarter) |
|
67 |
{ |
|
68 |
case 0: enabled[1]=0; enabled[2]=1; break; |
|
69 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
70 |
case 2: enabled[1]=2; enabled[2]=3; break; |
|
71 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
72 |
} |
|
73 |
break; |
|
74 |
case 1: switch(quarter) |
|
75 |
{ |
|
76 |
case 0: enabled[1]=2; enabled[2]=3; break; |
|
77 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
78 |
case 2: enabled[1]=0; enabled[2]=1; break; |
|
79 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
80 |
} |
|
81 |
break; |
|
82 |
case 2: switch(quarter) |
|
83 |
{ |
|
84 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
85 |
case 1: enabled[1]=0; enabled[2]=1; break; |
|
86 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
87 |
case 3: enabled[1]=2; enabled[2]=3; break; |
|
88 |
} |
|
89 |
break; |
|
90 |
case 3: switch(quarter) |
|
91 |
{ |
|
92 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
93 |
case 1: enabled[1]=2; enabled[2]=3; break; |
|
94 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
95 |
case 3: enabled[1]=0; enabled[2]=1; break; |
|
96 |
} |
|
97 |
break; |
|
98 |
case 4: switch(quarter) |
|
99 |
{ |
|
100 |
case 0: enabled[1]=0; enabled[2]=3; break; |
|
101 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
102 |
case 2: enabled[1]=1; enabled[2]=2; break; |
|
103 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
104 |
} |
|
105 |
break; |
|
106 |
case 5: switch(quarter) |
|
107 |
{ |
|
108 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
109 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
110 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
111 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
112 |
} |
|
113 |
break; |
|
114 |
} |
|
115 |
} |
|
116 |
} |
src/main/java/org/distorted/objects/MovementDino.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.objects; |
|
21 |
|
|
22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
class MovementDino extends Movement6 |
|
25 |
{ |
|
26 |
|
|
27 |
MovementDino() |
|
28 |
{ |
|
29 |
super(TwistyDino.ROT_AXIS); |
|
30 |
} |
|
31 |
|
|
32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
33 |
|
|
34 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
|
35 |
{ |
|
36 |
return offset<0 ? 0:2; |
|
37 |
} |
|
38 |
|
|
39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
40 |
// _____________ |
|
41 |
// | \ 0 / | |
|
42 |
// | \ / | |
|
43 |
// | 3 | | 1 | |
|
44 |
// | / \ | |
|
45 |
// | / 2 \ | |
|
46 |
// ------------- |
|
47 |
|
|
48 |
private int getQuarter(float[] touchPoint) |
|
49 |
{ |
|
50 |
boolean p0 = touchPoint[1] >= touchPoint[0]; |
|
51 |
boolean p1 = touchPoint[1] >=-touchPoint[0]; |
|
52 |
|
|
53 |
if( p0 ) return p1 ? 0:3; |
|
54 |
else return p1 ? 1:2; |
|
55 |
} |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
|
|
59 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
|
60 |
{ |
|
61 |
enabled[0] = 2; |
|
62 |
|
|
63 |
int quarter = getQuarter(touchPoint); |
|
64 |
|
|
65 |
switch(face) |
|
66 |
{ |
|
67 |
case 0: switch(quarter) |
|
68 |
{ |
|
69 |
case 0: enabled[1]=0; enabled[2]=1; break; |
|
70 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
71 |
case 2: enabled[1]=2; enabled[2]=3; break; |
|
72 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
73 |
} |
|
74 |
break; |
|
75 |
case 1: switch(quarter) |
|
76 |
{ |
|
77 |
case 0: enabled[1]=2; enabled[2]=3; break; |
|
78 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
79 |
case 2: enabled[1]=0; enabled[2]=1; break; |
|
80 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
81 |
} |
|
82 |
break; |
|
83 |
case 2: switch(quarter) |
|
84 |
{ |
|
85 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
86 |
case 1: enabled[1]=0; enabled[2]=1; break; |
|
87 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
88 |
case 3: enabled[1]=2; enabled[2]=3; break; |
|
89 |
} |
|
90 |
break; |
|
91 |
case 3: switch(quarter) |
|
92 |
{ |
|
93 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
94 |
case 1: enabled[1]=2; enabled[2]=3; break; |
|
95 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
96 |
case 3: enabled[1]=0; enabled[2]=1; break; |
|
97 |
} |
|
98 |
break; |
|
99 |
case 4: switch(quarter) |
|
100 |
{ |
|
101 |
case 0: enabled[1]=0; enabled[2]=3; break; |
|
102 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
103 |
case 2: enabled[1]=1; enabled[2]=2; break; |
|
104 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
105 |
} |
|
106 |
break; |
|
107 |
case 5: switch(quarter) |
|
108 |
{ |
|
109 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
110 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
111 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
112 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
113 |
} |
|
114 |
break; |
|
115 |
} |
|
116 |
} |
|
117 |
} |
src/main/java/org/distorted/objects/MovementRedi.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.objects; |
|
21 |
|
|
22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
class MovementRedi extends Movement6 |
|
25 |
{ |
|
26 |
MovementRedi() |
|
27 |
{ |
|
28 |
super(TwistyRedi.ROT_AXIS); |
|
29 |
} |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
|
34 |
{ |
|
35 |
return offset<0 ? 0:2; |
|
36 |
} |
|
37 |
|
|
38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
// _____________ |
|
40 |
// | \ 0 / | |
|
41 |
// | \ / | |
|
42 |
// | 3 | | 1 | |
|
43 |
// | / \ | |
|
44 |
// | / 2 \ | |
|
45 |
// ------------- |
|
46 |
|
|
47 |
private int getQuarter(float[] touchPoint) |
|
48 |
{ |
|
49 |
boolean p0 = touchPoint[1] >= touchPoint[0]; |
|
50 |
boolean p1 = touchPoint[1] >=-touchPoint[0]; |
|
51 |
|
|
52 |
if( p0 ) return p1 ? 0:3; |
|
53 |
else return p1 ? 1:2; |
|
54 |
} |
|
55 |
|
|
56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
57 |
|
|
58 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
|
59 |
{ |
|
60 |
enabled[0] = 2; |
|
61 |
|
|
62 |
int quarter = getQuarter(touchPoint); |
|
63 |
|
|
64 |
switch(face) |
|
65 |
{ |
|
66 |
case 0: switch(quarter) |
|
67 |
{ |
|
68 |
case 0: enabled[1]=0; enabled[2]=1; break; |
|
69 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
70 |
case 2: enabled[1]=2; enabled[2]=3; break; |
|
71 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
72 |
} |
|
73 |
break; |
|
74 |
case 1: switch(quarter) |
|
75 |
{ |
|
76 |
case 0: enabled[1]=2; enabled[2]=3; break; |
|
77 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
78 |
case 2: enabled[1]=0; enabled[2]=1; break; |
|
79 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
80 |
} |
|
81 |
break; |
|
82 |
case 2: switch(quarter) |
|
83 |
{ |
|
84 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
85 |
case 1: enabled[1]=0; enabled[2]=1; break; |
|
86 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
87 |
case 3: enabled[1]=2; enabled[2]=3; break; |
|
88 |
} |
|
89 |
break; |
|
90 |
case 3: switch(quarter) |
|
91 |
{ |
|
92 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
93 |
case 1: enabled[1]=2; enabled[2]=3; break; |
|
94 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
95 |
case 3: enabled[1]=0; enabled[2]=1; break; |
|
96 |
} |
|
97 |
break; |
|
98 |
case 4: switch(quarter) |
|
99 |
{ |
|
100 |
case 0: enabled[1]=0; enabled[2]=3; break; |
|
101 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
102 |
case 2: enabled[1]=1; enabled[2]=2; break; |
|
103 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
104 |
} |
|
105 |
break; |
|
106 |
case 5: switch(quarter) |
|
107 |
{ |
|
108 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
109 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
110 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
111 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
112 |
} |
|
113 |
break; |
|
114 |
} |
|
115 |
} |
|
116 |
} |
src/main/java/org/distorted/objects/MovementRex.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.objects; |
|
21 |
|
|
22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
class MovementRex extends Movement6 |
|
25 |
{ |
|
26 |
MovementRex() |
|
27 |
{ |
|
28 |
super(TwistyRex.ROT_AXIS); |
|
29 |
} |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
|
34 |
{ |
|
35 |
return offset<0 ? 0:2; |
|
36 |
} |
|
37 |
|
|
38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
// _____________ |
|
40 |
// | \ 0 / | |
|
41 |
// | \ / | |
|
42 |
// | 3 | | 1 | |
|
43 |
// | / \ | |
|
44 |
// | / 2 \ | |
|
45 |
// ------------- |
|
46 |
|
|
47 |
private int getQuarter(float[] touchPoint) |
|
48 |
{ |
|
49 |
boolean p0 = touchPoint[1] >= touchPoint[0]; |
|
50 |
boolean p1 = touchPoint[1] >=-touchPoint[0]; |
|
51 |
|
|
52 |
if( p0 ) return p1 ? 0:3; |
|
53 |
else return p1 ? 1:2; |
|
54 |
} |
|
55 |
|
|
56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
57 |
|
|
58 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
|
59 |
{ |
|
60 |
enabled[0] = 2; |
|
61 |
|
|
62 |
int quarter = getQuarter(touchPoint); |
|
63 |
|
|
64 |
switch(face) |
|
65 |
{ |
|
66 |
case 0: switch(quarter) |
|
67 |
{ |
|
68 |
case 0: enabled[1]=0; enabled[2]=1; break; |
|
69 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
70 |
case 2: enabled[1]=2; enabled[2]=3; break; |
|
71 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
72 |
} |
|
73 |
break; |
|
74 |
case 1: switch(quarter) |
|
75 |
{ |
|
76 |
case 0: enabled[1]=2; enabled[2]=3; break; |
|
77 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
78 |
case 2: enabled[1]=0; enabled[2]=1; break; |
|
79 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
80 |
} |
|
81 |
break; |
|
82 |
case 2: switch(quarter) |
|
83 |
{ |
|
84 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
85 |
case 1: enabled[1]=0; enabled[2]=1; break; |
|
86 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
87 |
case 3: enabled[1]=2; enabled[2]=3; break; |
|
88 |
} |
|
89 |
break; |
|
90 |
case 3: switch(quarter) |
|
91 |
{ |
|
92 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
93 |
case 1: enabled[1]=2; enabled[2]=3; break; |
|
94 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
95 |
case 3: enabled[1]=0; enabled[2]=1; break; |
|
96 |
} |
|
97 |
break; |
|
98 |
case 4: switch(quarter) |
|
99 |
{ |
|
100 |
case 0: enabled[1]=0; enabled[2]=3; break; |
|
101 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
102 |
case 2: enabled[1]=1; enabled[2]=2; break; |
|
103 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
104 |
} |
|
105 |
break; |
|
106 |
case 5: switch(quarter) |
|
107 |
{ |
|
108 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
109 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
110 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
111 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
112 |
} |
|
113 |
break; |
|
114 |
} |
|
115 |
} |
|
116 |
} |
src/main/java/org/distorted/objects/MovementSkewb.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.objects; |
|
21 |
|
|
22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
class MovementSkewb extends Movement6 |
|
25 |
{ |
|
26 |
MovementSkewb() |
|
27 |
{ |
|
28 |
super(TwistySkewb.ROT_AXIS); |
|
29 |
} |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
|
34 |
{ |
|
35 |
return offset<0 ? 0:numLayers-1; |
|
36 |
} |
|
37 |
|
|
38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
// _____________ |
|
40 |
// | \ 0 / | |
|
41 |
// | \ / | |
|
42 |
// | 3 | | 1 | |
|
43 |
// | / \ | |
|
44 |
// | / 2 \ | |
|
45 |
// ------------- |
|
46 |
|
|
47 |
private int getQuarter(float[] touchPoint) |
|
48 |
{ |
|
49 |
boolean p0 = touchPoint[1] >= touchPoint[0]; |
|
50 |
boolean p1 = touchPoint[1] >=-touchPoint[0]; |
|
51 |
|
|
52 |
if( p0 ) return p1 ? 0:3; |
|
53 |
else return p1 ? 1:2; |
|
54 |
} |
|
55 |
|
|
56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
57 |
|
|
58 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
|
59 |
{ |
|
60 |
enabled[0] = 2; |
|
61 |
|
|
62 |
int quarter = getQuarter(touchPoint); |
|
63 |
|
|
64 |
switch(face) |
|
65 |
{ |
|
66 |
case 0: switch(quarter) |
|
67 |
{ |
|
68 |
case 0: enabled[1]=0; enabled[2]=1; break; |
|
69 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
70 |
case 2: enabled[1]=2; enabled[2]=3; break; |
|
71 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
72 |
} |
|
73 |
break; |
|
74 |
case 1: switch(quarter) |
|
75 |
{ |
|
76 |
case 0: enabled[1]=2; enabled[2]=3; break; |
|
77 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
78 |
case 2: enabled[1]=0; enabled[2]=1; break; |
|
79 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
80 |
} |
|
81 |
break; |
|
82 |
case 2: switch(quarter) |
|
83 |
{ |
|
84 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
85 |
case 1: enabled[1]=0; enabled[2]=1; break; |
|
86 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
87 |
case 3: enabled[1]=2; enabled[2]=3; break; |
|
88 |
} |
|
89 |
break; |
|
90 |
case 3: switch(quarter) |
|
91 |
{ |
|
92 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
93 |
case 1: enabled[1]=2; enabled[2]=3; break; |
|
94 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
95 |
case 3: enabled[1]=0; enabled[2]=1; break; |
|
96 |
} |
|
97 |
break; |
|
98 |
case 4: switch(quarter) |
|
99 |
{ |
|
100 |
case 0: enabled[1]=0; enabled[2]=3; break; |
|
101 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
102 |
case 2: enabled[1]=1; enabled[2]=2; break; |
|
103 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
104 |
} |
|
105 |
break; |
|
106 |
case 5: switch(quarter) |
|
107 |
{ |
|
108 |
case 0: enabled[1]=1; enabled[2]=2; break; |
|
109 |
case 1: enabled[1]=0; enabled[2]=2; break; |
|
110 |
case 2: enabled[1]=0; enabled[2]=3; break; |
|
111 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
112 |
} |
|
113 |
break; |
|
114 |
} |
|
115 |
} |
|
116 |
} |
src/main/java/org/distorted/objects/ObjectList.java | ||
---|---|---|
120 | 120 |
{3 , 10, 10, R.raw.dino, R.drawable.ui_small_dino, R.drawable.ui_medium_dino, R.drawable.ui_big_dino, R.drawable.ui_huge_dino} , |
121 | 121 |
}, |
122 | 122 |
TwistyDino6.class, |
123 |
new MovementDino(),
|
|
123 |
new MovementCornerTwisting(),
|
|
124 | 124 |
4, |
125 | 125 |
60 |
126 | 126 |
), |
... | ... | |
130 | 130 |
{3 , 7, 7, R.raw.dino, R.drawable.ui_small_din4, R.drawable.ui_medium_din4, R.drawable.ui_big_din4, R.drawable.ui_huge_din4} , |
131 | 131 |
}, |
132 | 132 |
TwistyDino4.class, |
133 |
new MovementDino(),
|
|
133 |
new MovementCornerTwisting(),
|
|
134 | 134 |
4, |
135 | 135 |
60 |
136 | 136 |
), |
... | ... | |
140 | 140 |
{3 , 14, 16, R.raw.redi, R.drawable.ui_small_redi, R.drawable.ui_medium_redi, R.drawable.ui_big_redi, R.drawable.ui_huge_redi} , |
141 | 141 |
}, |
142 | 142 |
TwistyRedi.class, |
143 |
new MovementRedi(),
|
|
143 |
new MovementCornerTwisting(),
|
|
144 | 144 |
4, |
145 | 145 |
60 |
146 | 146 |
), |
... | ... | |
161 | 161 |
{3 , 17, 21, R.raw.skew3, R.drawable.ui_small_skewm, R.drawable.ui_medium_skewm, R.drawable.ui_big_skewm, R.drawable.ui_huge_skewm} , |
162 | 162 |
}, |
163 | 163 |
TwistySkewb.class, |
164 |
new MovementSkewb(),
|
|
164 |
new MovementCornerTwisting(),
|
|
165 | 165 |
5, |
166 | 166 |
60 |
167 | 167 |
), |
... | ... | |
181 | 181 |
{3 , 16, 19, R.raw.rex, R.drawable.ui_small_rex, R.drawable.ui_medium_rex, R.drawable.ui_big_rex, R.drawable.ui_huge_rex} , |
182 | 182 |
}, |
183 | 183 |
TwistyRex.class, |
184 |
new MovementRex(),
|
|
184 |
new MovementCornerTwisting(),
|
|
185 | 185 |
5, |
186 | 186 |
60 |
187 | 187 |
), |
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
119 | 119 |
{ |
120 | 120 |
if( mQuats==null ) initializeQuats(); |
121 | 121 |
int status = retCubitSolvedStatus(cubit,numLayers); |
122 |
return status<0 ? null : buildSolvedQuats(MovementRedi.FACE_AXIS[status],mQuats);
|
|
122 |
return status<0 ? null : buildSolvedQuats(MovementCornerTwisting.FACE_AXIS[status],mQuats);
|
|
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyRex.java | ||
---|---|---|
112 | 112 |
{ |
113 | 113 |
if( mQuats==null ) initializeQuats(); |
114 | 114 |
int status = retCubitSolvedStatus(cubit,numLayers); |
115 |
return status<0 ? null : buildSolvedQuats(MovementRex.FACE_AXIS[status],mQuats);
|
|
115 |
return status<0 ? null : buildSolvedQuats(MovementCornerTwisting.FACE_AXIS[status],mQuats);
|
|
116 | 116 |
} |
117 | 117 |
|
118 | 118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
111 | 111 |
{ |
112 | 112 |
if( mQuats==null ) initializeQuats(); |
113 | 113 |
int status = retCubitSolvedStatus(cubit,numLayers); |
114 |
return status<0 ? null : buildSolvedQuats(MovementSkewb.FACE_AXIS[status],mQuats);
|
|
114 |
return status<0 ? null : buildSolvedQuats(MovementCornerTwisting.FACE_AXIS[status],mQuats);
|
|
115 | 115 |
} |
116 | 116 |
|
117 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Realize that the Movements of Rex, Redi, Dino and the Skewbs are all identical and convert those 4 classes into one MovementCornerTwisting.