Revision f10a88a8
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.FactoryCubit; |
25 |
import org.distorted.helpers.ObjectShape; |
|
25 | 26 |
import org.distorted.helpers.ObjectSticker; |
26 | 27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
27 | 28 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
177 | 178 |
return CENTERS; |
178 | 179 |
} |
179 | 180 |
|
181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
182 |
|
|
183 |
private Static4D getQuat(int cubit, int numLayers) |
|
184 |
{ |
|
185 |
return QUATS[cubit]; |
|
186 |
} |
|
187 |
|
|
188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
189 |
|
|
190 |
private int getNumCubitVariants(int numLayers) |
|
191 |
{ |
|
192 |
return 1; |
|
193 |
} |
|
194 |
|
|
195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
196 |
|
|
197 |
int getCubitVariant(int cubit, int numLayers) |
|
198 |
{ |
|
199 |
return 0; |
|
200 |
} |
|
201 |
|
|
202 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
203 |
|
|
204 |
ObjectShape getObjectShape(int cubit, int numLayers) |
|
205 |
{ |
|
206 |
float[][] bands= new float[][] { {0.035f,30,0.16f,0.8f,6,2,2}, {0.010f,30,0.16f,0.2f,6,2,2} }; |
|
207 |
int[] bandIndices = new int[] { 0,0,1,1 }; |
|
208 |
float[][] corners = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} }; |
|
209 |
int[] cornerIndices = new int[] { 0,0,1,1 }; |
|
210 |
float[][] centers = new float[][] { {0.0f, -0.75f, -0.75f} }; |
|
211 |
int[] centerIndices = new int[] { 0,0,0,0 }; |
|
212 |
|
|
213 |
return new ObjectShape(VERTICES,VERT_INDEXES,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
214 |
} |
|
215 |
|
|
180 | 216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
181 | 217 |
|
182 | 218 |
MeshBase createCubitMesh(int cubit, int numLayers) |
183 | 219 |
{ |
220 |
int variant = getCubitVariant(cubit,numLayers); |
|
221 |
|
|
184 | 222 |
if( mMeshes==null ) |
185 | 223 |
{ |
186 | 224 |
FactoryCubit factory = FactoryCubit.getInstance(); |
187 | 225 |
factory.clear(); |
188 |
mMeshes = new MeshBase[1];
|
|
226 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
|
|
189 | 227 |
} |
190 | 228 |
|
191 |
if( mMeshes[0]==null )
|
|
229 |
if( mMeshes[variant]==null )
|
|
192 | 230 |
{ |
193 |
float[][] bands= new float[][] |
|
194 |
{ |
|
195 |
{0.035f,30,0.16f,0.8f,6,2,2}, |
|
196 |
{0.010f,30,0.16f,0.2f,6,2,2} |
|
197 |
}; |
|
198 |
int[] bandIndexes = new int[] { 0,0,1,1 }; |
|
199 |
float[][] corners = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} }; |
|
200 |
int[] cornerIndexes = new int[] { 0,0,1,1 }; |
|
201 |
float[][] centers = new float[][] { {0.0f, -0.75f, -0.75f} }; |
|
202 |
int[] centerIndexes = new int[] { 0,0,0,0 }; |
|
203 |
|
|
231 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
204 | 232 |
FactoryCubit factory = FactoryCubit.getInstance(); |
205 |
|
|
206 |
factory.createNewFaceTransform(VERTICES,VERT_INDEXES); |
|
207 |
mMeshes[0] = factory.createRoundedSolid(VERTICES, VERT_INDEXES, |
|
208 |
bands, bandIndexes, |
|
209 |
corners, cornerIndexes, |
|
210 |
centers, centerIndexes, |
|
211 |
getNumCubitFaces(), null ); |
|
233 |
factory.createNewFaceTransform(shape); |
|
234 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
212 | 235 |
} |
213 | 236 |
|
214 |
MeshBase mesh = mMeshes[0].copy(true);
|
|
215 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[cubit], new Static3D(0,0,0) );
|
|
237 |
MeshBase mesh = mMeshes[variant].copy(true);
|
|
238 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
|
|
216 | 239 |
mesh.apply(quat,0xffffffff,0); |
217 | 240 |
|
218 | 241 |
return mesh; |
Also available in: Unified diff
Move 1) bandaged 3x3 2) normals cubes 3) octahedrons 4) both dinos to the new cubit creation scheme.