Revision 334c13fa
Added by Leszek Koltunski about 9 years ago
| src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
|---|---|---|
| 46 | 46 |
{
|
| 47 | 47 |
private GLSurfaceView mView; |
| 48 | 48 |
private DistortedBitmap mBean; |
| 49 |
private Static2D pLeft, pRight;
|
|
| 49 |
private Static3D pLeft, pRight;
|
|
| 50 | 50 |
private Dynamic3D dLeft, dRight; |
| 51 | 51 |
private Static4D rLeft, rRight; |
| 52 | 52 |
private int bmpHeight, bmpWidth; |
| ... | ... | |
| 57 | 57 |
{
|
| 58 | 58 |
mView = v; |
| 59 | 59 |
|
| 60 |
pLeft = new Static2D(106, 192);
|
|
| 61 |
pRight= new Static2D(230, 150);
|
|
| 60 |
pLeft = new Static3D(106, 192, 0);
|
|
| 61 |
pRight= new Static3D(230, 150, 0);
|
|
| 62 | 62 |
|
| 63 | 63 |
rLeft = new Static4D(-9,-31,35,35); |
| 64 | 64 |
rRight= new Static4D(-9,-31,35,35); |
| src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
|---|---|---|
| 137 | 137 |
// Even if adding some of the Effects fails, the App will still start - you just won't see |
| 138 | 138 |
// the effects that failed to add. |
| 139 | 139 |
|
| 140 |
Dynamic2D dSwirl = new Dynamic2D(2000,0.0f);
|
|
| 141 |
dSwirl.add(new Static2D( 0, bmpHeight/2));
|
|
| 142 |
dSwirl.add(new Static2D( bmpWidth, bmpHeight/2));
|
|
| 140 |
Dynamic3D dSwirl = new Dynamic3D(2000,0.0f);
|
|
| 141 |
dSwirl.add(new Static3D( 0, bmpHeight/2, 0));
|
|
| 142 |
dSwirl.add(new Static3D( bmpWidth, bmpHeight/2, 0));
|
|
| 143 | 143 |
|
| 144 | 144 |
long swirlEffectID = mSuccess.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) ); |
| 145 | 145 |
|
| ... | ... | |
| 152 | 152 |
dDeform.add(new Static3D( 0, 0,0)); |
| 153 | 153 |
dDeform.add(new Static3D( 0,-bmpHeight,0)); |
| 154 | 154 |
|
| 155 |
long deformEffectID = mSuccess.deform(dDeform, new Static2D(bmpWidth/2,0) );
|
|
| 155 |
long deformEffectID = mSuccess.deform(dDeform, new Static3D(bmpWidth/2,0,0) );
|
|
| 156 | 156 |
|
| 157 | 157 |
if( deformEffectID<0 ) |
| 158 | 158 |
{
|
| src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
|---|---|---|
| 49 | 49 |
|
| 50 | 50 |
private GLSurfaceView mView; |
| 51 | 51 |
private DistortedBitmap[] bmp; |
| 52 |
private Static2D mPoint;
|
|
| 52 |
private Static3D mPoint;
|
|
| 53 | 53 |
private Dynamic3D dDistort; |
| 54 | 54 |
private int bmpHeight, bmpWidth; |
| 55 | 55 |
|
| ... | ... | |
| 63 | 63 |
dDistort = new Dynamic3D(3000,0.0f); |
| 64 | 64 |
dDistort.add(new Static3D( 25,0,0)); |
| 65 | 65 |
dDistort.add(new Static3D(-25,0,0)); |
| 66 |
mPoint = new Static2D(305, 380);
|
|
| 66 |
mPoint = new Static3D(305, 380, 0);
|
|
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
|---|---|---|
| 50 | 50 |
|
| 51 | 51 |
private GLSurfaceView mView; |
| 52 | 52 |
private DistortedBitmap[] bmp; |
| 53 |
private Static2D pLeft, pRight, pNose1;
|
|
| 53 |
private Static3D pLeft, pRight, pNose1;
|
|
| 54 | 54 |
private Static4D RegionEye; |
| 55 | 55 |
private Dynamic3D mDI; |
| 56 | 56 |
private int bmpHeight, bmpWidth; |
| ... | ... | |
| 62 | 62 |
mView = v; |
| 63 | 63 |
|
| 64 | 64 |
// bmp[0] effects |
| 65 |
pLeft = new Static2D(214, 206);
|
|
| 66 |
pRight= new Static2D(390, 212);
|
|
| 65 |
pLeft = new Static3D(214, 206, 0);
|
|
| 66 |
pRight= new Static3D(390, 212, 0);
|
|
| 67 | 67 |
RegionEye = new Static4D(0,0,60,60); |
| 68 | 68 |
|
| 69 | 69 |
// bmp[1] effects |
| 70 | 70 |
mDI = new Dynamic3D(1000,0.0f); |
| 71 | 71 |
mDI.add(new Static3D( 50,0,0)); |
| 72 | 72 |
mDI.add(new Static3D(-50,0,0)); |
| 73 |
pNose1 = new Static2D(305, 340);
|
|
| 73 |
pNose1 = new Static3D(305, 340, 0);
|
|
| 74 | 74 |
|
| 75 | 75 |
// we don't need to prepare anything for bmp[2] effects |
| 76 | 76 |
} |
| src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java | ||
|---|---|---|
| 43 | 43 |
private int mScrW, mScrH; |
| 44 | 44 |
|
| 45 | 45 |
private Static4D mRegionV, mRegionF; |
| 46 |
private Static2D mPoint;
|
|
| 46 |
private Static3D mPoint;
|
|
| 47 | 47 |
private Dynamic1D mInterA, mInterB, mInterC, mInterS; |
| 48 | 48 |
private Dynamic3D mInterD; |
| 49 | 49 |
|
| ... | ... | |
| 98 | 98 |
mRenderer = new EffectQueueRenderer(this); |
| 99 | 99 |
setRenderer(mRenderer); |
| 100 | 100 |
|
| 101 |
mPoint = new Static2D(0,0);
|
|
| 101 |
mPoint = new Static3D(0,0,0);
|
|
| 102 | 102 |
mRegionV= new Static4D(0,0,60,60); |
| 103 | 103 |
mRegionF= new Static4D(0,0,60,60); |
| 104 | 104 |
|
| ... | ... | |
| 140 | 140 |
{
|
| 141 | 141 |
case MotionEvent.ACTION_DOWN: x = (int)event.getX()* mRenderer.BWID/mScrW; |
| 142 | 142 |
y = (int)event.getY()* mRenderer.BHEI/mScrH; |
| 143 |
mPoint.set(x,y); |
|
| 143 |
mPoint.set(x,y,0);
|
|
| 144 | 144 |
mRegionF.set(x,y,60,60); |
| 145 | 145 |
EffectQueueActivity act = (EffectQueueActivity)getContext(); |
| 146 | 146 |
|
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java | ||
|---|---|---|
| 71 | 71 |
|
| 72 | 72 |
private ArrayList<Effects3DEffect> mEffects; |
| 73 | 73 |
private int mEffectAdd; |
| 74 |
private float mCenterX, mCenterY; |
|
| 74 |
private float mCenterX, mCenterY, mCenterZ;
|
|
| 75 | 75 |
private float mRegionX, mRegionY, mRegionR; |
| 76 | 76 |
|
| 77 | 77 |
private EffectNames[] mEffectNames; |
| ... | ... | |
| 321 | 321 |
|
| 322 | 322 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 323 | 323 |
|
| 324 |
public void setCenter(float x, float y) |
|
| 324 |
public void setCenter(float x, float y, float z)
|
|
| 325 | 325 |
{
|
| 326 | 326 |
mCenterX = x; |
| 327 | 327 |
mCenterY = y; |
| 328 |
mCenterZ = z; |
|
| 328 | 329 |
|
| 329 | 330 |
Effects3DSurfaceView view = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView); |
| 330 | 331 |
|
| 331 |
view.getRenderer().setCenter( mCenterX, mCenterY ); |
|
| 332 |
view.getRenderer().setCenter( mCenterX, mCenterY, mCenterZ );
|
|
| 332 | 333 |
} |
| 333 | 334 |
|
| 334 | 335 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 345 | 346 |
return mCenterY; |
| 346 | 347 |
} |
| 347 | 348 |
|
| 349 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 350 |
|
|
| 351 |
public float getCenterZ() |
|
| 352 |
{
|
|
| 353 |
return mCenterZ; |
|
| 354 |
} |
|
| 355 |
|
|
| 348 | 356 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 349 | 357 |
|
| 350 | 358 |
public float getRegionX() |
| ... | ... | |
| 450 | 458 |
return mObject==null ? 0: mObject.getHeight(); |
| 451 | 459 |
} |
| 452 | 460 |
|
| 461 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 462 |
|
|
| 463 |
public int getDepth() |
|
| 464 |
{
|
|
| 465 |
return mObject==null ? 0: mObject.getDepth(); |
|
| 466 |
} |
|
| 467 |
|
|
| 468 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 469 |
|
|
| 470 |
public int getScreenWidth() |
|
| 471 |
{
|
|
| 472 |
return 0; |
|
| 473 |
} |
|
| 474 |
|
|
| 475 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 476 |
|
|
| 477 |
public int getScreenHeight() |
|
| 478 |
{
|
|
| 479 |
return 0; |
|
| 480 |
} |
|
| 481 |
|
|
| 453 | 482 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 454 | 483 |
|
| 455 | 484 |
private void resetData() |
| ... | ... | |
| 530 | 559 |
Effects3DSurfaceView view = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView); |
| 531 | 560 |
Effects3DRenderer renderer= view.getRenderer(); |
| 532 | 561 |
|
| 533 |
renderer.setCenter( mCenterX, mCenterY ); |
|
| 562 |
renderer.setCenter( mCenterX, mCenterY, mCenterZ );
|
|
| 534 | 563 |
renderer.setRegion( mRegionX, mRegionY, mRegionR ); |
| 535 | 564 |
renderer.mQuat1.set(0,0,0,1); |
| 536 | 565 |
renderer.mQuat2.set(0,0,0,1); |
| src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
|---|---|---|
| 59 | 59 |
private Dynamic1D mDyn1; |
| 60 | 60 |
private Dynamic2D mDyn2; |
| 61 | 61 |
private Dynamic3D mDyn3; |
| 62 |
private Dynamic4D mDyn4; |
|
| 62 | 63 |
private Dynamic5D mDyn5; |
| 63 | 64 |
private Static1D mSta1; |
| 64 | 65 |
private Static2D mSta2; |
| 65 | 66 |
private Static3D mSta3; |
| 67 |
private Static4D mSta4; |
|
| 66 | 68 |
private Static5D mSta5; |
| 67 | 69 |
private Dynamic4D mRegionDyn; |
| 68 | 70 |
private Static4D mRegionSta; |
| 69 |
private Dynamic2D mCenterDyn;
|
|
| 70 |
private Static2D mCenterSta;
|
|
| 71 |
private Dynamic3D mCenterDyn;
|
|
| 72 |
private Static3D mCenterSta;
|
|
| 71 | 73 |
|
| 72 | 74 |
private View mButton, mEffect, mCenter, mRegion; |
| 73 | 75 |
private long mId; |
| ... | ... | |
| 79 | 81 |
{
|
| 80 | 82 |
switch(mName) |
| 81 | 83 |
{
|
| 84 |
case ROTATE : mId = object.rotate (mDyn4, mCenterDyn); break; |
|
| 85 |
case QUATERNION : mId = object.quaternion(mDyn4, mCenterDyn); break; |
|
| 86 |
case MOVE : mId = object.move (mDyn3) ; break; |
|
| 87 |
case SCALE : mId = object.scale (mDyn3) ; break; |
|
| 88 |
case SHEAR : mId = object.shear (mDyn3, mCenterDyn); break; |
|
| 89 |
|
|
| 82 | 90 |
case DISTORT: mId = object.distort(mDyn3, mCenterDyn, mRegionDyn); break; |
| 83 | 91 |
case DEFORM : mId = object.deform (mDyn3, mCenterDyn ); break; |
| 84 | 92 |
case SINK : mId = object.sink (mDyn1, mCenterDyn, mRegionDyn); break; |
| ... | ... | |
| 107 | 115 |
{
|
| 108 | 116 |
switch(mName) |
| 109 | 117 |
{
|
| 118 |
case ROTATE : float an = (mInter[0]-50)*180/50; |
|
| 119 |
float rx = (mInter[1]-50)/ 50.0f; |
|
| 120 |
float ry = (mInter[2]-50)/ 50.0f; |
|
| 121 |
float rz = (mInter[3]-50)/ 50.0f; |
|
| 122 |
mSta4.set(an,rx,ry,rz); |
|
| 123 |
break; |
|
| 124 |
case QUATERNION : |
|
| 125 |
break; |
|
| 126 |
case MOVE : float sw = mAct.get().getScreenWidth()/50.0f; |
|
| 127 |
float sh = mAct.get().getScreenWidth()/50.0f; |
|
| 128 |
float xm = (mInter[0]-50)*sw; |
|
| 129 |
float ym = (mInter[1]-50)*sh; |
|
| 130 |
float zm = (mInter[2]-50)*(sw+sh)/2; |
|
| 131 |
mSta3.set(xm,ym,zm); |
|
| 132 |
break; |
|
| 133 |
case SCALE : float xs = (mInter[0]>50 ? 0.18f : 0.018f)*(mInter[0]-50) + 1; |
|
| 134 |
float ys = (mInter[1]>50 ? 0.18f : 0.018f)*(mInter[1]-50) + 1; |
|
| 135 |
float zs = (mInter[2]>50 ? 0.18f : 0.018f)*(mInter[2]-50) + 1; |
|
| 136 |
mSta3.set(xs,ys,zs); |
|
| 137 |
break; |
|
| 138 |
case SHEAR : float xsh = (mInter[0]-50)/25.0f; |
|
| 139 |
float ysh = (mInter[1]-50)/25.0f; |
|
| 140 |
float zsh = (mInter[2]-50)/25.0f; |
|
| 141 |
mSta3.set(xsh,ysh,zsh); |
|
| 142 |
break; |
|
| 110 | 143 |
case DISTORT : |
| 111 |
case DEFORM : float l = mAct.get().getWidth()/50.0f; |
|
| 112 |
float x = (mInter[0]-50)*l;
|
|
| 113 |
float y = (mInter[1]-50)*l;
|
|
| 114 |
float z = (mInter[2]-50)*l;
|
|
| 115 |
mSta3.set(x,y,z);
|
|
| 144 |
case DEFORM : float ld = mAct.get().getWidth()/50.0f;
|
|
| 145 |
float xd = (mInter[0]-50)*ld;
|
|
| 146 |
float yd = (mInter[1]-50)*ld;
|
|
| 147 |
float zd = (mInter[2]-50)*ld;
|
|
| 148 |
mSta3.set(xd,yd,zd);
|
|
| 116 | 149 |
break; |
| 117 | 150 |
case WAVE : float l2 = mAct.get().getWidth()/50.0f; |
| 118 | 151 |
float x2 = (mInter[0]-50)*l2; |
| ... | ... | |
| 156 | 189 |
case 2: mInter[1] = 50; |
| 157 | 190 |
case 1: mInter[0] = 50; |
| 158 | 191 |
} |
| 192 |
|
|
| 193 |
if( mName==EffectNames.ROTATE ) mInter[1]= 100; |
|
| 159 | 194 |
} |
| 160 | 195 |
|
| 161 | 196 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 185 | 220 |
text += " ("+f1+","+f2+","+f3+")";
|
| 186 | 221 |
} |
| 187 | 222 |
|
| 223 |
if( mSta4 !=null ) |
|
| 224 |
{
|
|
| 225 |
float f1 = ((int)(mSta4.getX()*100))/100.0f; |
|
| 226 |
float f2 = ((int)(mSta4.getY()*100))/100.0f; |
|
| 227 |
float f3 = ((int)(mSta4.getZ()*100))/100.0f; |
|
| 228 |
float f4 = ((int)(mSta4.getW()*100))/100.0f; |
|
| 229 |
text += " ("+f1+","+f2+","+f3+","+f4+")";
|
|
| 230 |
} |
|
| 231 |
|
|
| 188 | 232 |
if( mSta5 !=null ) |
| 189 | 233 |
{
|
| 190 | 234 |
float f1 = ((int)(mSta5.getX()*100))/100.0f; |
| ... | ... | |
| 206 | 250 |
|
| 207 | 251 |
float x = (mInterCenter[0]*0.012f - 0.1f)*act.getWidth(); |
| 208 | 252 |
float y = (mInterCenter[1]*0.012f - 0.1f)*act.getHeight(); |
| 209 |
mCenterSta.set(x,y); |
|
| 253 |
float z = (mInterCenter[2]*0.012f - 0.1f)*act.getDepth(); |
|
| 254 |
|
|
| 255 |
mCenterSta.set(x,y,z); |
|
| 210 | 256 |
} |
| 211 | 257 |
|
| 212 | 258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 215 | 261 |
{
|
| 216 | 262 |
mInterCenter[0] = 50; |
| 217 | 263 |
mInterCenter[1] = 50; |
| 264 |
mInterCenter[2] = 50; |
|
| 218 | 265 |
} |
| 219 | 266 |
|
| 220 | 267 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 223 | 270 |
{
|
| 224 | 271 |
int f0 = (int)mCenterSta.getX(); |
| 225 | 272 |
int f1 = (int)mCenterSta.getY(); |
| 273 |
int f2 = (int)mCenterSta.getZ(); |
|
| 226 | 274 |
|
| 227 |
mTextCenter.setText("center ("+f0+","+f1+")");
|
|
| 275 |
mTextCenter.setText("center ("+f0+","+f1+","+f2+")");
|
|
| 228 | 276 |
} |
| 229 | 277 |
|
| 230 | 278 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 278 | 326 |
mDyn1 = null; |
| 279 | 327 |
mDyn2 = null; |
| 280 | 328 |
mDyn3 = null; |
| 329 |
mDyn4 = null; |
|
| 281 | 330 |
mDyn5 = null; |
| 282 | 331 |
mSta1 = null; |
| 283 | 332 |
mSta2 = null; |
| 284 | 333 |
mSta3 = null; |
| 334 |
mSta4 = null; |
|
| 285 | 335 |
mSta5 = null; |
| 286 | 336 |
|
| 287 | 337 |
mDimension = mName.getDimension(); |
| ... | ... | |
| 300 | 350 |
mSta3 = new Static3D(0,0,0); |
| 301 | 351 |
mDyn3.add(mSta3); |
| 302 | 352 |
break; |
| 303 |
case 4 : mDyn3 = new Dynamic3D(); |
|
| 304 |
mSta3 = new Static3D(0,0,0); |
|
| 305 |
mDyn3.add(mSta3); |
|
| 306 |
mDyn1 = new Dynamic1D(); |
|
| 307 |
mSta1 = new Static1D(0); |
|
| 308 |
mDyn1.add(mSta1); |
|
| 353 |
case 4 : if( mName == EffectNames.QUATERNION || mName == EffectNames.ROTATE ) |
|
| 354 |
{
|
|
| 355 |
mDyn4 = new Dynamic4D(); |
|
| 356 |
mSta4 = new Static4D(0,0,0,0); |
|
| 357 |
mDyn4.add(mSta4); |
|
| 358 |
} |
|
| 359 |
else |
|
| 360 |
{
|
|
| 361 |
mDyn3 = new Dynamic3D(); |
|
| 362 |
mSta3 = new Static3D(0,0,0); |
|
| 363 |
mDyn3.add(mSta3); |
|
| 364 |
mDyn1 = new Dynamic1D(); |
|
| 365 |
mSta1 = new Static1D(0); |
|
| 366 |
mDyn1.add(mSta1); |
|
| 367 |
} |
|
| 309 | 368 |
break; |
| 310 | 369 |
case 5 : mDyn5 = new Dynamic5D(); |
| 311 | 370 |
mSta5 = new Static5D(0,0,0,0,0); |
| ... | ... | |
| 323 | 382 |
mRegionSta = new Static4D(0,0,0,0); |
| 324 | 383 |
mRegionDyn.add(mRegionSta); |
| 325 | 384 |
|
| 326 |
mInterCenter = new int[2];
|
|
| 327 |
mSeekCenterID= new int[2];
|
|
| 328 |
mCenterDyn = new Dynamic2D();
|
|
| 329 |
mCenterSta = new Static2D(0,0);
|
|
| 385 |
mInterCenter = new int[3];
|
|
| 386 |
mSeekCenterID= new int[3];
|
|
| 387 |
mCenterDyn = new Dynamic3D();
|
|
| 388 |
mCenterSta = new Static3D(0,0,0);
|
|
| 330 | 389 |
mCenterDyn.add(mCenterSta); |
| 331 | 390 |
|
| 332 | 391 |
mButton = null; |
| ... | ... | |
| 395 | 454 |
mSeekID[4] = seek[4].getId(); |
| 396 | 455 |
mButton = mEffect.findViewById(R.id.button5dRemove); |
| 397 | 456 |
break; |
| 398 |
default: android.util.Log.e("Effects3DEffect", "dimension "+mDimension+" not supported!");
|
|
| 457 |
default: android.util.Log.e("Matrix3DEffect", "dimension "+mDimension+" not supported!");
|
|
| 399 | 458 |
return null; |
| 400 | 459 |
} |
| 401 | 460 |
|
| ... | ... | |
| 456 | 515 |
|
| 457 | 516 |
mCenter = act.getLayoutInflater().inflate(R.layout.effectcenter, null); |
| 458 | 517 |
|
| 459 |
SeekBar[] seek = new SeekBar[2];
|
|
| 518 |
SeekBar[] seek = new SeekBar[3];
|
|
| 460 | 519 |
|
| 461 | 520 |
seek[0] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarX ); |
| 462 | 521 |
seek[1] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarY ); |
| 522 |
seek[2] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarZ ); |
|
| 463 | 523 |
|
| 464 | 524 |
mSeekCenterID[0] = seek[0].getId(); |
| 465 | 525 |
mSeekCenterID[1] = seek[1].getId(); |
| 526 |
mSeekCenterID[2] = seek[2].getId(); |
|
| 466 | 527 |
|
| 467 | 528 |
mTextCenter = (TextView)mCenter.findViewById(R.id.effectCenterText); |
| 468 | 529 |
|
| 469 | 530 |
setDefaultCenterInter(); |
| 470 | 531 |
|
| 471 |
for(int i=0; i<2; i++)
|
|
| 532 |
for(int i=0; i<3; i++)
|
|
| 472 | 533 |
{
|
| 473 | 534 |
seek[i].setOnSeekBarChangeListener(this); |
| 474 | 535 |
seek[i].setProgress( mInterCenter[i] ); |
| 475 | 536 |
} |
| 476 | 537 |
|
| 477 |
act.setCenter(mCenterSta.getX(),mCenterSta.getY()); |
|
| 538 |
act.setCenter(mCenterSta.getX(),mCenterSta.getY(),mCenterSta.getZ());
|
|
| 478 | 539 |
|
| 479 | 540 |
return mCenter; |
| 480 | 541 |
} |
| ... | ... | |
| 551 | 612 |
fillCenterStatics(); |
| 552 | 613 |
setCenterText(); |
| 553 | 614 |
} |
| 615 |
if( bar.getId() == mSeekCenterID[2] ) |
|
| 616 |
{
|
|
| 617 |
mInterCenter[2] = progress; |
|
| 618 |
fillCenterStatics(); |
|
| 619 |
setCenterText(); |
|
| 620 |
} |
|
| 554 | 621 |
|
| 555 | 622 |
if( fromUser ) |
| 556 | 623 |
{
|
| ... | ... | |
| 559 | 626 |
|
| 560 | 627 |
Effects3DActivity act = mAct.get(); |
| 561 | 628 |
|
| 562 |
act.setCenter(mCenterSta.getX(),mCenterSta.getY()); |
|
| 629 |
act.setCenter(mCenterSta.getX(),mCenterSta.getY(),mCenterSta.getZ());
|
|
| 563 | 630 |
act.setRegion(mRegionSta.getX(),mRegionSta.getY(),mRegionSta.getZ()); |
| 564 | 631 |
} |
| 565 | 632 |
} |
| src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
|---|---|---|
| 101 | 101 |
|
| 102 | 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 103 | 103 |
|
| 104 |
void setCenter(float x, float y) |
|
| 104 |
void setCenter(float x, float y, float z)
|
|
| 105 | 105 |
{
|
| 106 |
mCenterPoint.set(mFactorObj*x,mFactorObj*y,0);
|
|
| 106 |
mCenterPoint.set(mFactorObj*x,mFactorObj*y,mFactorObj*z);
|
|
| 107 | 107 |
} |
| 108 | 108 |
|
| 109 | 109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/fbo/FBORenderer.java | ||
|---|---|---|
| 139 | 139 |
sinkDyn.add(new Static1D(1.0f)); |
| 140 | 140 |
sinkDyn.add(new Static1D(0.5f)); |
| 141 | 141 |
|
| 142 |
text.sink(sinkDyn, new Static2D(textWidth/2,textHeight/2));
|
|
| 142 |
text.sink(sinkDyn, new Static3D(textWidth/2,textHeight/2, 0));
|
|
| 143 | 143 |
|
| 144 | 144 |
Dynamic1D chromaDyn = new Dynamic1D(10000,0.0f); |
| 145 | 145 |
chromaDyn.add(new Static1D(0.0f)); |
| src/main/java/org/distorted/examples/flag/FlagRenderer.java | ||
|---|---|---|
| 85 | 85 |
mQuatInt1.add(mQuat1); |
| 86 | 86 |
mQuatInt2.add(mQuat2); |
| 87 | 87 |
|
| 88 |
Static2D waveCenter = new Static2D(mObjWidth, mObjHeight/2); // middle of the right edge
|
|
| 88 |
Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, 0); // middle of the right edge
|
|
| 89 | 89 |
Static4D waveRegion = new Static4D(0,0,mObjWidth,mObjWidth); |
| 90 | 90 |
|
| 91 | 91 |
mObject.wave(mWaveDyn, waveCenter, waveRegion); |
| src/main/java/org/distorted/examples/fov/FOVRenderer.java | ||
|---|---|---|
| 117 | 117 |
Static3D vector = new Static3D(0,0,min/5); |
| 118 | 118 |
Static4D region = new Static4D(0,0,min/5,min/5); |
| 119 | 119 |
|
| 120 |
fov.distort(vector, new Static2D( w/4, h/4), region);
|
|
| 121 |
fov.distort(vector, new Static2D(3*w/4, h/4), region);
|
|
| 122 |
fov.distort(vector, new Static2D( w/4, 3*h/4), region);
|
|
| 123 |
fov.distort(vector, new Static2D(3*w/4, 3*h/4), region);
|
|
| 120 |
fov.distort(vector, new Static3D( w/4, h/4, 0), region);
|
|
| 121 |
fov.distort(vector, new Static3D(3*w/4, h/4, 0), region);
|
|
| 122 |
fov.distort(vector, new Static3D( w/4, 3*h/4, 0), region);
|
|
| 123 |
fov.distort(vector, new Static3D(3*w/4, 3*h/4, 0), region);
|
|
| 124 | 124 |
} |
| 125 | 125 |
|
| 126 | 126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
|---|---|---|
| 48 | 48 |
{
|
| 49 | 49 |
private GLSurfaceView mView; |
| 50 | 50 |
private DistortedBitmap mGirl; |
| 51 |
private Static2D pLeft, pRight, pHips;
|
|
| 51 |
private Static3D pLeft, pRight, pHips;
|
|
| 52 | 52 |
private Static4D Region, sinkRegion, HipsRegion; |
| 53 | 53 |
private Dynamic3D diL, diR; |
| 54 | 54 |
private Dynamic1D diHips, diSink; |
| ... | ... | |
| 69 | 69 |
hipsSwirl = 0; |
| 70 | 70 |
boobsSink = 1.0f; |
| 71 | 71 |
|
| 72 |
pLeft = new Static2D(132, 264);
|
|
| 73 |
pRight= new Static2D(247, 264);
|
|
| 72 |
pLeft = new Static3D(132, 264, 0);
|
|
| 73 |
pRight= new Static3D(247, 264, 0);
|
|
| 74 | 74 |
|
| 75 | 75 |
// Size |
| 76 | 76 |
sinkRegion = new Static4D(0,0,60,60); |
| ... | ... | |
| 102 | 102 |
diR.add(v1); |
| 103 | 103 |
|
| 104 | 104 |
// Lower Movement |
| 105 |
pHips = new Static2D(216,505);
|
|
| 105 |
pHips = new Static3D(216,505,0);
|
|
| 106 | 106 |
HipsRegion = new Static4D(0,0,120,120); |
| 107 | 107 |
diHips = new Dynamic1D(1500,0.0f); |
| 108 | 108 |
|
| src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
|---|---|---|
| 77 | 77 |
dDistort.add(new Static3D(0,0, 0)); |
| 78 | 78 |
dDistort.add(new Static3D(0,0,height)); |
| 79 | 79 |
|
| 80 |
return water.distort(dDistort, new Static2D(pointx,pointy), new Static4D(0,0,radius,radius));
|
|
| 80 |
return water.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
|
|
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/matrix3d/Matrix3DActivity.java | ||
|---|---|---|
| 53 | 53 |
private EffectNames[] mEffectNames; |
| 54 | 54 |
|
| 55 | 55 |
private static boolean mSupportsCenter; |
| 56 |
private float mCenterX, mCenterY; |
|
| 56 |
private float mCenterX, mCenterY, mCenterZ;
|
|
| 57 | 57 |
|
| 58 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 | 59 |
|
| ... | ... | |
| 111 | 111 |
|
| 112 | 112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 113 | 113 |
|
| 114 |
public void setCenter(float x, float y) |
|
| 114 |
public void setCenter(float x, float y, float z)
|
|
| 115 | 115 |
{
|
| 116 | 116 |
mCenterX = x; |
| 117 | 117 |
mCenterY = y; |
| 118 |
mCenterZ = z; |
|
| 118 | 119 |
} |
| 119 | 120 |
|
| 120 | 121 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 183 | 184 |
return mObject==null ? 0: mObject.getHeight(); |
| 184 | 185 |
} |
| 185 | 186 |
|
| 187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 188 |
|
|
| 189 |
public int getScreenWidth() |
|
| 190 |
{
|
|
| 191 |
Matrix3DRenderer r = ((Matrix3DSurfaceView)findViewById(R.id.matrix3dSurfaceView)).getRenderer(); |
|
| 192 |
return r.getWidth(); |
|
| 193 |
} |
|
| 194 |
|
|
| 195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 196 |
|
|
| 197 |
public int getScreenHeight() |
|
| 198 |
{
|
|
| 199 |
Matrix3DRenderer r = ((Matrix3DSurfaceView)findViewById(R.id.matrix3dSurfaceView)).getRenderer(); |
|
| 200 |
return r.getHeight(); |
|
| 201 |
} |
|
| 202 |
|
|
| 203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 204 |
|
|
| 205 |
public int getDepth() |
|
| 206 |
{
|
|
| 207 |
return mObject==null ? 0: mObject.getDepth(); |
|
| 208 |
} |
|
| 209 |
|
|
| 186 | 210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 187 | 211 |
|
| 188 | 212 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
| src/main/java/org/distorted/examples/matrix3d/Matrix3DEffect.java | ||
|---|---|---|
| 59 | 59 |
private Dynamic1D mDyn1; |
| 60 | 60 |
private Dynamic2D mDyn2; |
| 61 | 61 |
private Dynamic3D mDyn3; |
| 62 |
private Dynamic4D mDyn4; |
|
| 62 | 63 |
private Dynamic5D mDyn5; |
| 63 | 64 |
private Static1D mSta1; |
| 64 | 65 |
private Static2D mSta2; |
| 65 | 66 |
private Static3D mSta3; |
| 67 |
private Static4D mSta4; |
|
| 66 | 68 |
private Static5D mSta5; |
| 67 | 69 |
private Dynamic4D mRegionDyn; |
| 68 | 70 |
private Static4D mRegionSta; |
| 69 |
private Dynamic2D mCenterDyn;
|
|
| 70 |
private Static2D mCenterSta;
|
|
| 71 |
private Dynamic3D mCenterDyn;
|
|
| 72 |
private Static3D mCenterSta;
|
|
| 71 | 73 |
|
| 72 | 74 |
private View mButton, mEffect, mCenter, mRegion; |
| 73 | 75 |
private long mId; |
| ... | ... | |
| 79 | 81 |
{
|
| 80 | 82 |
switch(mName) |
| 81 | 83 |
{
|
| 82 |
case ROTATE : break;//object.rotate (mDyn4, mCenterDyn); break;
|
|
| 83 |
case QUATERNION : break;//object.quaternion(mDyn4, mCenterDyn); break;
|
|
| 84 |
case MOVE : object.move (mDyn3) ; break;
|
|
| 85 |
case SCALE : object.scale (mDyn3) ; break;
|
|
| 86 |
case SHEAR : break;//object.shear (mDyn3, mCenterDyn); break;
|
|
| 84 |
case ROTATE : mId = object.rotate (mDyn4, mCenterDyn); break;
|
|
| 85 |
case QUATERNION : mId = object.quaternion(mDyn4, mCenterDyn); break;
|
|
| 86 |
case MOVE : mId = object.move (mDyn3) ; break;
|
|
| 87 |
case SCALE : mId = object.scale (mDyn3) ; break;
|
|
| 88 |
case SHEAR : mId = object.shear (mDyn3, mCenterDyn); break;
|
|
| 87 | 89 |
|
| 88 | 90 |
case DISTORT: mId = object.distort(mDyn3, mCenterDyn, mRegionDyn); break; |
| 89 | 91 |
case DEFORM : mId = object.deform (mDyn3, mCenterDyn ); break; |
| ... | ... | |
| 113 | 115 |
{
|
| 114 | 116 |
switch(mName) |
| 115 | 117 |
{
|
| 116 |
case ROTATE : |
|
| 118 |
case ROTATE : float an = (mInter[0]-50)*180/50; |
|
| 119 |
float rx = (mInter[1]-50)/ 50.0f; |
|
| 120 |
float ry = (mInter[2]-50)/ 50.0f; |
|
| 121 |
float rz = (mInter[3]-50)/ 50.0f; |
|
| 122 |
mSta4.set(an,rx,ry,rz); |
|
| 117 | 123 |
break; |
| 118 | 124 |
case QUATERNION : |
| 119 | 125 |
break; |
| 120 |
case MOVE : float lm = mAct.get().getWidth()/50.0f; |
|
| 121 |
float xm = (mInter[0]-50)*lm; |
|
| 122 |
float ym = (mInter[1]-50)*lm; |
|
| 123 |
float zm = (mInter[2]-50)*lm; |
|
| 126 |
case MOVE : float sw = mAct.get().getScreenWidth()/50.0f; |
|
| 127 |
float sh = mAct.get().getScreenWidth()/50.0f; |
|
| 128 |
float xm = (mInter[0]-50)*sw; |
|
| 129 |
float ym = (mInter[1]-50)*sh; |
|
| 130 |
float zm = (mInter[2]-50)*(sw+sh)/2; |
|
| 124 | 131 |
mSta3.set(xm,ym,zm); |
| 125 | 132 |
break; |
| 126 |
case SCALE : float xs = (mInter[0])/50.0f;
|
|
| 127 |
float ys = (mInter[1])/50.0f;
|
|
| 128 |
float zs = (mInter[2])/50.0f;
|
|
| 133 |
case SCALE : float xs = (mInter[0]>50 ? 0.18f : 0.018f)*(mInter[0]-50) + 1;
|
|
| 134 |
float ys = (mInter[1]>50 ? 0.18f : 0.018f)*(mInter[1]-50) + 1;
|
|
| 135 |
float zs = (mInter[2]>50 ? 0.18f : 0.018f)*(mInter[2]-50) + 1;
|
|
| 129 | 136 |
mSta3.set(xs,ys,zs); |
| 130 | 137 |
break; |
| 131 |
case SHEAR : |
|
| 138 |
case SHEAR : float xsh = (mInter[0]-50)/25.0f; |
|
| 139 |
float ysh = (mInter[1]-50)/25.0f; |
|
| 140 |
float zsh = (mInter[2]-50)/25.0f; |
|
| 141 |
mSta3.set(xsh,ysh,zsh); |
|
| 132 | 142 |
break; |
| 133 | 143 |
case DISTORT : |
| 134 | 144 |
case DEFORM : float ld = mAct.get().getWidth()/50.0f; |
| ... | ... | |
| 179 | 189 |
case 2: mInter[1] = 50; |
| 180 | 190 |
case 1: mInter[0] = 50; |
| 181 | 191 |
} |
| 192 |
|
|
| 193 |
if( mName==EffectNames.ROTATE ) mInter[1]= 100; |
|
| 182 | 194 |
} |
| 183 | 195 |
|
| 184 | 196 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 208 | 220 |
text += " ("+f1+","+f2+","+f3+")";
|
| 209 | 221 |
} |
| 210 | 222 |
|
| 223 |
if( mSta4 !=null ) |
|
| 224 |
{
|
|
| 225 |
float f1 = ((int)(mSta4.getX()*100))/100.0f; |
|
| 226 |
float f2 = ((int)(mSta4.getY()*100))/100.0f; |
|
| 227 |
float f3 = ((int)(mSta4.getZ()*100))/100.0f; |
|
| 228 |
float f4 = ((int)(mSta4.getW()*100))/100.0f; |
|
| 229 |
text += " ("+f1+","+f2+","+f3+","+f4+")";
|
|
| 230 |
} |
|
| 231 |
|
|
| 211 | 232 |
if( mSta5 !=null ) |
| 212 | 233 |
{
|
| 213 | 234 |
float f1 = ((int)(mSta5.getX()*100))/100.0f; |
| ... | ... | |
| 229 | 250 |
|
| 230 | 251 |
float x = (mInterCenter[0]*0.012f - 0.1f)*act.getWidth(); |
| 231 | 252 |
float y = (mInterCenter[1]*0.012f - 0.1f)*act.getHeight(); |
| 232 |
mCenterSta.set(x,y); |
|
| 253 |
float z = (mInterCenter[2]*0.012f - 0.1f)*act.getDepth(); |
|
| 254 |
|
|
| 255 |
mCenterSta.set(x,y,z); |
|
| 233 | 256 |
} |
| 234 | 257 |
|
| 235 | 258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 238 | 261 |
{
|
| 239 | 262 |
mInterCenter[0] = 50; |
| 240 | 263 |
mInterCenter[1] = 50; |
| 264 |
mInterCenter[2] = 50; |
|
| 241 | 265 |
} |
| 242 | 266 |
|
| 243 | 267 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 246 | 270 |
{
|
| 247 | 271 |
int f0 = (int)mCenterSta.getX(); |
| 248 | 272 |
int f1 = (int)mCenterSta.getY(); |
| 273 |
int f2 = (int)mCenterSta.getZ(); |
|
| 249 | 274 |
|
| 250 |
mTextCenter.setText("center ("+f0+","+f1+")");
|
|
| 275 |
mTextCenter.setText("center ("+f0+","+f1+","+f2+")");
|
|
| 251 | 276 |
} |
| 252 | 277 |
|
| 253 | 278 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 301 | 326 |
mDyn1 = null; |
| 302 | 327 |
mDyn2 = null; |
| 303 | 328 |
mDyn3 = null; |
| 329 |
mDyn4 = null; |
|
| 304 | 330 |
mDyn5 = null; |
| 305 | 331 |
mSta1 = null; |
| 306 | 332 |
mSta2 = null; |
| 307 | 333 |
mSta3 = null; |
| 334 |
mSta4 = null; |
|
| 308 | 335 |
mSta5 = null; |
| 309 | 336 |
|
| 310 | 337 |
mDimension = mName.getDimension(); |
| ... | ... | |
| 323 | 350 |
mSta3 = new Static3D(0,0,0); |
| 324 | 351 |
mDyn3.add(mSta3); |
| 325 | 352 |
break; |
| 326 |
case 4 : mDyn3 = new Dynamic3D(); |
|
| 327 |
mSta3 = new Static3D(0,0,0); |
|
| 328 |
mDyn3.add(mSta3); |
|
| 329 |
mDyn1 = new Dynamic1D(); |
|
| 330 |
mSta1 = new Static1D(0); |
|
| 331 |
mDyn1.add(mSta1); |
|
| 353 |
case 4 : if( mName == EffectNames.QUATERNION || mName == EffectNames.ROTATE ) |
|
| 354 |
{
|
|
| 355 |
mDyn4 = new Dynamic4D(); |
|
| 356 |
mSta4 = new Static4D(0,0,0,0); |
|
| 357 |
mDyn4.add(mSta4); |
|
| 358 |
} |
|
| 359 |
else |
|
| 360 |
{
|
|
| 361 |
mDyn3 = new Dynamic3D(); |
|
| 362 |
mSta3 = new Static3D(0,0,0); |
|
| 363 |
mDyn3.add(mSta3); |
|
| 364 |
mDyn1 = new Dynamic1D(); |
|
| 365 |
mSta1 = new Static1D(0); |
|
| 366 |
mDyn1.add(mSta1); |
|
| 367 |
} |
|
| 332 | 368 |
break; |
| 333 | 369 |
case 5 : mDyn5 = new Dynamic5D(); |
| 334 | 370 |
mSta5 = new Static5D(0,0,0,0,0); |
| ... | ... | |
| 346 | 382 |
mRegionSta = new Static4D(0,0,0,0); |
| 347 | 383 |
mRegionDyn.add(mRegionSta); |
| 348 | 384 |
|
| 349 |
mInterCenter = new int[2];
|
|
| 350 |
mSeekCenterID= new int[2];
|
|
| 351 |
mCenterDyn = new Dynamic2D();
|
|
| 352 |
mCenterSta = new Static2D(0,0);
|
|
| 385 |
mInterCenter = new int[3];
|
|
| 386 |
mSeekCenterID= new int[3];
|
|
| 387 |
mCenterDyn = new Dynamic3D();
|
|
| 388 |
mCenterSta = new Static3D(0,0,0);
|
|
| 353 | 389 |
mCenterDyn.add(mCenterSta); |
| 354 | 390 |
|
| 355 | 391 |
mButton = null; |
| ... | ... | |
| 479 | 515 |
|
| 480 | 516 |
mCenter = act.getLayoutInflater().inflate(R.layout.effectcenter, null); |
| 481 | 517 |
|
| 482 |
SeekBar[] seek = new SeekBar[2];
|
|
| 518 |
SeekBar[] seek = new SeekBar[3];
|
|
| 483 | 519 |
|
| 484 | 520 |
seek[0] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarX ); |
| 485 | 521 |
seek[1] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarY ); |
| 522 |
seek[2] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarZ ); |
|
| 486 | 523 |
|
| 487 | 524 |
mSeekCenterID[0] = seek[0].getId(); |
| 488 | 525 |
mSeekCenterID[1] = seek[1].getId(); |
| 526 |
mSeekCenterID[2] = seek[2].getId(); |
|
| 489 | 527 |
|
| 490 | 528 |
mTextCenter = (TextView)mCenter.findViewById(R.id.effectCenterText); |
| 491 | 529 |
|
| 492 | 530 |
setDefaultCenterInter(); |
| 493 | 531 |
|
| 494 |
for(int i=0; i<2; i++)
|
|
| 532 |
for(int i=0; i<3; i++)
|
|
| 495 | 533 |
{
|
| 496 | 534 |
seek[i].setOnSeekBarChangeListener(this); |
| 497 | 535 |
seek[i].setProgress( mInterCenter[i] ); |
| 498 | 536 |
} |
| 499 | 537 |
|
| 500 |
act.setCenter(mCenterSta.getX(),mCenterSta.getY()); |
|
| 538 |
act.setCenter(mCenterSta.getX(),mCenterSta.getY(),mCenterSta.getZ());
|
|
| 501 | 539 |
|
| 502 | 540 |
return mCenter; |
| 503 | 541 |
} |
| ... | ... | |
| 574 | 612 |
fillCenterStatics(); |
| 575 | 613 |
setCenterText(); |
| 576 | 614 |
} |
| 615 |
if( bar.getId() == mSeekCenterID[2] ) |
|
| 616 |
{
|
|
| 617 |
mInterCenter[2] = progress; |
|
| 618 |
fillCenterStatics(); |
|
| 619 |
setCenterText(); |
|
| 620 |
} |
|
| 577 | 621 |
|
| 578 | 622 |
if( fromUser ) |
| 579 | 623 |
{
|
| ... | ... | |
| 582 | 626 |
|
| 583 | 627 |
Matrix3DActivity act = mAct.get(); |
| 584 | 628 |
|
| 585 |
act.setCenter(mCenterSta.getX(),mCenterSta.getY()); |
|
| 629 |
act.setCenter(mCenterSta.getX(),mCenterSta.getY(),mCenterSta.getZ());
|
|
| 586 | 630 |
act.setRegion(mRegionSta.getX(),mRegionSta.getY(),mRegionSta.getZ()); |
| 587 | 631 |
} |
| 588 | 632 |
} |
| src/main/java/org/distorted/examples/matrix3d/Matrix3DRenderer.java | ||
|---|---|---|
| 36 | 36 |
private GLSurfaceView mView; |
| 37 | 37 |
private DistortedObject mObject; |
| 38 | 38 |
|
| 39 |
private int mWidth, mHeight; |
|
| 40 |
|
|
| 39 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 40 | 42 |
|
| 41 | 43 |
Matrix3DRenderer(GLSurfaceView v) |
| ... | ... | |
| 56 | 58 |
mObject.draw(time); |
| 57 | 59 |
} |
| 58 | 60 |
|
| 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 62 |
|
|
| 63 |
public int getWidth() |
|
| 64 |
{
|
|
| 65 |
return mWidth; |
|
| 66 |
} |
|
| 67 |
|
|
| 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 69 |
|
|
| 70 |
public int getHeight() |
|
| 71 |
{
|
|
| 72 |
return mHeight; |
|
| 73 |
} |
|
| 74 |
|
|
| 59 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 60 | 76 |
|
| 61 | 77 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 62 | 78 |
{
|
| 63 | 79 |
mObject.abortEffects(EffectTypes.MATRIX); |
| 64 | 80 |
|
| 81 |
mWidth = width; |
|
| 82 |
mHeight= height; |
|
| 83 |
|
|
| 65 | 84 |
Distorted.onSurfaceChanged(width, height); |
| 66 | 85 |
} |
| 67 | 86 |
|
| src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
|---|---|---|
| 45 | 45 |
{
|
| 46 | 46 |
private GLSurfaceView mView; |
| 47 | 47 |
private DistortedBitmap monaLisa; |
| 48 |
private Static2D pLeft, pRight;
|
|
| 48 |
private Static3D pLeft, pRight;
|
|
| 49 | 49 |
private Static4D rLeft, rRight; |
| 50 | 50 |
private Dynamic3D dLeft, dRight; |
| 51 | 51 |
|
| ... | ... | |
| 57 | 57 |
{
|
| 58 | 58 |
mView = v; |
| 59 | 59 |
|
| 60 |
pLeft = new Static2D( 90, 258);
|
|
| 61 |
pRight= new Static2D(176, 255);
|
|
| 60 |
pLeft = new Static3D( 90, 258, 0);
|
|
| 61 |
pRight= new Static3D(176, 255, 0);
|
|
| 62 | 62 |
|
| 63 | 63 |
rLeft = new Static4D(-10,-10,25,25); |
| 64 | 64 |
rRight= new Static4D( 10, -5,25,25); |
| src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
import org.distorted.library.EffectTypes; |
| 32 | 32 |
import org.distorted.library.type.Dynamic2D; |
| 33 |
import org.distorted.library.type.Dynamic3D; |
|
| 33 | 34 |
import org.distorted.library.type.Dynamic4D; |
| 34 | 35 |
import org.distorted.library.type.Static1D; |
| 35 | 36 |
import org.distorted.library.type.Static2D; |
| ... | ... | |
| 52 | 53 |
|
| 53 | 54 |
private static final Object lock = new Object(); |
| 54 | 55 |
|
| 55 |
private Dynamic2D di2D;
|
|
| 56 |
private Dynamic3D di3D;
|
|
| 56 | 57 |
private Static4D dr; |
| 57 | 58 |
private Dynamic4D mRegion; |
| 58 | 59 |
|
| ... | ... | |
| 75 | 76 |
mPaint.setStyle(Style.FILL); |
| 76 | 77 |
moving = -1; |
| 77 | 78 |
|
| 78 |
di2D = new Dynamic2D(LOOP_TIME,0.0f);
|
|
| 79 |
di3D = new Dynamic3D(LOOP_TIME,0.0f);
|
|
| 79 | 80 |
mRegion = new Dynamic4D(LOOP_TIME,0.0f); |
| 80 | 81 |
|
| 81 | 82 |
if(!isInEditMode()) |
| ... | ... | |
| 125 | 126 |
{
|
| 126 | 127 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX); |
| 127 | 128 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT); |
| 128 |
MovingEffectsRenderer.mBackground.distort( new Static3D(0,0,mMax/10) , di2D, dr);
|
|
| 129 |
MovingEffectsRenderer.mBackground.distort( new Static3D(0,0,mMax/10) , di3D, dr);
|
|
| 129 | 130 |
mCurrEffect = EFFECT_BUBBLE; |
| 130 | 131 |
} |
| 131 | 132 |
} |
| ... | ... | |
| 140 | 141 |
{
|
| 141 | 142 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX); |
| 142 | 143 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT); |
| 143 |
MovingEffectsRenderer.mBackground.sink(new Static1D(10), di2D, dr);
|
|
| 144 |
MovingEffectsRenderer.mBackground.sink(new Static1D(10), di3D, dr);
|
|
| 144 | 145 |
mCurrEffect = EFFECT_SINK; |
| 145 | 146 |
} |
| 146 | 147 |
} |
| ... | ... | |
| 185 | 186 |
{
|
| 186 | 187 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX); |
| 187 | 188 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT); |
| 188 |
MovingEffectsRenderer.mBackground.swirl( new Static1D(30), di2D, dr);
|
|
| 189 |
MovingEffectsRenderer.mBackground.swirl( new Static1D(30), di3D, dr);
|
|
| 189 | 190 |
mCurrEffect = EFFECT_SWIRL; |
| 190 | 191 |
} |
| 191 | 192 |
} |
| ... | ... | |
| 198 | 199 |
{
|
| 199 | 200 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX); |
| 200 | 201 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT); |
| 201 |
di2D.removeAll();
|
|
| 202 |
di3D.removeAll();
|
|
| 202 | 203 |
mRegion.removeAll(); |
| 203 | 204 |
mCurrEffect = EFFECT_POINTS; |
| 204 | 205 |
} |
| ... | ... | |
| 210 | 211 |
{
|
| 211 | 212 |
synchronized(lock) |
| 212 | 213 |
{
|
| 213 |
int len = di2D.getNumPoints();
|
|
| 214 |
int len = di3D.getNumPoints();
|
|
| 214 | 215 |
|
| 215 |
float[] drawCoord = new float[2];
|
|
| 216 |
Static2D cu;
|
|
| 216 |
float[] drawCoord = new float[3];
|
|
| 217 |
Static3D cu;
|
|
| 217 | 218 |
int lit = mTime> 0 ? (int)((float)(time-mTime)*NUM_POINTS/LOOP_TIME) : 0; |
| 218 | 219 |
|
| 219 | 220 |
if( len>=2 ) |
| ... | ... | |
| 226 | 227 |
: 0xff - (lit+NUM_POINTS-i)*0xff/(NUM_POINTS-1); |
| 227 | 228 |
|
| 228 | 229 |
mPaint.setColor( 0xffffff + ((color&0xff)<<24) ); |
| 229 |
di2D.interpolateMain( drawCoord, 0, (long)(i*step) );
|
|
| 230 |
di3D.interpolateMain( drawCoord, 0, (long)(i*step) );
|
|
| 230 | 231 |
c.drawCircle(drawCoord[0], drawCoord[1], mSize1, mPaint ); |
| 231 | 232 |
} |
| 232 | 233 |
} |
| ... | ... | |
| 235 | 236 |
|
| 236 | 237 |
for(int curr=0; curr<len; curr++) |
| 237 | 238 |
{
|
| 238 |
cu = di2D.getPoint(curr);
|
|
| 239 |
cu = di3D.getPoint(curr);
|
|
| 239 | 240 |
c.drawCircle(cu.getX(), cu.getY(), mSize2, mPaint); |
| 240 | 241 |
} |
| 241 | 242 |
|
| ... | ... | |
| 258 | 259 |
|
| 259 | 260 |
float gx, gy; |
| 260 | 261 |
Static2D dv; |
| 261 |
int len = di2D.getNumPoints();
|
|
| 262 |
int len = di3D.getNumPoints();
|
|
| 262 | 263 |
|
| 263 | 264 |
for(int g=0; g<len; g++) |
| 264 | 265 |
{
|
| 265 |
dv = di2D.getPoint(g);
|
|
| 266 |
dv = di3D.getPoint(g);
|
|
| 266 | 267 |
gx = dv.getX(); |
| 267 | 268 |
gy = dv.getY(); |
| 268 | 269 |
|
| ... | ... | |
| 276 | 277 |
{
|
| 277 | 278 |
synchronized(lock) |
| 278 | 279 |
{
|
| 279 |
di2D.add(new Static2D(xDown,yDown));
|
|
| 280 |
di3D.add(new Static3D(xDown,yDown,0));
|
|
| 280 | 281 |
mRegion.add(new Static4D(xDown,yDown,mSizeR,mSizeR)); |
| 281 | 282 |
} |
| 282 | 283 |
} |
| ... | ... | |
| 286 | 287 |
xDown = (int)event.getX(); |
| 287 | 288 |
yDown = (int)event.getY(); |
| 288 | 289 |
|
| 289 |
di2D.setPoint(moving, xDown, yDown);
|
|
| 290 |
di3D.setPoint(moving, xDown, yDown, 0);
|
|
| 290 | 291 |
mRegion.setPoint(moving, xDown, yDown, mSizeR, mSizeR); |
| 291 | 292 |
} |
| 292 | 293 |
break; |
| src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
|---|---|---|
| 63 | 63 |
private DistortedBitmap monaLisa; |
| 64 | 64 |
private int bmpHeight, bmpWidth; |
| 65 | 65 |
|
| 66 |
private Static2D pLeft, pRight;
|
|
| 66 |
private Static3D pLeft, pRight;
|
|
| 67 | 67 |
private Static4D rLeft, rRight; |
| 68 | 68 |
|
| 69 | 69 |
private Dynamic3D dLeft, dRight; |
| ... | ... | |
| 77 | 77 |
mSurfaceHolder = holder; |
| 78 | 78 |
mView = view; |
| 79 | 79 |
|
| 80 |
pLeft = new Static2D( 90, 258);
|
|
| 81 |
pRight= new Static2D(176, 255);
|
|
| 80 |
pLeft = new Static3D( 90, 258, 0);
|
|
| 81 |
pRight= new Static3D(176, 255, 0);
|
|
| 82 | 82 |
|
| 83 | 83 |
rLeft = new Static4D(-10,-10,25,25); |
| 84 | 84 |
rRight= new Static4D( 10, -5,25,25); |
| src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
|---|---|---|
| 51 | 51 |
{
|
| 52 | 52 |
private GLSurfaceView mView; |
| 53 | 53 |
private DistortedBitmap mGirl; |
| 54 |
private Static2D pLeft, pRight;
|
|
| 54 |
private Static3D pLeft, pRight;
|
|
| 55 | 55 |
private Static4D sinkRegion; |
| 56 | 56 |
private Dynamic1D diSink; |
| 57 | 57 |
private Static1D s0; |
| ... | ... | |
| 70 | 70 |
|
| 71 | 71 |
boobsSink = 1.0f; |
| 72 | 72 |
|
| 73 |
pLeft = new Static2D(132, 264);
|
|
| 74 |
pRight= new Static2D(247, 264);
|
|
| 73 |
pLeft = new Static3D(132, 264, 0);
|
|
| 74 |
pRight= new Static3D(247, 264, 0);
|
|
| 75 | 75 |
|
| 76 | 76 |
sinkRegion = new Static4D(0,0,60,60); |
| 77 | 77 |
|
| src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
|---|---|---|
| 47 | 47 |
{
|
| 48 | 48 |
private GLSurfaceView mView; |
| 49 | 49 |
private DistortedBitmap sinkBmp; |
| 50 |
private Static2D pLeft, pRight;
|
|
| 50 |
private Static3D pLeft, pRight;
|
|
| 51 | 51 |
private Static4D Region; |
| 52 | 52 |
private int bmpHeight, bmpWidth; |
| 53 | 53 |
|
| ... | ... | |
| 57 | 57 |
{
|
| 58 | 58 |
mView = v; |
| 59 | 59 |
|
| 60 |
pLeft = new Static2D(214, 206);
|
|
| 61 |
pRight= new Static2D(390, 212);
|
|
| 60 |
pLeft = new Static3D(214, 206, 0);
|
|
| 61 |
pRight= new Static3D(390, 212, 0);
|
|
| 62 | 62 |
Region= new Static4D(0,0,60,60); |
| 63 | 63 |
} |
| 64 | 64 |
|
| src/main/res/layout/effectcenter.xml | ||
|---|---|---|
| 26 | 26 |
android:layout_marginEnd="5dp" |
| 27 | 27 |
android:layout_marginLeft="5dp" |
| 28 | 28 |
android:layout_marginRight="5dp" |
| 29 |
android:layout_weight="0.5"/>
|
|
| 29 |
android:layout_weight="1.0"/>
|
|
| 30 | 30 |
|
| 31 | 31 |
<SeekBar |
| 32 | 32 |
android:id="@+id/effectCenterBarY" |
| ... | ... | |
| 35 | 35 |
android:layout_marginEnd="5dp" |
| 36 | 36 |
android:layout_marginLeft="5dp" |
| 37 | 37 |
android:layout_marginRight="5dp" |
| 38 |
android:layout_weight="0.5"/>
|
|
| 38 |
android:layout_weight="1.0"/>
|
|
| 39 | 39 |
|
| 40 |
<SeekBar |
|
| 41 |
android:id="@+id/effectCenterBarZ" |
|
| 42 |
android:layout_width="wrap_content" |
|
| 43 |
android:layout_height="wrap_content" |
|
| 44 |
android:layout_marginEnd="5dp" |
|
| 45 |
android:layout_marginLeft="5dp" |
|
| 46 |
android:layout_marginRight="5dp" |
|
| 47 |
android:layout_weight="1.0"/> |
|
| 40 | 48 |
</LinearLayout> |
| 41 | 49 |
|
| 42 | 50 |
</LinearLayout> |
Also available in: Unified diff
Make the effect Center be always 3D.