Revision 3e605536
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistySquare2.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 |
import org.distorted.helpers.FactoryCubit; |
|
25 | 24 |
import org.distorted.helpers.ObjectShape; |
26 | 25 |
import org.distorted.helpers.ObjectSticker; |
27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
28 | 26 |
import org.distorted.library.main.DistortedEffects; |
29 | 27 |
import org.distorted.library.main.DistortedTexture; |
30 |
import org.distorted.library.mesh.MeshBase; |
|
31 | 28 |
import org.distorted.library.mesh.MeshSquare; |
32 |
import org.distorted.library.type.Static3D; |
|
33 | 29 |
import org.distorted.library.type.Static4D; |
34 | 30 |
import org.distorted.main.R; |
35 | 31 |
|
... | ... | |
199 | 195 |
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
200 | 196 |
float[][] centers = new float[][] { { -0.75f, 0.0f, 0.0f} }; |
201 | 197 |
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
202 |
|
|
203 | 198 |
return new ObjectShape(VERTICES_MIDDLE,VERT_INDEXES_MIDDLE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
204 | 199 |
} |
205 | 200 |
else if( variant==1 ) |
... | ... | |
210 | 205 |
int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 }; |
211 | 206 |
float[][] centers = new float[][] { { 0.0f, 0.0f,-0.5f} }; |
212 | 207 |
int[] centerIndices = new int[] { 0,0,-1,0,0,-1 }; |
213 |
|
|
214 | 208 |
return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
215 | 209 |
} |
216 | 210 |
else |
... | ... | |
221 | 215 |
int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 }; |
222 | 216 |
float[][] centers = new float[][] { { 0.0f, 0.0f,-0.5f} }; |
223 | 217 |
int[] centerIndices = new int[] { 0,0,-1,0,0,-1 }; |
224 |
|
|
225 | 218 |
return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
226 | 219 |
} |
227 | 220 |
} |
228 | 221 |
|
229 | 222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
230 | 223 |
|
231 |
private Static4D getQuat(int cubit, int numLayers)
|
|
224 |
Static4D getQuat(int cubit, int numLayers) |
|
232 | 225 |
{ |
233 | 226 |
return QUATS[QUAT_NUMBER[cubit]]; |
234 | 227 |
} |
235 | 228 |
|
236 | 229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
237 | 230 |
|
238 |
private int getNumCubitVariants(int numLayers)
|
|
231 |
int getNumCubitVariants(int numLayers) |
|
239 | 232 |
{ |
240 | 233 |
return 3; |
241 | 234 |
} |
... | ... | |
247 | 240 |
return cubit<2 ? 0 : (cubit<10 ? 1:2); |
248 | 241 |
} |
249 | 242 |
|
250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
251 |
|
|
252 |
MeshBase createCubitMesh(int cubit, int numLayers) |
|
253 |
{ |
|
254 |
int variant = getCubitVariant(cubit,numLayers); |
|
255 |
|
|
256 |
if( mMeshes==null ) |
|
257 |
{ |
|
258 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
259 |
factory.clear(); |
|
260 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)]; |
|
261 |
} |
|
262 |
|
|
263 |
if( mMeshes[variant]==null ) |
|
264 |
{ |
|
265 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
266 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
267 |
factory.createNewFaceTransform(shape); |
|
268 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
269 |
} |
|
270 |
|
|
271 |
MeshBase mesh = mMeshes[variant].copy(true); |
|
272 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) ); |
|
273 |
mesh.apply(quat,0xffffffff,0); |
|
274 |
|
|
275 |
return mesh; |
|
276 |
} |
|
277 |
|
|
278 | 243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
279 | 244 |
|
280 | 245 |
ObjectSticker retSticker(int face) |
Also available in: Unified diff
Finally remove cubit creation from the implementation classes and move it to the TwistyObject.