Revision 1a106eb8
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import org.distorted.dialogs.RubikDialogBandagedSave; |
31 | 31 |
import org.distorted.library.effect.EffectType; |
32 |
import org.distorted.library.effect.FragmentEffectBrightness; |
|
32 | 33 |
import org.distorted.library.effect.PostprocessEffectBorder; |
33 | 34 |
import org.distorted.library.effect.VertexEffectDeform; |
34 | 35 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
61 | 62 |
public static final float BRIGHTNESS = 0.333f; |
62 | 63 |
private static final int DURATION = 1000; |
63 | 64 |
|
64 |
private static final int COLOR_DEFAULT = 0xffffff55; |
|
65 |
private static final int COLOR_MARKED = 0xffff0000; |
|
66 |
|
|
67 | 65 |
static final float SCREEN_RATIO = 0.5f; |
68 | 66 |
static final float OBJECT_SIZE = 3.0f; |
69 | 67 |
|
... | ... | |
162 | 160 |
|
163 | 161 |
for(int c=0; c<len; c++) |
164 | 162 |
{ |
165 |
cubits[c] = new BandagedCubit(POSITIONS[c],mQuatT,mQuatA,mScale,COLOR_DEFAULT,roundCorners);
|
|
163 |
cubits[c] = new BandagedCubit(POSITIONS[c],mQuatT,mQuatA,mScale,roundCorners); |
|
166 | 164 |
} |
167 | 165 |
|
168 | 166 |
return cubits; |
... | ... | |
181 | 179 |
if( !mCubits[c].isAttached() ) |
182 | 180 |
{ |
183 | 181 |
mCubits[c].attach(); |
184 |
mCubits[c].setTexture( COLOR_DEFAULT);
|
|
182 |
mCubits[c].setUnmarked();
|
|
185 | 183 |
mScreen.attach(mCubits[c].getNode()); |
186 | 184 |
} |
187 | 185 |
if( mCubits[c].getPosition().length>3 ) |
... | ... | |
262 | 260 |
if( mCubits[i].isAttached() ) |
263 | 261 |
{ |
264 | 262 |
mCubits[i].scaleMove(mScaleValue); |
265 |
mCubits[i].setTexture( touched==i ? COLOR_MARKED : COLOR_DEFAULT); |
|
263 |
if( touched==i ) mCubits[i].setMarked(); |
|
264 |
else mCubits[i].setUnmarked(); |
|
266 | 265 |
DistortedNode node = mCubits[i].getNode(); |
267 | 266 |
mScreen.attach(node); |
268 | 267 |
} |
... | ... | |
281 | 280 |
MeshBase.setMaxEffComponents(50); |
282 | 281 |
|
283 | 282 |
VertexEffectDeform.enable(); |
283 |
FragmentEffectBrightness.enable(); |
|
284 | 284 |
|
285 | 285 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1); |
286 | 286 |
DistortedLibrary.setCull(true); |
... | ... | |
556 | 556 |
|
557 | 557 |
public void touchCubit(int index) |
558 | 558 |
{ |
559 |
mCubits[index].setTexture(COLOR_MARKED);
|
|
559 |
mCubits[index].setMarked();
|
|
560 | 560 |
} |
561 | 561 |
|
562 | 562 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
563 | 563 |
|
564 | 564 |
public void untouchCubit(int index) |
565 | 565 |
{ |
566 |
mCubits[index].setTexture(COLOR_DEFAULT);
|
|
566 |
mCubits[index].setUnmarked();
|
|
567 | 567 |
} |
568 | 568 |
} |
src/main/java/org/distorted/bandaged/BandagedCubit.java | ||
---|---|---|
23 | 23 |
import android.graphics.Canvas; |
24 | 24 |
import android.graphics.Paint; |
25 | 25 |
|
26 |
import org.distorted.library.effect.FragmentEffectBrightness; |
|
26 | 27 |
import org.distorted.library.effect.MatrixEffectMove; |
27 | 28 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
28 | 29 |
import org.distorted.library.effect.MatrixEffectScale; |
... | ... | |
31 | 32 |
import org.distorted.library.main.DistortedTexture; |
32 | 33 |
import org.distorted.library.main.QuatHelper; |
33 | 34 |
import org.distorted.library.mesh.MeshBase; |
35 |
import org.distorted.library.type.Static1D; |
|
34 | 36 |
import org.distorted.library.type.Static3D; |
35 | 37 |
import org.distorted.library.type.Static4D; |
36 | 38 |
import org.distorted.objectlib.helpers.FactoryBandaged3x3Cubit; |
... | ... | |
48 | 50 |
public class BandagedCubit |
49 | 51 |
{ |
50 | 52 |
private static final Static3D CENTER = new Static3D(0,0,0); |
53 |
private static final float[] mTmp = new float[4]; |
|
54 |
private static final Static1D mAlpha = new Static1D(2.0f); |
|
51 | 55 |
private static Bitmap mBitmap; |
52 | 56 |
private static Static4D[] mTextureMaps; |
53 |
private static float[] mTmp = new float[4]; |
|
54 | 57 |
|
55 | 58 |
private final DistortedNode mNode; |
56 |
private final DistortedTexture mTexture;
|
|
59 |
private final DistortedEffects mEffects;
|
|
57 | 60 |
private final Static3D mMove; |
58 | 61 |
private final boolean mRoundCorners; |
59 | 62 |
|
60 | 63 |
private float mUnscaledX, mUnscaledY, mUnscaledZ; |
61 | 64 |
private float[] mPosition; |
62 | 65 |
private boolean mIsAttached; |
66 |
private long mMarkedEffectID; |
|
63 | 67 |
|
64 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
65 | 69 |
|
... | ... | |
159 | 163 |
// PUBLIC API |
160 | 164 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
161 | 165 |
|
162 |
public BandagedCubit(float[] position, Static4D quat1, Static4D quat2, Static3D scale, int color, boolean roundCorners)
|
|
166 |
public BandagedCubit(float[] position, Static4D quat1, Static4D quat2, Static3D scale, boolean roundCorners) |
|
163 | 167 |
{ |
164 | 168 |
mRoundCorners = roundCorners; |
165 | 169 |
mPosition = position; |
166 | 170 |
mIsAttached = true; |
171 |
mMarkedEffectID = -1; |
|
167 | 172 |
|
168 | 173 |
computeMove(mPosition); |
169 | 174 |
mMove = new Static3D(0,0,0); |
... | ... | |
171 | 176 |
FactoryBandaged3x3Cubit factory = FactoryBandaged3x3Cubit.getInstance(); |
172 | 177 |
MeshBase mesh = factory.createMesh(mPosition,false,mRoundCorners); |
173 | 178 |
|
174 |
mTexture = new DistortedTexture();
|
|
179 |
DistortedTexture texture = new DistortedTexture();
|
|
175 | 180 |
if( mBitmap==null ) createBitmap(); |
176 |
mTexture.setTextureAlreadyInverted(mBitmap);
|
|
181 |
texture.setTextureAlreadyInverted(mBitmap);
|
|
177 | 182 |
|
178 | 183 |
resetTextureMaps(mesh); |
179 | 184 |
|
... | ... | |
182 | 187 |
MatrixEffectQuaternion quat2Effect = new MatrixEffectQuaternion(quat2, CENTER); |
183 | 188 |
MatrixEffectMove moveEffect = new MatrixEffectMove(mMove); |
184 | 189 |
|
185 |
DistortedEffects effects = new DistortedEffects();
|
|
186 |
effects.apply(scaleEffect);
|
|
187 |
effects.apply(moveEffect);
|
|
188 |
effects.apply(quat2Effect);
|
|
189 |
effects.apply(quat1Effect);
|
|
190 |
mEffects = new DistortedEffects();
|
|
191 |
mEffects.apply(scaleEffect);
|
|
192 |
mEffects.apply(moveEffect);
|
|
193 |
mEffects.apply(quat2Effect);
|
|
194 |
mEffects.apply(quat1Effect);
|
|
190 | 195 |
|
191 |
mNode = new DistortedNode(mTexture,effects,mesh);
|
|
196 |
mNode = new DistortedNode(texture,mEffects,mesh);
|
|
192 | 197 |
} |
193 | 198 |
|
194 | 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
243 | 248 |
|
244 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
245 | 250 |
|
246 |
public void setTexture(int color)
|
|
251 |
public void setMarked()
|
|
247 | 252 |
{ |
248 |
// mTexture.setColorARGB(color); |
|
253 |
FragmentEffectBrightness effect = new FragmentEffectBrightness(mAlpha); |
|
254 |
mMarkedEffectID = effect.getID(); |
|
255 |
mEffects.apply(effect); |
|
256 |
} |
|
257 |
|
|
258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
259 |
|
|
260 |
public void setUnmarked() |
|
261 |
{ |
|
262 |
if( mMarkedEffectID>=0 ) mEffects.abortById(mMarkedEffectID); |
|
249 | 263 |
} |
250 | 264 |
|
251 | 265 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
BandagedCreator: mark cubits