Revision fbca0033
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/objects/RubikCube.java | ||
---|---|---|
94 | 94 |
new Static4D( -0.5f, 0.5f, 0.5f, 0.5f) |
95 | 95 |
}; |
96 | 96 |
|
97 |
private static MeshBase mMeshBig = null; |
|
98 |
private static MeshBase mMeshSma = null; |
|
97 |
private static MeshBase[] mMeshes; |
|
99 | 98 |
|
100 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
101 | 100 |
|
... | ... | |
164 | 163 |
|
165 | 164 |
MeshBase createCubitMesh(int cubit) |
166 | 165 |
{ |
167 |
return createCubitMesh(getSize()<=3); |
|
166 |
int size = getSize(); |
|
167 |
int ordinal= RubikObjectList.CUBE.ordinal(); |
|
168 |
int index = RubikObjectList.getSizeIndex(ordinal,size); |
|
169 |
float[] loc; |
|
170 |
|
|
171 |
switch(size) |
|
172 |
{ |
|
173 |
case 5 : loc = new float[] { -0.5f, 0.05f, 0.1f, 0.35f, 0.35f, 0.1f, 0.05f }; |
|
174 |
break; |
|
175 |
case 2 : loc = new float[] { -0.5f, 0.03f, 0.05f, 0.07f, 0.20f, 0.30f, 0.20f, 0.07f, 0.05f, 0.03f }; |
|
176 |
break; |
|
177 |
default: loc = new float[] { -0.5f, 0.04f, 0.06f, 0.25f, 0.30f, 0.25f, 0.06f, 0.04f }; |
|
178 |
} |
|
179 |
|
|
180 |
return createCubitMesh(index,loc); |
|
168 | 181 |
} |
169 | 182 |
|
170 | 183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
171 | 184 |
|
172 |
MeshBase createCubitMesh(boolean big)
|
|
185 |
MeshBase createCubitMesh(int index, float[] loc)
|
|
173 | 186 |
{ |
174 |
MeshBase mesh = big ? mMeshBig : mMeshSma; |
|
175 |
int size = big ? 14 : 9; |
|
187 |
if( mMeshes==null ) |
|
188 |
{ |
|
189 |
mMeshes = new MeshBase[RubikObjectList.CUBE.getNumVariants()]; |
|
190 |
} |
|
176 | 191 |
|
177 |
if( mesh==null )
|
|
192 |
if( mMeshes[index]==null )
|
|
178 | 193 |
{ |
179 | 194 |
final int MESHES=6; |
180 | 195 |
int association = 1; |
181 | 196 |
MeshBase[] meshes = new MeshRectangles[MESHES]; |
182 |
meshes[0] = new MeshRectangles(size,size);
|
|
197 |
meshes[0] = new MeshRectangles(loc,loc);
|
|
183 | 198 |
meshes[0].setEffectAssociation(0,association,0); |
184 | 199 |
|
185 | 200 |
for(int i=1; i<MESHES; i++) |
... | ... | |
189 | 204 |
meshes[i].setEffectAssociation(0,association,0); |
190 | 205 |
} |
191 | 206 |
|
192 |
mesh = new MeshJoined(meshes);
|
|
207 |
mMeshes[index] = new MeshJoined(meshes);
|
|
193 | 208 |
|
194 | 209 |
Static3D axisY = new Static3D(0,1,0); |
195 | 210 |
Static3D axisX = new Static3D(1,0,0); |
... | ... | |
247 | 262 |
|
248 | 263 |
VertexEffectSink effect14= new VertexEffectSink( new Static1D(1.5f), center, new Static4D(0,0,0,0.72f) ); |
249 | 264 |
|
250 |
mesh.apply(effect0);
|
|
251 |
mesh.apply(effect1);
|
|
252 |
mesh.apply(effect2);
|
|
253 |
mesh.apply(effect3);
|
|
254 |
mesh.apply(effect4);
|
|
255 |
mesh.apply(effect5);
|
|
256 |
mesh.apply(effect6);
|
|
257 |
mesh.apply(effect7);
|
|
258 |
mesh.apply(effect8);
|
|
259 |
mesh.apply(effect9);
|
|
260 |
mesh.apply(effect10);
|
|
261 |
mesh.apply(effect11);
|
|
262 |
mesh.apply(effect12);
|
|
263 |
mesh.apply(effect13);
|
|
264 |
mesh.apply(effect14);
|
|
265 |
|
|
266 |
mesh.mergeEffComponents();
|
|
265 |
mMeshes[index].apply(effect0);
|
|
266 |
mMeshes[index].apply(effect1);
|
|
267 |
mMeshes[index].apply(effect2);
|
|
268 |
mMeshes[index].apply(effect3);
|
|
269 |
mMeshes[index].apply(effect4);
|
|
270 |
mMeshes[index].apply(effect5);
|
|
271 |
mMeshes[index].apply(effect6);
|
|
272 |
mMeshes[index].apply(effect7);
|
|
273 |
mMeshes[index].apply(effect8);
|
|
274 |
mMeshes[index].apply(effect9);
|
|
275 |
mMeshes[index].apply(effect10);
|
|
276 |
mMeshes[index].apply(effect11);
|
|
277 |
mMeshes[index].apply(effect12);
|
|
278 |
mMeshes[index].apply(effect13);
|
|
279 |
mMeshes[index].apply(effect14);
|
|
280 |
|
|
281 |
mMeshes[index].mergeEffComponents();
|
|
267 | 282 |
} |
268 | 283 |
|
269 |
return mesh.copy(true);
|
|
284 |
return mMeshes[index].copy(true);
|
|
270 | 285 |
} |
271 | 286 |
|
272 | 287 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Re-introduce possibility to dynamically create object mesh: part 2.