1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.objectlib.bandaged;
|
11
|
|
12
|
import org.distorted.library.type.Static3D;
|
13
|
import org.distorted.library.type.Static4D;
|
14
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
15
|
|
16
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
17
|
|
18
|
public class FactoryBandagedCuboid extends FactoryBandaged
|
19
|
{
|
20
|
private static FactoryBandagedCuboid mThis;
|
21
|
private float[][] mVertices;
|
22
|
private int[][] mIndices;
|
23
|
|
24
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25
|
|
26
|
private FactoryBandagedCuboid()
|
27
|
{
|
28
|
|
29
|
}
|
30
|
|
31
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
|
33
|
public static FactoryBandagedCuboid getInstance()
|
34
|
{
|
35
|
if( mThis==null ) mThis = new FactoryBandagedCuboid();
|
36
|
return mThis;
|
37
|
}
|
38
|
|
39
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40
|
|
41
|
public float[][] getVertices(int[] numLayers, int variant)
|
42
|
{
|
43
|
if( mVertices==null )
|
44
|
mVertices = new float[][]
|
45
|
{
|
46
|
{ 0.5f, 0.5f, 0.5f },
|
47
|
{ 0.5f, 0.5f,-0.5f },
|
48
|
{ 0.5f,-0.5f, 0.5f },
|
49
|
{ 0.5f,-0.5f,-0.5f },
|
50
|
{-0.5f, 0.5f, 0.5f },
|
51
|
{-0.5f, 0.5f,-0.5f },
|
52
|
{-0.5f,-0.5f, 0.5f },
|
53
|
{-0.5f,-0.5f,-0.5f },
|
54
|
};
|
55
|
|
56
|
return mVertices;
|
57
|
}
|
58
|
|
59
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60
|
|
61
|
public int[][] getIndices(int[] numLayers, int variant)
|
62
|
{
|
63
|
if( mIndices==null )
|
64
|
mIndices = new int[][]
|
65
|
{
|
66
|
{2,3,1,0},
|
67
|
{7,6,4,5},
|
68
|
{4,0,1,5},
|
69
|
{7,3,2,6},
|
70
|
{6,2,0,4},
|
71
|
{3,7,5,1}
|
72
|
};
|
73
|
|
74
|
return mIndices;
|
75
|
}
|
76
|
|
77
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
78
|
|
79
|
public float[][][] getPositions(int[] numLayers)
|
80
|
{
|
81
|
int sx = numLayers[0];
|
82
|
int sy = numLayers[1];
|
83
|
int sz = numLayers[2];
|
84
|
int numCubits = ( sx<=1 || sy<=1 || sz<=1 ) ? sx*sy*sz : sx*sy*sz-(sx-2)*(sy-2)*(sz-2);
|
85
|
|
86
|
float[][][] pos = new float[1][numCubits][];
|
87
|
int c=0;
|
88
|
|
89
|
float begX = 0.5f*(1-sx);
|
90
|
float begY = 0.5f*(1-sy);
|
91
|
float begZ = 0.5f*(1-sz);
|
92
|
|
93
|
for(int x=0; x<sx; x++)
|
94
|
for(int y=0; y<sy; y++)
|
95
|
for(int z=0; z<sz; z++)
|
96
|
if( x==0 || x==sx-1 || y==0 || y==sy-1 || z==0 || z==sz-1 )
|
97
|
{
|
98
|
pos[0][c++] = new float[] { begX+x,begY+y,begZ+z };
|
99
|
}
|
100
|
|
101
|
return pos;
|
102
|
}
|
103
|
|
104
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105
|
|
106
|
public int getNumVariants(int[] numLayers)
|
107
|
{
|
108
|
return 1;
|
109
|
}
|
110
|
|
111
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112
|
|
113
|
public int getElementVariant(int[] numLayers, float x, float y, float z)
|
114
|
{
|
115
|
return 0;
|
116
|
}
|
117
|
|
118
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
119
|
|
120
|
public Static4D getElementQuat(int[] numLayers, int cubitIndex)
|
121
|
{
|
122
|
return QUAT;
|
123
|
}
|
124
|
|
125
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
126
|
|
127
|
public Static3D[] getNormals()
|
128
|
{
|
129
|
return TouchControlHexahedron.FACE_AXIS;
|
130
|
}
|
131
|
|
132
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133
|
|
134
|
public float[][] getDiameterAxis()
|
135
|
{
|
136
|
return new float[][] { {1,0,0},{0,1,0},{0,0,1} };
|
137
|
}
|
138
|
|
139
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
140
|
|
141
|
public float sizeCorrection(int[] numLayers)
|
142
|
{
|
143
|
return 1.0f;
|
144
|
}
|
145
|
|
146
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
147
|
|
148
|
public int diameterMap(float diameter)
|
149
|
{
|
150
|
return diameter>7 ? 7 : (int)diameter;
|
151
|
}
|
152
|
|
153
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
154
|
|
155
|
public float[] getDist3D(int[] numLayers)
|
156
|
{
|
157
|
float dx = numLayers[0]/2.0f;
|
158
|
float dy = numLayers[1]/2.0f;
|
159
|
float dz = numLayers[2]/2.0f;
|
160
|
|
161
|
return new float[] {dx,dx,dy,dy,dz,dz};
|
162
|
}
|
163
|
|
164
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165
|
|
166
|
public float[][] getBands(boolean iconMode, int[] numLayers)
|
167
|
{
|
168
|
int sum = numLayers[0]+numLayers[1]+numLayers[2];
|
169
|
|
170
|
float height= iconMode ? 0.001f : 0.05f;
|
171
|
int[] angle = {1,54,43,35,30,26,23,21};
|
172
|
float R = 0.3f;
|
173
|
float S = 0.5f;
|
174
|
int extraI = sum>6 ? 0 : 2;
|
175
|
int extraV = sum>6 ? 0 : 2;
|
176
|
int numVertA= sum>=19 ? 3 : (sum>=16 ? 4:5);
|
177
|
int numVertI= sum>=13 ? 2 : 3;
|
178
|
|
179
|
return new float[][] { {0.001f ,angle[0],R,S,numVertI,extraV,extraI},
|
180
|
{height ,angle[1],R,S,numVertA,extraV,extraI},
|
181
|
{height/2,angle[2],R,S,numVertA,extraV,extraI},
|
182
|
{height/3,angle[3],R,S,numVertA,extraV,extraI},
|
183
|
{height/4,angle[4],R,S,numVertA,extraV,extraI},
|
184
|
{height/5,angle[5],R,S,numVertA,extraV,extraI},
|
185
|
{height/6,angle[6],R,S,numVertA,extraV,extraI},
|
186
|
{height/7,angle[7],R,S,numVertA,extraV,extraI},
|
187
|
};
|
188
|
}
|
189
|
}
|