Revision 55fa2499
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/objects/RubikCube.java | ||
|---|---|---|
| 93 | 93 |
new Static4D( -0.5f, 0.5f, 0.5f, 0.5f) |
| 94 | 94 |
}; |
| 95 | 95 |
|
| 96 |
private static MeshBase mMesh = null; |
|
| 96 |
private static MeshBase mMeshBig = null; |
|
| 97 |
private static MeshBase mMeshSma = null; |
|
| 97 | 98 |
|
| 98 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 99 | 100 |
|
| ... | ... | |
| 161 | 162 |
|
| 162 | 163 |
MeshBase createCubitMesh(int cubit) |
| 163 | 164 |
{
|
| 164 |
if( mMesh==null ) |
|
| 165 |
return createCubitMesh(getSize()<=3); |
|
| 166 |
} |
|
| 167 |
|
|
| 168 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 169 |
|
|
| 170 |
MeshBase createCubitMesh(boolean big) |
|
| 171 |
{
|
|
| 172 |
MeshBase mesh = big ? mMeshBig : mMeshSma; |
|
| 173 |
int size = big ? 14 : 9; |
|
| 174 |
|
|
| 175 |
if( mesh==null ) |
|
| 165 | 176 |
{
|
| 166 | 177 |
final int MESHES=6; |
| 167 | 178 |
int association = 1; |
| 168 | 179 |
MeshBase[] meshes = new MeshRectangles[MESHES]; |
| 169 |
meshes[0] = new MeshRectangles(14,14);
|
|
| 180 |
meshes[0] = new MeshRectangles(size,size);
|
|
| 170 | 181 |
meshes[0].setEffectAssociation(0,association,0); |
| 171 | 182 |
|
| 172 | 183 |
for(int i=1; i<MESHES; i++) |
| ... | ... | |
| 176 | 187 |
meshes[i].setEffectAssociation(0,association,0); |
| 177 | 188 |
} |
| 178 | 189 |
|
| 179 |
mMesh = new MeshJoined(meshes);
|
|
| 190 |
mesh = new MeshJoined(meshes); |
|
| 180 | 191 |
|
| 181 | 192 |
Static3D axisY = new Static3D(0,1,0); |
| 182 | 193 |
Static3D axisX = new Static3D(1,0,0); |
| ... | ... | |
| 234 | 245 |
|
| 235 | 246 |
VertexEffectSink effect14= new VertexEffectSink( new Static1D(1.5f), center, new Static4D(0,0,0,0.72f) ); |
| 236 | 247 |
|
| 237 |
mMesh.apply(effect0);
|
|
| 238 |
mMesh.apply(effect1);
|
|
| 239 |
mMesh.apply(effect2);
|
|
| 240 |
mMesh.apply(effect3);
|
|
| 241 |
mMesh.apply(effect4);
|
|
| 242 |
mMesh.apply(effect5);
|
|
| 243 |
mMesh.apply(effect6);
|
|
| 244 |
mMesh.apply(effect7);
|
|
| 245 |
mMesh.apply(effect8);
|
|
| 246 |
mMesh.apply(effect9);
|
|
| 247 |
mMesh.apply(effect10);
|
|
| 248 |
mMesh.apply(effect11);
|
|
| 249 |
mMesh.apply(effect12);
|
|
| 250 |
mMesh.apply(effect13);
|
|
| 251 |
mMesh.apply(effect14);
|
|
| 252 |
|
|
| 253 |
mMesh.mergeEffComponents();
|
|
| 248 |
mesh.apply(effect0); |
|
| 249 |
mesh.apply(effect1); |
|
| 250 |
mesh.apply(effect2); |
|
| 251 |
mesh.apply(effect3); |
|
| 252 |
mesh.apply(effect4); |
|
| 253 |
mesh.apply(effect5); |
|
| 254 |
mesh.apply(effect6); |
|
| 255 |
mesh.apply(effect7); |
|
| 256 |
mesh.apply(effect8); |
|
| 257 |
mesh.apply(effect9); |
|
| 258 |
mesh.apply(effect10); |
|
| 259 |
mesh.apply(effect11); |
|
| 260 |
mesh.apply(effect12); |
|
| 261 |
mesh.apply(effect13); |
|
| 262 |
mesh.apply(effect14); |
|
| 263 |
|
|
| 264 |
mesh.mergeEffComponents(); |
|
| 254 | 265 |
} |
| 255 | 266 |
|
| 256 |
return mMesh.copy(true);
|
|
| 267 |
return mesh.copy(true); |
|
| 257 | 268 |
} |
| 258 | 269 |
|
| 259 | 270 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Speedup for rendering: cubes 2,3 contain better quality cubit faces (more vertices) than cubes 4,5.