Revision 20b60ad9
Added by Leszek Koltunski over 3 years ago
| src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java | ||
|---|---|---|
| 236 | 236 |
|
| 237 | 237 |
public void iconCreationDone(Bitmap bmp) |
| 238 | 238 |
{
|
| 239 |
mScreen.iconCreationDone(bmp); |
|
| 239 |
mScreen.iconCreationDone(this,bmp);
|
|
| 240 | 240 |
} |
| 241 | 241 |
|
| 242 | 242 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java | ||
|---|---|---|
| 35 | 35 |
import org.distorted.library.main.DistortedNode; |
| 36 | 36 |
import org.distorted.library.main.DistortedScreen; |
| 37 | 37 |
|
| 38 |
import org.distorted.library.main.InternalOutputSurface; |
|
| 38 | 39 |
import org.distorted.library.type.Static1D; |
| 39 | 40 |
import org.distorted.library.type.Static3D; |
| 40 | 41 |
import org.distorted.library.type.Static4D; |
| 41 | 42 |
import org.distorted.objectlib.json.JsonWriter; |
| 42 |
import org.distorted.objectlib.main.ObjectControl; |
|
| 43 | 43 |
import org.distorted.objectlib.main.ShapeHexahedron; |
| 44 | 44 |
import org.distorted.objectlib.main.TwistyObject; |
| 45 | 45 |
import org.distorted.objectlib.objects.TwistyBandagedGeneric; |
| ... | ... | |
| 57 | 57 |
{
|
| 58 | 58 |
public static final float BRIGHTNESS = 0.333f; |
| 59 | 59 |
private static final int DURATION = 1000; |
| 60 |
private static final int FBO_SIZE = 100; |
|
| 60 | 61 |
|
| 61 | 62 |
static final int COLOR_DEFAULT = 0xffffff55; |
| 62 | 63 |
static final int COLOR_MARKED = 0xffff0000; |
| ... | ... | |
| 231 | 232 |
} |
| 232 | 233 |
|
| 233 | 234 |
if( mSaveIcon>=0 ) mSaveIcon++; |
| 234 |
if( mSaveIcon>=2 ) { saveIcon(); mSaveIcon = -1; }
|
|
| 235 |
if( mSaveIcon>=2 ) { saveIcon(time); mSaveIcon = -1; }
|
|
| 235 | 236 |
} |
| 236 | 237 |
|
| 237 | 238 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 359 | 360 |
} |
| 360 | 361 |
|
| 361 | 362 |
TwistyBandagedGeneric.setPositions(pos); |
| 362 |
TwistyObject obj = new TwistyBandagedGeneric(); |
|
| 363 |
TwistyObject obj = new TwistyBandagedGeneric( new Static4D(0,0,0,1), 1.0f, TwistyObject.MODE_NORM);
|
|
| 363 | 364 |
BandagedCreatorActivity act = (BandagedCreatorActivity) mView.getContext(); |
| 364 | 365 |
|
| 365 | 366 |
boolean success = createObjectJson(obj,act); |
| 366 |
setupIconCreation(obj,act);
|
|
| 367 |
setupIconCreation(act); |
|
| 367 | 368 |
|
| 368 | 369 |
if( success ) |
| 369 | 370 |
{
|
| ... | ... | |
| 429 | 430 |
|
| 430 | 431 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 431 | 432 |
|
| 432 |
private void setupIconCreation(TwistyObject object, Activity act)
|
|
| 433 |
private void setupIconCreation(Activity act) |
|
| 433 | 434 |
{
|
| 434 |
/* |
|
| 435 |
// create framebuffer, attach object's node to it |
|
| 435 |
if( mFramebuffer==null ) |
|
| 436 |
{
|
|
| 437 |
mFramebuffer = new DistortedFramebuffer(FBO_SIZE,FBO_SIZE,1, InternalOutputSurface.DEPTH_NO_STENCIL); |
|
| 438 |
} |
|
| 436 | 439 |
|
| 437 |
ObjectControl control = getControl();
|
|
| 440 |
TwistyObject object = new TwistyBandagedGeneric(ShapeHexahedron.DEFAULT_ROT, 1.15f, TwistyObject.MODE_ICON);
|
|
| 438 | 441 |
DistortedEffects effects = object.getObjectEffects(); |
| 442 |
DistortedNode node = object.getNode(); |
|
| 443 |
|
|
| 444 |
mFramebuffer.detachAll(); |
|
| 445 |
mFramebuffer.attach(node); |
|
| 439 | 446 |
|
| 440 |
Static4D defRot = ShapeHexahedron.DEFAULT_ROT; |
|
| 441 | 447 |
Static1D halo = new Static1D(5); |
| 442 |
control.rotateNow(defRot); |
|
| 443 |
float scale = 1.15f; |
|
| 444 |
control.scaleNow(scale); |
|
| 445 | 448 |
Static4D color = new Static4D(0,0,0,1); |
| 446 | 449 |
PostprocessEffectBorder border = new PostprocessEffectBorder(halo,color); |
| 447 | 450 |
border.setHaloDepth(false); |
| ... | ... | |
| 453 | 456 |
|
| 454 | 457 |
mSaveIcon = 0; |
| 455 | 458 |
mPath = filename; |
| 456 |
*/ |
|
| 457 | 459 |
} |
| 458 | 460 |
|
| 459 | 461 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 460 | 462 |
|
| 461 |
private void saveIcon() |
|
| 463 |
private void saveIcon(long time)
|
|
| 462 | 464 |
{
|
| 465 |
mFramebuffer.render(time); |
|
| 463 | 466 |
int fW = mFramebuffer.getWidth(); |
| 464 | 467 |
int fH = mFramebuffer.getHeight(); |
| 465 | 468 |
ByteBuffer buf = ByteBuffer.allocateDirect(fW*fH*4); |
| src/main/java/org/distorted/bandaged/BandagedCreatorScreen.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.bandaged; |
| 21 | 21 |
|
| 22 |
import android.app.Activity; |
|
| 22 | 23 |
import android.graphics.Bitmap; |
| 23 | 24 |
import android.view.View; |
| 24 | 25 |
import android.widget.ImageView; |
| ... | ... | |
| 144 | 145 |
|
| 145 | 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 146 | 147 |
|
| 147 |
void iconCreationDone(Bitmap bmp) |
|
| 148 |
void iconCreationDone(Activity act, Bitmap bmp)
|
|
| 148 | 149 |
{
|
| 149 | 150 |
int numChildren = mObjectView.getChildCount(); |
| 150 | 151 |
LinearLayout pane = (LinearLayout)mObjectView.getChildAt(numChildren-1); |
| ... | ... | |
| 152 | 153 |
|
| 153 | 154 |
if( view!=null ) |
| 154 | 155 |
{
|
| 155 |
view.setImageBitmap(bmp); |
|
| 156 |
act.runOnUiThread(new Runnable() |
|
| 157 |
{
|
|
| 158 |
@Override |
|
| 159 |
public void run() |
|
| 160 |
{
|
|
| 161 |
view.setImageBitmap(bmp); |
|
| 162 |
} |
|
| 163 |
}); |
|
| 156 | 164 |
} |
| 157 | 165 |
else |
| 158 | 166 |
{
|
| src/main/java/org/distorted/bandaged/BandagedCreatorWorkerThread.java | ||
|---|---|---|
| 140 | 140 |
if( containsBlackness(tmp,width) ) return i; |
| 141 | 141 |
} |
| 142 | 142 |
|
| 143 |
return -1;
|
|
| 143 |
return 0;
|
|
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 | 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 157 | 157 |
if( containsBlackness(tmp,width) ) return i; |
| 158 | 158 |
} |
| 159 | 159 |
|
| 160 |
return -1; |
|
| 160 |
return width-1;
|
|
| 161 | 161 |
} |
| 162 | 162 |
|
| 163 | 163 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 176 | 176 |
|
| 177 | 177 |
int firstRow = computeFirstRow(input,tmp,width,height); |
| 178 | 178 |
int lastRow = computeLastRow(input,tmp,width,height); |
| 179 |
|
|
| 180 | 179 |
int startRow = (firstRow+lastRow+width)/2; |
| 181 | 180 |
|
| 182 | 181 |
for(int i=0; i<width; i++) |
| src/main/res/layout/bandaged_pane.xml | ||
|---|---|---|
| 10 | 10 |
android:id="@+id/bandagedCreatorObjectIcon" |
| 11 | 11 |
android:layout_width="match_parent" |
| 12 | 12 |
android:layout_height="0dp" |
| 13 |
android:layout_weight="3.0" |
|
| 14 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
| 13 |
android:layout_weight="3.0"/> |
|
| 15 | 14 |
|
| 16 | 15 |
<LinearLayout |
| 17 | 16 |
android:id="@+id/bandagedCreatorObjectLayout" |
Also available in: Unified diff
Create the bandaged 3x3 icon: should work already, but it doesn't. Debug.