Revision 198c5bf0
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
48 | 48 |
import org.distorted.library.type.Static3D; |
49 | 49 |
import org.distorted.library.type.Static4D; |
50 | 50 |
import org.distorted.objectlib.BuildConfig; |
51 |
import org.distorted.objectlib.helpers.FactoryCubit; |
|
52 |
import org.distorted.objectlib.helpers.FactorySticker; |
|
53 |
import org.distorted.objectlib.helpers.ObjectShape; |
|
54 |
import org.distorted.objectlib.helpers.ObjectSticker; |
|
55 |
import org.distorted.objectlib.helpers.ScrambleState; |
|
51 | 56 |
|
52 | 57 |
import java.io.DataInputStream; |
53 | 58 |
import java.io.IOException; |
... | ... | |
838 | 843 |
return -1; |
839 | 844 |
} |
840 | 845 |
|
841 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
842 |
// the getFaceColors + final black in a grid (so that we do not exceed the maximum texture size) |
|
843 |
|
|
844 |
private void createTexture() |
|
845 |
{ |
|
846 |
Bitmap bitmap; |
|
847 |
|
|
848 |
Paint paint = new Paint(); |
|
849 |
bitmap = Bitmap.createBitmap( mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888); |
|
850 |
Canvas canvas = new Canvas(bitmap); |
|
851 |
|
|
852 |
paint.setAntiAlias(true); |
|
853 |
paint.setTextAlign(Paint.Align.CENTER); |
|
854 |
paint.setStyle(Paint.Style.FILL); |
|
855 |
|
|
856 |
paint.setColor(COLOR_BLACK); |
|
857 |
canvas.drawRect(0, 0, mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, paint); |
|
858 |
|
|
859 |
int face = 0; |
|
860 |
FactorySticker factory = FactorySticker.getInstance(); |
|
861 |
|
|
862 |
for(int row=0; row<mNumTexRows; row++) |
|
863 |
for(int col=0; col<mNumTexCols; col++) |
|
864 |
{ |
|
865 |
if( face>=NUM_TEXTURES ) break; |
|
866 |
ObjectSticker sticker = retSticker(face); |
|
867 |
factory.drawRoundedPolygon(canvas, paint, col*TEXTURE_HEIGHT, row*TEXTURE_HEIGHT, getColor(face%NUM_FACE_COLORS), sticker); |
|
868 |
face++; |
|
869 |
} |
|
870 |
|
|
871 |
if( !mTexture.setTexture(bitmap) ) |
|
872 |
{ |
|
873 |
int max = DistortedLibrary.getMaxTextureSize(); |
|
874 |
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); |
|
875 |
crashlytics.log("failed to set texture of size "+bitmap.getWidth()+"x"+bitmap.getHeight()+" max is "+max); |
|
876 |
} |
|
877 |
} |
|
878 |
|
|
879 | 846 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
880 | 847 |
|
881 | 848 |
private float getAngle() |
... | ... | |
937 | 904 |
return false; |
938 | 905 |
} |
939 | 906 |
|
907 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
908 |
// the getFaceColors + final black in a grid (so that we do not exceed the maximum texture size) |
|
909 |
|
|
910 |
public void createTexture() |
|
911 |
{ |
|
912 |
Bitmap bitmap; |
|
913 |
|
|
914 |
Paint paint = new Paint(); |
|
915 |
bitmap = Bitmap.createBitmap( mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888); |
|
916 |
Canvas canvas = new Canvas(bitmap); |
|
917 |
|
|
918 |
paint.setAntiAlias(true); |
|
919 |
paint.setTextAlign(Paint.Align.CENTER); |
|
920 |
paint.setStyle(Paint.Style.FILL); |
|
921 |
|
|
922 |
paint.setColor(COLOR_BLACK); |
|
923 |
canvas.drawRect(0, 0, mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, paint); |
|
924 |
|
|
925 |
int face = 0; |
|
926 |
FactorySticker factory = FactorySticker.getInstance(); |
|
927 |
|
|
928 |
for(int row=0; row<mNumTexRows; row++) |
|
929 |
for(int col=0; col<mNumTexCols; col++) |
|
930 |
{ |
|
931 |
if( face>=NUM_TEXTURES ) break; |
|
932 |
ObjectSticker sticker = retSticker(face); |
|
933 |
factory.drawRoundedPolygon(canvas, paint, col*TEXTURE_HEIGHT, row*TEXTURE_HEIGHT, getColor(face%NUM_FACE_COLORS), sticker); |
|
934 |
face++; |
|
935 |
} |
|
936 |
|
|
937 |
if( !mTexture.setTexture(bitmap) ) |
|
938 |
{ |
|
939 |
int max = DistortedLibrary.getMaxTextureSize(); |
|
940 |
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); |
|
941 |
crashlytics.log("failed to set texture of size "+bitmap.getWidth()+"x"+bitmap.getHeight()+" max is "+max); |
|
942 |
} |
|
943 |
} |
|
944 |
|
|
940 | 945 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
941 | 946 |
|
942 | 947 |
public void setObjectRatio(float sizeChange) |
Also available in: Unified diff
Move more code to objectlib.