Revision 348dbeea
Added by Leszek Koltunski about 7 years ago
| src/main/AndroidManifest.xml | ||
|---|---|---|
| 36 | 36 |
<activity android:name=".quaternion.QuaternionActivity" /> |
| 37 | 37 |
<activity android:name=".matrix3d.Matrix3DActivity" /> |
| 38 | 38 |
<activity android:name=".effects3d.Effects3DActivity" /> |
| 39 |
<activity android:name=".effects3d.Effects3DActivity2" /> |
|
| 39 | 40 |
<activity android:name=".plainmonalisa.PlainMonaLisaActivity" /> |
| 40 | 41 |
<activity android:name=".save.SaveActivity"/> |
| 41 | 42 |
<activity android:name=".flag.FlagActivity"/> |
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java | ||
|---|---|---|
| 20 | 20 |
package org.distorted.examples.effects3d; |
| 21 | 21 |
|
| 22 | 22 |
import android.app.Activity; |
| 23 |
import android.graphics.Bitmap; |
|
| 24 |
import android.graphics.BitmapFactory; |
|
| 25 |
import android.graphics.Canvas; |
|
| 26 |
import android.graphics.Paint; |
|
| 27 |
import android.opengl.GLSurfaceView; |
|
| 23 |
import android.content.Intent; |
|
| 28 | 24 |
import android.os.Bundle; |
| 29 |
import android.support.design.widget.TabLayout; |
|
| 30 |
import android.support.v4.view.ViewPager; |
|
| 31 | 25 |
import android.view.Gravity; |
| 32 | 26 |
import android.view.View; |
| 33 | 27 |
import android.widget.AdapterView; |
| 34 | 28 |
import android.widget.ArrayAdapter; |
| 35 | 29 |
import android.widget.Button; |
| 36 |
import android.widget.CheckBox; |
|
| 37 | 30 |
import android.widget.LinearLayout; |
| 38 | 31 |
import android.widget.NumberPicker; |
| 39 | 32 |
import android.widget.Spinner; |
| 40 | 33 |
import android.widget.TableRow; |
| 41 | 34 |
|
| 42 | 35 |
import org.distorted.examples.R; |
| 43 |
import org.distorted.library.effect.EffectType; |
|
| 44 |
import org.distorted.library.main.Distorted; |
|
| 45 |
import org.distorted.library.main.MeshCubes; |
|
| 46 |
import org.distorted.library.main.MeshFlat; |
|
| 47 |
import org.distorted.library.main.MeshObject; |
|
| 48 |
import org.distorted.library.main.DistortedTexture; |
|
| 49 |
import org.distorted.library.main.DistortedEffects; |
|
| 50 |
|
|
| 51 |
import java.io.IOException; |
|
| 52 |
import java.io.InputStream; |
|
| 53 | 36 |
|
| 54 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 | 38 |
|
| ... | ... | |
| 66 | 49 |
private boolean mGridInitialized; |
| 67 | 50 |
private NumberPicker mColsPicker, mRowsPicker, mSlicPicker; |
| 68 | 51 |
private boolean[] mShape; |
| 69 |
private DistortedTexture mTexture; |
|
| 70 |
private MeshObject mMesh; |
|
| 71 | 52 |
private int mObjectType; |
| 72 | 53 |
private int mBitmapID; |
| 73 |
private Bitmap mBitmap; |
|
| 74 | 54 |
private LinearLayout mLay; |
| 75 | 55 |
|
| 76 |
private float mCenterX, mCenterY, mCenterZ; |
|
| 77 |
private float mRegionX, mRegionY, mRegionR; |
|
| 78 |
private DistortedEffects mEffects; |
|
| 79 |
private ViewPager mViewPager; |
|
| 80 |
private Effects3DTabViewPager mPager; |
|
| 81 |
|
|
| 82 |
private static boolean mShowCenter = true; |
|
| 83 |
private static boolean mShowRegion = true; |
|
| 84 |
private static boolean mShowNormal = true; |
|
| 85 |
private static boolean mUseOIT = false; |
|
| 86 |
|
|
| 87 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 88 | 57 |
|
| 89 | 58 |
@Override |
| ... | ... | |
| 205 | 174 |
} |
| 206 | 175 |
} |
| 207 | 176 |
|
| 208 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 209 |
|
|
| 210 |
public DistortedTexture getTexture() |
|
| 211 |
{
|
|
| 212 |
return mTexture; |
|
| 213 |
} |
|
| 214 |
|
|
| 215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 216 |
|
|
| 217 |
public MeshObject getMesh() |
|
| 218 |
{
|
|
| 219 |
return mMesh; |
|
| 220 |
} |
|
| 221 |
|
|
| 222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 223 |
|
|
| 224 |
public Bitmap getBitmap() |
|
| 225 |
{
|
|
| 226 |
if( mBitmap==null ) |
|
| 227 |
{
|
|
| 228 |
if( mBitmapID!=-1) |
|
| 229 |
{
|
|
| 230 |
InputStream is = getResources().openRawResource(mBitmapID); |
|
| 231 |
|
|
| 232 |
try |
|
| 233 |
{
|
|
| 234 |
mBitmap = BitmapFactory.decodeStream(is); |
|
| 235 |
} |
|
| 236 |
finally |
|
| 237 |
{
|
|
| 238 |
try |
|
| 239 |
{
|
|
| 240 |
is.close(); |
|
| 241 |
} |
|
| 242 |
catch(IOException e) { }
|
|
| 243 |
} |
|
| 244 |
} |
|
| 245 |
else |
|
| 246 |
{
|
|
| 247 |
final int W = 64*mNumCols; |
|
| 248 |
final int H = 64*mNumRows; |
|
| 249 |
|
|
| 250 |
Paint paint = new Paint(); |
|
| 251 |
mBitmap = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888); |
|
| 252 |
Canvas canvas = new Canvas(mBitmap); |
|
| 253 |
|
|
| 254 |
paint.setAntiAlias(true); |
|
| 255 |
paint.setTextAlign(Paint.Align.CENTER); |
|
| 256 |
paint.setColor(0xff008800); |
|
| 257 |
paint.setStyle(Paint.Style.FILL); |
|
| 258 |
canvas.drawRect(0, 0, W, H, paint); |
|
| 259 |
paint.setColor(0xffffffff); |
|
| 260 |
|
|
| 261 |
for(int i=0; i<=mNumCols ; i++ ) canvas.drawRect(W*i/mNumCols-1, 0, W*i/mNumCols + 1, H, paint); |
|
| 262 |
for(int i=0; i<=mNumRows ; i++ ) canvas.drawRect( 0, H*i/mNumRows-1, W, H*i/mNumRows+1, paint); |
|
| 263 |
} |
|
| 264 |
} |
|
| 265 |
|
|
| 266 |
return mBitmap; |
|
| 267 |
} |
|
| 268 |
|
|
| 269 | 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 270 | 178 |
|
| 271 | 179 |
public void onClick(View view) |
| ... | ... | |
| 299 | 207 |
} |
| 300 | 208 |
} |
| 301 | 209 |
|
| 302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 303 |
|
|
| 304 |
public void setRegion(float x, float y, float r) |
|
| 305 |
{
|
|
| 306 |
mRegionX = x; |
|
| 307 |
mRegionY =-y; |
|
| 308 |
mRegionR = r; |
|
| 309 |
|
|
| 310 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 311 |
view.getRenderer().setRegion(mRegionX, mRegionY, mRegionR); |
|
| 312 |
} |
|
| 313 |
|
|
| 314 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 315 |
|
|
| 316 |
public void setCenter(float x, float y, float z) |
|
| 317 |
{
|
|
| 318 |
mCenterX = x; |
|
| 319 |
mCenterY = y; |
|
| 320 |
mCenterZ = z; |
|
| 321 |
|
|
| 322 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 323 |
view.getRenderer().setCenter( mCenterX, mCenterY, mCenterZ ); |
|
| 324 |
} |
|
| 325 |
|
|
| 326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 327 |
|
|
| 328 |
public float getCenterX() |
|
| 329 |
{
|
|
| 330 |
return mCenterX; |
|
| 331 |
} |
|
| 332 |
|
|
| 333 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 334 |
|
|
| 335 |
public float getCenterY() |
|
| 336 |
{
|
|
| 337 |
return mCenterY; |
|
| 338 |
} |
|
| 339 |
|
|
| 340 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 341 |
|
|
| 342 |
public float getCenterZ() |
|
| 343 |
{
|
|
| 344 |
return mCenterZ; |
|
| 345 |
} |
|
| 346 |
|
|
| 347 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 348 |
|
|
| 349 |
public float getRegionX() |
|
| 350 |
{
|
|
| 351 |
return mRegionX; |
|
| 352 |
} |
|
| 353 |
|
|
| 354 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 355 |
|
|
| 356 |
public float getRegionY() |
|
| 357 |
{
|
|
| 358 |
return mRegionY; |
|
| 359 |
} |
|
| 360 |
|
|
| 361 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 362 |
|
|
| 363 |
public float getRegionR() |
|
| 364 |
{
|
|
| 365 |
return mRegionR; |
|
| 366 |
} |
|
| 367 |
|
|
| 368 | 210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 369 | 211 |
|
| 370 | 212 |
public void Create(View v) |
| 371 | 213 |
{
|
| 372 |
DistortedEffects.setMax(EffectType.VERTEX ,20); // those have to be called before |
|
| 373 |
DistortedEffects.setMax(EffectType.FRAGMENT,3); // any DistortedEffect get created! |
|
| 214 |
Intent mainInt = new Intent( getApplicationContext(), Effects3DActivity2.class); |
|
| 215 |
Bundle b = new Bundle(); |
|
| 216 |
|
|
| 217 |
b.putInt("type", mObjectType);
|
|
| 218 |
b.putInt("cols", mNumCols);
|
|
| 219 |
b.putInt("rows", mNumRows);
|
|
| 220 |
b.putInt("slices", mNumSlic);
|
|
| 221 |
b.putInt("bitmap", mBitmapID);
|
|
| 374 | 222 |
|
| 375 | 223 |
if( mObjectType==1 ) |
| 376 | 224 |
{
|
| 377 |
mMesh = new MeshFlat(mNumCols,mNumRows);
|
|
| 225 |
b.putString("string", "");
|
|
| 378 | 226 |
} |
| 379 | 227 |
else |
| 380 | 228 |
{
|
| ... | ... | |
| 383 | 231 |
for(int i=0; i<mNumRows*mNumCols; i++) |
| 384 | 232 |
str += mShape[i] ? "1" : "0"; |
| 385 | 233 |
|
| 386 |
mMesh = new MeshCubes(mNumCols, str, mNumSlic);
|
|
| 234 |
b.putString("string", str);
|
|
| 387 | 235 |
} |
| 388 | 236 |
|
| 389 |
mMesh.setShowNormals(mShowNormal); |
|
| 390 |
mTexture= new DistortedTexture(mNumCols,mNumRows); |
|
| 391 |
mEffects= new DistortedEffects(); |
|
| 392 |
|
|
| 393 |
final View view = getLayoutInflater().inflate(R.layout.effects3dlayout, null); |
|
| 394 |
|
|
| 395 |
setContentView(view); |
|
| 396 |
|
|
| 397 |
mViewPager = findViewById(R.id.effects3d_viewpager); |
|
| 398 |
mViewPager.setOffscreenPageLimit(2); |
|
| 399 |
mPager = new Effects3DTabViewPager(this, getFragmentManager() ); |
|
| 400 |
mViewPager.setAdapter(mPager); |
|
| 401 |
TabLayout tabLayout = findViewById(R.id.effects3d_sliding_tabs); |
|
| 402 |
tabLayout.setupWithViewPager(mViewPager); |
|
| 403 |
|
|
| 404 |
resetData(); |
|
| 237 |
mainInt.putExtras(b); |
|
| 238 |
startActivity(mainInt); |
|
| 405 | 239 |
} |
| 406 | 240 |
|
| 407 | 241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 436 | 270 |
{
|
| 437 | 271 |
} |
| 438 | 272 |
|
| 439 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 440 |
|
|
| 441 |
public int getWidth() |
|
| 442 |
{
|
|
| 443 |
return mTexture==null ? 0: mTexture.getWidth(); |
|
| 444 |
} |
|
| 445 |
|
|
| 446 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 447 |
|
|
| 448 |
public int getHeight() |
|
| 449 |
{
|
|
| 450 |
return mTexture==null ? 0: mTexture.getHeight(); |
|
| 451 |
} |
|
| 452 |
|
|
| 453 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 454 |
|
|
| 455 |
public int getDepth() |
|
| 456 |
{
|
|
| 457 |
return mTexture==null ? 0: mTexture.getDepth(mMesh); |
|
| 458 |
} |
|
| 459 |
|
|
| 460 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 461 |
|
|
| 462 |
public int getScreenWidth() |
|
| 463 |
{
|
|
| 464 |
return 0; |
|
| 465 |
} |
|
| 466 |
|
|
| 467 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 468 |
|
|
| 469 |
void resetData() |
|
| 470 |
{
|
|
| 471 |
mCenterX = 0.5f*getWidth(); |
|
| 472 |
mCenterY = 0.5f*getHeight(); |
|
| 473 |
mRegionX = 0; |
|
| 474 |
mRegionY = 0; |
|
| 475 |
mRegionR = getWidth()/2; |
|
| 476 |
|
|
| 477 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 478 |
Effects3DRenderer renderer= view.getRenderer(); |
|
| 479 |
|
|
| 480 |
renderer.setCenter( mCenterX, mCenterY, mCenterZ ); |
|
| 481 |
renderer.setRegion( mRegionX, mRegionY, mRegionR ); |
|
| 482 |
renderer.mQuat1.set(0,0,0,1); |
|
| 483 |
renderer.mQuat2.set(0,0,0,1); |
|
| 484 |
} |
|
| 485 |
|
|
| 486 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 487 |
// 'second screen' methods |
|
| 488 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 489 |
|
|
| 490 |
public DistortedEffects getEffects() |
|
| 491 |
{
|
|
| 492 |
return mEffects; |
|
| 493 |
} |
|
| 494 |
|
|
| 495 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 496 |
|
|
| 497 |
public void newEffect(View v) |
|
| 498 |
{
|
|
| 499 |
mPager.newEffect(v,mViewPager.getCurrentItem()); |
|
| 500 |
} |
|
| 501 |
|
|
| 502 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 503 |
|
|
| 504 |
public void removeAll(View v) |
|
| 505 |
{
|
|
| 506 |
mPager.removeAll(v,mViewPager.getCurrentItem()); |
|
| 507 |
} |
|
| 508 |
|
|
| 509 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 510 |
|
|
| 511 |
public void remove(View v) |
|
| 512 |
{
|
|
| 513 |
mPager.remove(v,mViewPager.getCurrentItem()); |
|
| 514 |
} |
|
| 515 |
|
|
| 516 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 517 |
|
|
| 518 |
boolean getShowCenter() |
|
| 519 |
{
|
|
| 520 |
return mShowCenter; |
|
| 521 |
} |
|
| 522 |
|
|
| 523 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 524 |
|
|
| 525 |
boolean getShowRegion() |
|
| 526 |
{
|
|
| 527 |
return mShowRegion; |
|
| 528 |
} |
|
| 529 |
|
|
| 530 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 531 |
|
|
| 532 |
public void showCenter(View view) |
|
| 533 |
{
|
|
| 534 |
CheckBox box = (CheckBox)view; |
|
| 535 |
mShowCenter = box.isChecked(); |
|
| 536 |
|
|
| 537 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 538 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
| 539 |
} |
|
| 540 |
|
|
| 541 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 542 |
|
|
| 543 |
public void showRegion(View view) |
|
| 544 |
{
|
|
| 545 |
CheckBox box = (CheckBox)view; |
|
| 546 |
mShowRegion = box.isChecked(); |
|
| 547 |
|
|
| 548 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 549 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
| 550 |
} |
|
| 551 |
|
|
| 552 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 553 |
|
|
| 554 |
public void showNormal(View view) |
|
| 555 |
{
|
|
| 556 |
CheckBox box = (CheckBox)view; |
|
| 557 |
mShowNormal = box.isChecked(); |
|
| 558 |
|
|
| 559 |
if ( mMesh!=null ) |
|
| 560 |
{
|
|
| 561 |
mMesh.setShowNormals(mShowNormal); |
|
| 562 |
} |
|
| 563 |
} |
|
| 564 |
|
|
| 565 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 566 |
|
|
| 567 |
public void triggerOIT(View view) |
|
| 568 |
{
|
|
| 569 |
CheckBox box = (CheckBox)view; |
|
| 570 |
mUseOIT = box.isChecked(); |
|
| 571 |
|
|
| 572 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 573 |
sv.getRenderer().useOIT(mUseOIT); |
|
| 574 |
} |
|
| 575 |
|
|
| 576 | 273 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 577 | 274 |
// Overrides |
| 578 | 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 579 | 276 |
|
| 580 |
@Override |
|
| 581 |
protected void onPause() |
|
| 582 |
{
|
|
| 583 |
GLSurfaceView mView = findViewById(R.id.effects3dSurfaceView); |
|
| 584 |
if( mView!=null ) mView.onPause(); |
|
| 585 |
|
|
| 586 |
Distorted.onPause(); |
|
| 587 |
super.onPause(); |
|
| 588 |
} |
|
| 589 |
|
|
| 590 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 591 |
|
|
| 592 |
@Override |
|
| 593 |
protected void onResume() |
|
| 594 |
{
|
|
| 595 |
super.onResume(); |
|
| 596 |
GLSurfaceView mView = findViewById(R.id.effects3dSurfaceView); |
|
| 597 |
if( mView!=null ) mView.onResume(); |
|
| 598 |
} |
|
| 599 |
|
|
| 600 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 601 |
|
|
| 602 | 277 |
@Override |
| 603 | 278 |
public void onWindowFocusChanged(boolean hasFocus) |
| 604 | 279 |
{
|
| ... | ... | |
| 610 | 285 |
|
| 611 | 286 |
if( !mGridInitialized ) setGrid(); |
| 612 | 287 |
} |
| 613 |
|
|
| 614 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 615 |
|
|
| 616 |
@Override |
|
| 617 |
protected void onDestroy() |
|
| 618 |
{
|
|
| 619 |
Distorted.onDestroy(); |
|
| 620 |
super.onDestroy(); |
|
| 621 |
} |
|
| 622 |
|
|
| 623 | 288 |
} |
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity2.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.effects3d; |
|
| 21 |
|
|
| 22 |
import android.app.Activity; |
|
| 23 |
import android.graphics.Bitmap; |
|
| 24 |
import android.graphics.BitmapFactory; |
|
| 25 |
import android.graphics.Canvas; |
|
| 26 |
import android.graphics.Paint; |
|
| 27 |
import android.opengl.GLSurfaceView; |
|
| 28 |
import android.os.Bundle; |
|
| 29 |
import android.support.design.widget.TabLayout; |
|
| 30 |
import android.support.v4.view.ViewPager; |
|
| 31 |
import android.view.View; |
|
| 32 |
import android.widget.CheckBox; |
|
| 33 |
|
|
| 34 |
import org.distorted.examples.R; |
|
| 35 |
import org.distorted.library.effect.EffectType; |
|
| 36 |
import org.distorted.library.main.Distorted; |
|
| 37 |
import org.distorted.library.main.DistortedEffects; |
|
| 38 |
import org.distorted.library.main.DistortedTexture; |
|
| 39 |
import org.distorted.library.main.MeshCubes; |
|
| 40 |
import org.distorted.library.main.MeshFlat; |
|
| 41 |
import org.distorted.library.main.MeshObject; |
|
| 42 |
|
|
| 43 |
import java.io.IOException; |
|
| 44 |
import java.io.InputStream; |
|
| 45 |
|
|
| 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 47 |
|
|
| 48 |
public class Effects3DActivity2 extends Activity |
|
| 49 |
{
|
|
| 50 |
private int mNumCols; |
|
| 51 |
private int mNumRows; |
|
| 52 |
private int mNumSlic; |
|
| 53 |
private int mObjectType; |
|
| 54 |
private int mBitmapID; |
|
| 55 |
private String mString; |
|
| 56 |
|
|
| 57 |
private DistortedTexture mTexture; |
|
| 58 |
private MeshObject mMesh; |
|
| 59 |
private Bitmap mBitmap; |
|
| 60 |
|
|
| 61 |
private float mCenterX, mCenterY, mCenterZ; |
|
| 62 |
private float mRegionX, mRegionY, mRegionR; |
|
| 63 |
private DistortedEffects mEffects; |
|
| 64 |
private ViewPager mViewPager; |
|
| 65 |
private Effects3DTabViewPager mPager; |
|
| 66 |
|
|
| 67 |
private static boolean mShowCenter = true; |
|
| 68 |
private static boolean mShowRegion = true; |
|
| 69 |
private static boolean mShowNormal = true; |
|
| 70 |
private static boolean mUseOIT = false; |
|
| 71 |
|
|
| 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 73 |
|
|
| 74 |
@Override |
|
| 75 |
protected void onCreate(Bundle savedState) |
|
| 76 |
{
|
|
| 77 |
super.onCreate(savedState); |
|
| 78 |
|
|
| 79 |
Bundle b = getIntent().getExtras(); |
|
| 80 |
|
|
| 81 |
mObjectType = b.getInt("type");
|
|
| 82 |
mNumCols = b.getInt("cols");
|
|
| 83 |
mNumRows = b.getInt("rows");
|
|
| 84 |
mNumSlic = b.getInt("slices");
|
|
| 85 |
mBitmapID = b.getInt("bitmap");
|
|
| 86 |
mString = b.getString("string");
|
|
| 87 |
|
|
| 88 |
DistortedEffects.setMax(EffectType.VERTEX ,20); // those have to be called before |
|
| 89 |
DistortedEffects.setMax(EffectType.FRAGMENT,3); // any DistortedEffect get created! |
|
| 90 |
|
|
| 91 |
if( mObjectType==1 ) mMesh = new MeshFlat(mNumCols,mNumRows); |
|
| 92 |
else mMesh = new MeshCubes(mNumCols, mString, mNumSlic); |
|
| 93 |
|
|
| 94 |
mMesh.setShowNormals(mShowNormal); |
|
| 95 |
mTexture= new DistortedTexture(mNumCols,mNumRows); |
|
| 96 |
mEffects= new DistortedEffects(); |
|
| 97 |
|
|
| 98 |
final View view = getLayoutInflater().inflate(R.layout.effects3dlayout, null); |
|
| 99 |
|
|
| 100 |
setContentView(view); |
|
| 101 |
|
|
| 102 |
mViewPager = findViewById(R.id.effects3d_viewpager); |
|
| 103 |
mViewPager.setOffscreenPageLimit(2); |
|
| 104 |
mPager = new Effects3DTabViewPager(this, getFragmentManager() ); |
|
| 105 |
mViewPager.setAdapter(mPager); |
|
| 106 |
TabLayout tabLayout = findViewById(R.id.effects3d_sliding_tabs); |
|
| 107 |
tabLayout.setupWithViewPager(mViewPager); |
|
| 108 |
|
|
| 109 |
resetData(); |
|
| 110 |
} |
|
| 111 |
|
|
| 112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 113 |
|
|
| 114 |
public DistortedTexture getTexture() |
|
| 115 |
{
|
|
| 116 |
return mTexture; |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 120 |
|
|
| 121 |
public MeshObject getMesh() |
|
| 122 |
{
|
|
| 123 |
return mMesh; |
|
| 124 |
} |
|
| 125 |
|
|
| 126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 127 |
|
|
| 128 |
public Bitmap getBitmap() |
|
| 129 |
{
|
|
| 130 |
if( mBitmap==null ) |
|
| 131 |
{
|
|
| 132 |
if( mBitmapID!=-1) |
|
| 133 |
{
|
|
| 134 |
InputStream is = getResources().openRawResource(mBitmapID); |
|
| 135 |
|
|
| 136 |
try |
|
| 137 |
{
|
|
| 138 |
mBitmap = BitmapFactory.decodeStream(is); |
|
| 139 |
} |
|
| 140 |
finally |
|
| 141 |
{
|
|
| 142 |
try |
|
| 143 |
{
|
|
| 144 |
is.close(); |
|
| 145 |
} |
|
| 146 |
catch(IOException e) { }
|
|
| 147 |
} |
|
| 148 |
} |
|
| 149 |
else |
|
| 150 |
{
|
|
| 151 |
final int W = 64*mNumCols; |
|
| 152 |
final int H = 64*mNumRows; |
|
| 153 |
|
|
| 154 |
Paint paint = new Paint(); |
|
| 155 |
mBitmap = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888); |
|
| 156 |
Canvas canvas = new Canvas(mBitmap); |
|
| 157 |
|
|
| 158 |
paint.setAntiAlias(true); |
|
| 159 |
paint.setTextAlign(Paint.Align.CENTER); |
|
| 160 |
paint.setColor(0xff008800); |
|
| 161 |
paint.setStyle(Paint.Style.FILL); |
|
| 162 |
canvas.drawRect(0, 0, W, H, paint); |
|
| 163 |
paint.setColor(0xffffffff); |
|
| 164 |
|
|
| 165 |
for(int i=0; i<=mNumCols ; i++ ) canvas.drawRect(W*i/mNumCols-1, 0, W*i/mNumCols + 1, H, paint); |
|
| 166 |
for(int i=0; i<=mNumRows ; i++ ) canvas.drawRect( 0, H*i/mNumRows-1, W, H*i/mNumRows+1, paint); |
|
| 167 |
} |
|
| 168 |
} |
|
| 169 |
|
|
| 170 |
return mBitmap; |
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 174 |
|
|
| 175 |
public void setRegion(float x, float y, float r) |
|
| 176 |
{
|
|
| 177 |
mRegionX = x; |
|
| 178 |
mRegionY =-y; |
|
| 179 |
mRegionR = r; |
|
| 180 |
|
|
| 181 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 182 |
view.getRenderer().setRegion(mRegionX, mRegionY, mRegionR); |
|
| 183 |
} |
|
| 184 |
|
|
| 185 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 186 |
|
|
| 187 |
public void setCenter(float x, float y, float z) |
|
| 188 |
{
|
|
| 189 |
mCenterX = x; |
|
| 190 |
mCenterY = y; |
|
| 191 |
mCenterZ = z; |
|
| 192 |
|
|
| 193 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 194 |
view.getRenderer().setCenter( mCenterX, mCenterY, mCenterZ ); |
|
| 195 |
} |
|
| 196 |
|
|
| 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 198 |
|
|
| 199 |
public float getCenterX() |
|
| 200 |
{
|
|
| 201 |
return mCenterX; |
|
| 202 |
} |
|
| 203 |
|
|
| 204 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 205 |
|
|
| 206 |
public float getCenterY() |
|
| 207 |
{
|
|
| 208 |
return mCenterY; |
|
| 209 |
} |
|
| 210 |
|
|
| 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 212 |
|
|
| 213 |
public float getCenterZ() |
|
| 214 |
{
|
|
| 215 |
return mCenterZ; |
|
| 216 |
} |
|
| 217 |
|
|
| 218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 219 |
|
|
| 220 |
public float getRegionX() |
|
| 221 |
{
|
|
| 222 |
return mRegionX; |
|
| 223 |
} |
|
| 224 |
|
|
| 225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 226 |
|
|
| 227 |
public float getRegionY() |
|
| 228 |
{
|
|
| 229 |
return mRegionY; |
|
| 230 |
} |
|
| 231 |
|
|
| 232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 233 |
|
|
| 234 |
public float getRegionR() |
|
| 235 |
{
|
|
| 236 |
return mRegionR; |
|
| 237 |
} |
|
| 238 |
|
|
| 239 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 240 |
|
|
| 241 |
public int getWidth() |
|
| 242 |
{
|
|
| 243 |
return mTexture==null ? 0: mTexture.getWidth(); |
|
| 244 |
} |
|
| 245 |
|
|
| 246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 247 |
|
|
| 248 |
public int getHeight() |
|
| 249 |
{
|
|
| 250 |
return mTexture==null ? 0: mTexture.getHeight(); |
|
| 251 |
} |
|
| 252 |
|
|
| 253 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 254 |
|
|
| 255 |
public int getDepth() |
|
| 256 |
{
|
|
| 257 |
return mTexture==null ? 0: mTexture.getDepth(mMesh); |
|
| 258 |
} |
|
| 259 |
|
|
| 260 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 261 |
|
|
| 262 |
public int getScreenWidth() |
|
| 263 |
{
|
|
| 264 |
return 0; |
|
| 265 |
} |
|
| 266 |
|
|
| 267 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 268 |
|
|
| 269 |
void resetData() |
|
| 270 |
{
|
|
| 271 |
mCenterX = 0.5f*getWidth(); |
|
| 272 |
mCenterY = 0.5f*getHeight(); |
|
| 273 |
mRegionX = 0; |
|
| 274 |
mRegionY = 0; |
|
| 275 |
mRegionR = getWidth()/2; |
|
| 276 |
|
|
| 277 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 278 |
Effects3DRenderer renderer= view.getRenderer(); |
|
| 279 |
|
|
| 280 |
renderer.setCenter( mCenterX, mCenterY, mCenterZ ); |
|
| 281 |
renderer.setRegion( mRegionX, mRegionY, mRegionR ); |
|
| 282 |
renderer.mQuat1.set(0,0,0,1); |
|
| 283 |
renderer.mQuat2.set(0,0,0,1); |
|
| 284 |
} |
|
| 285 |
|
|
| 286 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 287 |
// 'second screen' methods |
|
| 288 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 289 |
|
|
| 290 |
public DistortedEffects getEffects() |
|
| 291 |
{
|
|
| 292 |
return mEffects; |
|
| 293 |
} |
|
| 294 |
|
|
| 295 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 296 |
|
|
| 297 |
public void newEffect(View v) |
|
| 298 |
{
|
|
| 299 |
mPager.newEffect(v,mViewPager.getCurrentItem()); |
|
| 300 |
} |
|
| 301 |
|
|
| 302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 303 |
|
|
| 304 |
public void removeAll(View v) |
|
| 305 |
{
|
|
| 306 |
mPager.removeAll(v,mViewPager.getCurrentItem()); |
|
| 307 |
} |
|
| 308 |
|
|
| 309 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 310 |
|
|
| 311 |
public void remove(View v) |
|
| 312 |
{
|
|
| 313 |
mPager.remove(v,mViewPager.getCurrentItem()); |
|
| 314 |
} |
|
| 315 |
|
|
| 316 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 317 |
|
|
| 318 |
boolean getShowCenter() |
|
| 319 |
{
|
|
| 320 |
return mShowCenter; |
|
| 321 |
} |
|
| 322 |
|
|
| 323 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 324 |
|
|
| 325 |
boolean getShowRegion() |
|
| 326 |
{
|
|
| 327 |
return mShowRegion; |
|
| 328 |
} |
|
| 329 |
|
|
| 330 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 331 |
|
|
| 332 |
public void showCenter(View view) |
|
| 333 |
{
|
|
| 334 |
CheckBox box = (CheckBox)view; |
|
| 335 |
mShowCenter = box.isChecked(); |
|
| 336 |
|
|
| 337 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 338 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
| 339 |
} |
|
| 340 |
|
|
| 341 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 342 |
|
|
| 343 |
public void showRegion(View view) |
|
| 344 |
{
|
|
| 345 |
CheckBox box = (CheckBox)view; |
|
| 346 |
mShowRegion = box.isChecked(); |
|
| 347 |
|
|
| 348 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 349 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
| 350 |
} |
|
| 351 |
|
|
| 352 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 353 |
|
|
| 354 |
public void showNormal(View view) |
|
| 355 |
{
|
|
| 356 |
CheckBox box = (CheckBox)view; |
|
| 357 |
mShowNormal = box.isChecked(); |
|
| 358 |
|
|
| 359 |
if ( mMesh!=null ) |
|
| 360 |
{
|
|
| 361 |
mMesh.setShowNormals(mShowNormal); |
|
| 362 |
} |
|
| 363 |
} |
|
| 364 |
|
|
| 365 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 366 |
|
|
| 367 |
public void triggerOIT(View view) |
|
| 368 |
{
|
|
| 369 |
CheckBox box = (CheckBox)view; |
|
| 370 |
mUseOIT = box.isChecked(); |
|
| 371 |
|
|
| 372 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 373 |
sv.getRenderer().useOIT(mUseOIT); |
|
| 374 |
} |
|
| 375 |
|
|
| 376 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 377 |
// Overrides |
|
| 378 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 379 |
|
|
| 380 |
@Override |
|
| 381 |
protected void onPause() |
|
| 382 |
{
|
|
| 383 |
GLSurfaceView mView = findViewById(R.id.effects3dSurfaceView); |
|
| 384 |
if( mView!=null ) mView.onPause(); |
|
| 385 |
|
|
| 386 |
Distorted.onPause(); |
|
| 387 |
super.onPause(); |
|
| 388 |
} |
|
| 389 |
|
|
| 390 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 391 |
|
|
| 392 |
@Override |
|
| 393 |
protected void onResume() |
|
| 394 |
{
|
|
| 395 |
super.onResume(); |
|
| 396 |
GLSurfaceView mView = findViewById(R.id.effects3dSurfaceView); |
|
| 397 |
if( mView!=null ) mView.onResume(); |
|
| 398 |
} |
|
| 399 |
|
|
| 400 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 401 |
|
|
| 402 |
@Override |
|
| 403 |
protected void onDestroy() |
|
| 404 |
{
|
|
| 405 |
Distorted.onDestroy(); |
|
| 406 |
super.onDestroy(); |
|
| 407 |
} |
|
| 408 |
|
|
| 409 |
} |
|
| src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
|---|---|---|
| 61 | 61 |
|
| 62 | 62 |
class Effects3DEffect implements SeekBar.OnSeekBarChangeListener |
| 63 | 63 |
{
|
| 64 |
private WeakReference<Effects3DActivity> mAct; |
|
| 64 |
private WeakReference<Effects3DActivity2> mAct;
|
|
| 65 | 65 |
|
| 66 | 66 |
private EffectName mName; |
| 67 | 67 |
private int[] mInter; |
| ... | ... | |
| 285 | 285 |
|
| 286 | 286 |
private void fillCenterStatics() |
| 287 | 287 |
{
|
| 288 |
Effects3DActivity act = mAct.get(); |
|
| 288 |
Effects3DActivity2 act = mAct.get();
|
|
| 289 | 289 |
|
| 290 | 290 |
float x = (mInterCenter[0]*0.012f - 0.1f)*act.getWidth(); |
| 291 | 291 |
float y = (mInterCenter[1]*0.012f - 0.1f)*act.getHeight(); |
| ... | ... | |
| 318 | 318 |
|
| 319 | 319 |
private void fillRegionStatics() |
| 320 | 320 |
{
|
| 321 |
Effects3DActivity act = mAct.get(); |
|
| 321 |
Effects3DActivity2 act = mAct.get();
|
|
| 322 | 322 |
|
| 323 | 323 |
float factorX = act.getWidth() / 100.0f; |
| 324 | 324 |
float factorY = act.getHeight()/ 100.0f; |
| ... | ... | |
| 357 | 357 |
|
| 358 | 358 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 359 | 359 |
|
| 360 |
Effects3DEffect(EffectName name, Effects3DActivity act) |
|
| 360 |
Effects3DEffect(EffectName name, Effects3DActivity2 act)
|
|
| 361 | 361 |
{
|
| 362 | 362 |
mAct = new WeakReference<>(act); |
| 363 | 363 |
mName = name; |
| ... | ... | |
| 439 | 439 |
{
|
| 440 | 440 |
SeekBar[] seek = new SeekBar[mDimension]; |
| 441 | 441 |
|
| 442 |
Effects3DActivity act = mAct.get(); |
|
| 442 |
Effects3DActivity2 act = mAct.get();
|
|
| 443 | 443 |
|
| 444 | 444 |
switch(mDimension) |
| 445 | 445 |
{
|
| ... | ... | |
| 512 | 512 |
|
| 513 | 513 |
View createRegion() |
| 514 | 514 |
{
|
| 515 |
Effects3DActivity act = mAct.get(); |
|
| 515 |
Effects3DActivity2 act = mAct.get();
|
|
| 516 | 516 |
|
| 517 | 517 |
mRegion = act.getLayoutInflater().inflate(R.layout.effectregion, null); |
| 518 | 518 |
|
| ... | ... | |
| 547 | 547 |
|
| 548 | 548 |
View createCenter() |
| 549 | 549 |
{
|
| 550 |
Effects3DActivity act = mAct.get(); |
|
| 550 |
Effects3DActivity2 act = mAct.get();
|
|
| 551 | 551 |
|
| 552 | 552 |
mCenter = act.getLayoutInflater().inflate(R.layout.effectcenter, null); |
| 553 | 553 |
|
| ... | ... | |
| 657 | 657 |
|
| 658 | 658 |
if( fromUser ) |
| 659 | 659 |
{
|
| 660 |
Effects3DActivity act = mAct.get(); |
|
| 660 |
Effects3DActivity2 act = mAct.get();
|
|
| 661 | 661 |
|
| 662 | 662 |
boolean show = (mName.getType()==EffectType.VERTEX); |
| 663 | 663 |
boolean showR= (show && act.getShowRegion()); |
| src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
|---|---|---|
| 81 | 81 |
{
|
| 82 | 82 |
mView = v; |
| 83 | 83 |
|
| 84 |
Effects3DActivity act = (Effects3DActivity)v.getContext();
|
|
| 84 |
Effects3DActivity2 act = (Effects3DActivity2)v.getContext();
|
|
| 85 | 85 |
|
| 86 | 86 |
mRotateCen = new Static3D(0,0,0); |
| 87 | 87 |
mMoveObject = new Static3D(0,0,0); |
| ... | ... | |
| 230 | 230 |
factorCen = (0.08f*width)/centerSize; |
| 231 | 231 |
} |
| 232 | 232 |
|
| 233 |
Effects3DActivity act = (Effects3DActivity)mView.getContext();
|
|
| 233 |
Effects3DActivity2 act = (Effects3DActivity2)mView.getContext();
|
|
| 234 | 234 |
mCenterPoint.set(mFactorObj*act.getCenterX(),+mFactorObj*act.getCenterY(),0); |
| 235 | 235 |
mRegionPoint.set(mFactorObj*act.getRegionX(),-mFactorObj*act.getRegionY(),0); |
| 236 | 236 |
mFactorReg = 2*mFactorObj*act.getRegionR()/regionSize; |
| ... | ... | |
| 258 | 258 |
|
| 259 | 259 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
| 260 | 260 |
{
|
| 261 |
Effects3DActivity act = (Effects3DActivity)mView.getContext();
|
|
| 261 |
Effects3DActivity2 act = (Effects3DActivity2)mView.getContext();
|
|
| 262 | 262 |
|
| 263 | 263 |
InputStream isB = act.getResources().openRawResource(R.raw.water); |
| 264 | 264 |
InputStream isC = act.getResources().openRawResource(R.raw.center); |
| src/main/java/org/distorted/examples/effects3d/Effects3DTab.java | ||
|---|---|---|
| 86 | 86 |
break; |
| 87 | 87 |
} |
| 88 | 88 |
|
| 89 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
| 89 |
Effects3DActivity2 act = (Effects3DActivity2)getActivity();
|
|
| 90 | 90 |
mEffects = act.getEffects(); |
| 91 | 91 |
|
| 92 | 92 |
createEffectNames(mType); |
| ... | ... | |
| 122 | 122 |
|
| 123 | 123 |
android.util.Log.e("tab", "onResume, type="+mType.name());
|
| 124 | 124 |
|
| 125 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
| 125 |
Effects3DActivity2 act = (Effects3DActivity2)getActivity();
|
|
| 126 | 126 |
|
| 127 | 127 |
ArrayAdapter<String> adapterEffect = new ArrayAdapter<>( act, android.R.layout.simple_spinner_item, mEffectStrings); |
| 128 | 128 |
adapterEffect.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
| ... | ... | |
| 158 | 158 |
|
| 159 | 159 |
private void resetData() |
| 160 | 160 |
{
|
| 161 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
| 161 |
Effects3DActivity2 act = (Effects3DActivity2)getActivity();
|
|
| 162 | 162 |
Effects3DSurfaceView view = act.findViewById(R.id.effects3dSurfaceView); |
| 163 | 163 |
view.getRenderer().showRegionAndCenter(false,false); |
| 164 | 164 |
} |
| ... | ... | |
| 167 | 167 |
|
| 168 | 168 |
void newEffect() |
| 169 | 169 |
{
|
| 170 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
| 170 |
Effects3DActivity2 act = (Effects3DActivity2)getActivity();
|
|
| 171 | 171 |
Effects3DEffect eff = new Effects3DEffect(mEffectNames[mEffectAdd], act ); |
| 172 | 172 |
mList.add(eff); |
| 173 | 173 |
|
| ... | ... | |
| 223 | 223 |
|
| 224 | 224 |
void removeAll() |
| 225 | 225 |
{
|
| 226 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
| 226 |
Effects3DActivity2 act = (Effects3DActivity2)getActivity();
|
|
| 227 | 227 |
|
| 228 | 228 |
mList.clear(); |
| 229 | 229 |
LinearLayout layout = act.findViewById(mLayout); |
| ... | ... | |
| 242 | 242 |
{
|
| 243 | 243 |
if( effect.thisView(v) ) |
| 244 | 244 |
{
|
| 245 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
| 245 |
Effects3DActivity2 act = (Effects3DActivity2)getActivity();
|
|
| 246 | 246 |
LinearLayout layout = act.findViewById(mLayout); |
| 247 | 247 |
View view; |
| 248 | 248 |
|
| src/main/java/org/distorted/examples/effects3d/Effects3DTabViewPager.java | ||
|---|---|---|
| 35 | 35 |
{
|
| 36 | 36 |
private static final int NUM_TABS = 3; |
| 37 | 37 |
|
| 38 |
private WeakReference<Effects3DActivity> mAct; |
|
| 38 |
private WeakReference<Effects3DActivity2> mAct;
|
|
| 39 | 39 |
private Effects3DTab[] mTab; |
| 40 | 40 |
|
| 41 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 | 42 |
|
| 43 |
public Effects3DTabViewPager(Effects3DActivity act, FragmentManager fm) |
|
| 43 |
public Effects3DTabViewPager(Effects3DActivity2 act, FragmentManager fm)
|
|
| 44 | 44 |
{
|
| 45 | 45 |
super(fm); |
| 46 | 46 |
mAct = new WeakReference<>(act); |
Also available in: Unified diff
Split the Effects3D app into 2 activities