Revision 30f337e5
Added by Leszek Koltunski over 1 year ago
| src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java | ||
|---|---|---|
| 41 | 41 |
// WHITENESS |
| 42 | 42 |
// Vertex effects: |
| 43 | 43 |
// a) make the lips smaller (SINK) |
| 44 |
private Static4D wLipsRegion; |
|
| 45 |
private Static3D wLipsCenter; |
|
| 46 |
private Static1D wLipsFactor; |
|
| 47 |
private Dynamic1D wLipsDyn; |
|
| 44 |
private final Static4D wLipsRegion;
|
|
| 45 |
private final Static3D wLipsCenter;
|
|
| 46 |
private final Static1D wLipsFactor;
|
|
| 47 |
private final Dynamic1D wLipsDyn;
|
|
| 48 | 48 |
|
| 49 | 49 |
// ASIANNESS |
| 50 | 50 |
// Vertex Effects: |
| 51 | 51 |
// a) move lips & nose higher (DISTORT) |
| 52 |
private Static4D aLipsNoseRegion; |
|
| 53 |
private Static3D aLipsNoseCenter; |
|
| 54 |
private Static3D aLipsNoseFactor; |
|
| 55 |
private Dynamic3D aLipsNoseDyn; |
|
| 52 |
private final Static4D aLipsNoseRegion;
|
|
| 53 |
private final Static3D aLipsNoseCenter;
|
|
| 54 |
private final Static3D aLipsNoseFactor;
|
|
| 55 |
private final Dynamic3D aLipsNoseDyn;
|
|
| 56 | 56 |
// b) make the nose broader (PINCH) |
| 57 |
private Static4D aNoseBroaderRegion; |
|
| 58 |
private Static3D aNoseBroaderCenter; |
|
| 59 |
private Static3D aNoseBroaderFactor; |
|
| 60 |
private Dynamic3D aNoseBroaderDyn; |
|
| 57 |
private final Static4D aNoseBroaderRegion;
|
|
| 58 |
private final Static3D aNoseBroaderCenter;
|
|
| 59 |
private final Static3D aNoseBroaderFactor;
|
|
| 60 |
private final Dynamic3D aNoseBroaderDyn;
|
|
| 61 | 61 |
// c) make the nostrils more visible (DISTORT) |
| 62 |
private Static4D aNostrilsRegion; |
|
| 63 |
private Static3D aNostrilsCenter; |
|
| 64 |
private Static3D aNostrilsFactor; |
|
| 65 |
private Dynamic3D aNostrilsDyn; |
|
| 62 |
private final Static4D aNostrilsRegion;
|
|
| 63 |
private final Static3D aNostrilsCenter;
|
|
| 64 |
private final Static3D aNostrilsFactor;
|
|
| 65 |
private final Dynamic3D aNostrilsDyn;
|
|
| 66 | 66 |
// d) rotate eyes (2 x SWIRL) |
| 67 |
private Static4D aEyesRegion; |
|
| 68 |
private Static3D aLEyeCenter, aREyeCenter; |
|
| 69 |
private Static1D aLEyeFactor, aREyeFactor; |
|
| 70 |
private Dynamic1D aLEyeDyn, aREyeDyn; |
|
| 67 |
private final Static4D aEyesRegion;
|
|
| 68 |
private final Static3D aLEyeCenter, aREyeCenter;
|
|
| 69 |
private final Static1D aLEyeFactor, aREyeFactor;
|
|
| 70 |
private final Dynamic1D aLEyeDyn, aREyeDyn;
|
|
| 71 | 71 |
// e) move eyebrow higher (DISTORT) |
| 72 |
private Static4D aEyebrowsRegion; |
|
| 73 |
private Static3D aEyebrowsCenter; |
|
| 74 |
private Static3D aEyebrowsFactor; |
|
| 75 |
private Dynamic3D aEyebrowsDyn; |
|
| 72 |
private final Static4D aEyebrowsRegion;
|
|
| 73 |
private final Static3D aEyebrowsCenter;
|
|
| 74 |
private final Static3D aEyebrowsFactor;
|
|
| 75 |
private final Dynamic3D aEyebrowsDyn;
|
|
| 76 | 76 |
|
| 77 | 77 |
// Fragment effects: |
| 78 | 78 |
// a) change color of the skin to more brown and less red (CHROMA) |
| 79 |
private Static3D aSkinColorCenter; |
|
| 80 |
private Static3D aSkinColorRegion; |
|
| 81 |
private Static3D aChromaSkin; |
|
| 82 |
private Static1D aChromaSkinFactor; |
|
| 83 |
private Dynamic1D aChromaSkinDyn; |
|
| 79 |
private final Static3D aSkinColorCenter;
|
|
| 80 |
private final Static3D aSkinColorRegion;
|
|
| 81 |
private final Static3D aChromaSkin;
|
|
| 82 |
private final Static1D aChromaSkinFactor;
|
|
| 83 |
private final Dynamic1D aChromaSkinDyn;
|
|
| 84 | 84 |
// b) darken both eyes (2 x SMOOTH_CHROMA) |
| 85 |
private Static3D aLEyeColorCenter, aREyeColorCenter; |
|
| 86 |
private Static3D aLEyeColorRegion, aREyeColorRegion; |
|
| 87 |
private Static3D aChromaEyes; |
|
| 88 |
private Static1D aChromaEyesFactor; |
|
| 89 |
private Dynamic1D aChromaEyesDyn; |
|
| 85 |
private final Static3D aLEyeColorCenter, aREyeColorCenter;
|
|
| 86 |
private final Static3D aLEyeColorRegion, aREyeColorRegion;
|
|
| 87 |
private final Static3D aChromaEyes;
|
|
| 88 |
private final Static1D aChromaEyesFactor;
|
|
| 89 |
private final Dynamic1D aChromaEyesDyn;
|
|
| 90 | 90 |
|
| 91 | 91 |
// BLACKNESS |
| 92 | 92 |
// Vertex Effects |
| 93 | 93 |
// a) make the whole face broader (PINCH) |
| 94 |
private Static4D bFaceRegion; |
|
| 95 |
private Static3D bFaceCenter; |
|
| 96 |
private Static3D bFaceFactor; |
|
| 97 |
private Dynamic3D bFaceDyn; |
|
| 94 |
private final Static4D bFaceRegion;
|
|
| 95 |
private final Static3D bFaceCenter;
|
|
| 96 |
private final Static3D bFaceFactor;
|
|
| 97 |
private final Dynamic3D bFaceDyn;
|
|
| 98 | 98 |
// b) tip of the nose lower (DISTORT) |
| 99 |
private Static4D bTipLowerRegion; |
|
| 100 |
private Static3D bTipLowerCenter; |
|
| 101 |
private Static3D bTipLowerFactor; |
|
| 102 |
private Dynamic3D bTipLowerDyn; |
|
| 99 |
private final Static4D bTipLowerRegion;
|
|
| 100 |
private final Static3D bTipLowerCenter;
|
|
| 101 |
private final Static3D bTipLowerFactor;
|
|
| 102 |
private final Dynamic3D bTipLowerDyn;
|
|
| 103 | 103 |
// c) broaden the whole nose: (PINCH) |
| 104 |
private Static4D bWholeNoseRegion; |
|
| 105 |
private Static3D bWholeNoseCenter; |
|
| 106 |
private Static3D bWholeNoseFactor; |
|
| 107 |
private Dynamic3D bWholeNoseDyn; |
|
| 104 |
private final Static4D bWholeNoseRegion;
|
|
| 105 |
private final Static3D bWholeNoseCenter;
|
|
| 106 |
private final Static3D bWholeNoseFactor;
|
|
| 107 |
private final Dynamic3D bWholeNoseDyn;
|
|
| 108 | 108 |
// d) broaden the tip of the nose some more: (PINCH) |
| 109 |
private Static4D bNoseBroaderRegion; |
|
| 110 |
private Static3D bNoseBroaderCenter; |
|
| 111 |
private Static3D bNoseBroaderFactor; |
|
| 112 |
private Dynamic3D bNoseBroaderDyn; |
|
| 109 |
private final Static4D bNoseBroaderRegion;
|
|
| 110 |
private final Static3D bNoseBroaderCenter;
|
|
| 111 |
private final Static3D bNoseBroaderFactor;
|
|
| 112 |
private final Dynamic3D bNoseBroaderDyn;
|
|
| 113 | 113 |
// 3) make lips higher: (PINCH) |
| 114 |
private Static4D bLipsRegion; |
|
| 115 |
private Static3D bLipsCenter; |
|
| 116 |
private Static3D bLipsFactor; |
|
| 117 |
private Dynamic3D bLipsDyn; |
|
| 114 |
private final Static4D bLipsRegion;
|
|
| 115 |
private final Static3D bLipsCenter;
|
|
| 116 |
private final Static3D bLipsFactor;
|
|
| 117 |
private final Dynamic3D bLipsDyn;
|
|
| 118 | 118 |
// Fragment effects |
| 119 | 119 |
// a) make the whole face darker (CHROMA) |
| 120 |
private Static3D bSkinColorCenter; |
|
| 121 |
private Static3D bSkinColorRegion; |
|
| 122 |
private Static3D bChromaSkin; |
|
| 123 |
private Static1D bChromaSkinFactor; |
|
| 124 |
private Dynamic1D bChromaSkinDyn; |
|
| 120 |
private final Static3D bSkinColorCenter;
|
|
| 121 |
private final Static3D bSkinColorRegion;
|
|
| 122 |
private final Static3D bChromaSkin;
|
|
| 123 |
private final Static1D bChromaSkinFactor;
|
|
| 124 |
private final Dynamic1D bChromaSkinDyn;
|
|
| 125 | 125 |
// b) move both eyes back to whiteness (2 x SMOOTH CHROMA) |
| 126 |
private Static3D bLEyeColorCenter, bREyeColorCenter; |
|
| 127 |
private Static3D bLEyeColorRegion, bREyeColorRegion; |
|
| 128 |
private Static3D bChromaEyes; |
|
| 129 |
private Static1D bChromaEyesFactor; |
|
| 130 |
private Dynamic1D bChromaEyesDyn; |
|
| 126 |
private final Static3D bLEyeColorCenter, bREyeColorCenter;
|
|
| 127 |
private final Static3D bLEyeColorRegion, bREyeColorRegion;
|
|
| 128 |
private final Static3D bChromaEyes;
|
|
| 129 |
private final Static1D bChromaEyesFactor;
|
|
| 130 |
private final Dynamic1D bChromaEyesDyn;
|
|
| 131 | 131 |
// c) darken both pupils (2 x SMOOTH_CHROMA) |
| 132 |
private Static3D bLPupilColorCenter, bRPupilColorCenter; |
|
| 133 |
private Static3D bLPupilColorRegion, bRPupilColorRegion; |
|
| 134 |
private Static3D bChromaPupil; |
|
| 135 |
private Static1D bChromaPupilFactor; |
|
| 136 |
private Dynamic1D bChromaPupilDyn; |
|
| 132 |
private final Static3D bLPupilColorCenter, bRPupilColorCenter;
|
|
| 133 |
private final Static3D bLPupilColorRegion, bRPupilColorRegion;
|
|
| 134 |
private final Static3D bChromaPupil;
|
|
| 135 |
private final Static1D bChromaPupilFactor;
|
|
| 136 |
private final Dynamic1D bChromaPupilDyn;
|
|
| 137 | 137 |
// d) all those chroma effects have reduced contrast - bring it back |
| 138 |
private Static1D bContrastFactor; |
|
| 139 |
private Dynamic1D bContrastDyn; |
|
| 138 |
private final Static1D bContrastFactor;
|
|
| 139 |
private final Dynamic1D bContrastDyn;
|
|
| 140 | 140 |
|
| 141 | 141 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 142 | 142 |
|
| src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRendererPicker.java | ||
|---|---|---|
| 64 | 64 |
{
|
| 65 | 65 |
MatrixHelper.setIdentity(mModelMatrix); |
| 66 | 66 |
|
| 67 |
final float[] triangleVertData = {
|
|
| 67 |
final float[] triangleVertData = {
|
|
| 68 | 68 |
-0.865f, 1.5f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, // x,y,z, r,g,b,a |
| 69 |
-0.865f,-1.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, |
|
| 70 |
1.730f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f }; |
|
| 69 |
-0.865f,-1.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
|
|
| 70 |
1.730f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f };
|
|
| 71 | 71 |
|
| 72 |
mTriangleVert = ByteBuffer.allocateDirect(triangleVertData.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
|
| 73 |
mTriangleVert.put(triangleVertData).position(0); |
|
| 72 |
mTriangleVert = ByteBuffer.allocateDirect(triangleVertData.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
|
| 73 |
mTriangleVert.put(triangleVertData).position(0);
|
|
| 74 | 74 |
|
| 75 |
final float[] squareVertData = {
|
|
| 75 |
final float[] squareVertData = {
|
|
| 76 | 76 |
-0.15f, 0.15f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, |
| 77 |
-0.15f,-0.15f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, |
|
| 78 |
0.15f, 0.15f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, |
|
| 79 |
0.15f,-0.15f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f }; |
|
| 77 |
-0.15f,-0.15f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
|
|
| 78 |
0.15f, 0.15f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
|
|
| 79 |
0.15f,-0.15f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f };
|
|
| 80 | 80 |
|
| 81 |
mSquareVert = ByteBuffer.allocateDirect(squareVertData.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
|
| 82 |
mSquareVert.put(squareVertData).position(0); |
|
| 81 |
mSquareVert = ByteBuffer.allocateDirect(squareVertData.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
|
| 82 |
mSquareVert.put(squareVertData).position(0);
|
|
| 83 | 83 |
} |
| 84 | 84 |
|
| 85 | 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/blur/BlurRenderer.java | ||
|---|---|---|
| 110 | 110 |
|
| 111 | 111 |
int setHalo(int halo) |
| 112 | 112 |
{
|
| 113 |
int radius = halo; |
|
| 114 |
mHaloRadiusSta.set0(radius); |
|
| 115 |
return radius; |
|
| 113 |
mHaloRadiusSta.set0(halo); |
|
| 114 |
return halo; |
|
| 116 | 115 |
} |
| 117 | 116 |
|
| 118 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/deferredjob/DeferredJobRenderer.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.examples.deferredjob; |
| 21 | 21 |
|
| 22 |
import android.app.ActivityManager; |
|
| 23 |
import android.content.Context; |
|
| 24 |
import android.content.pm.ConfigurationInfo; |
|
| 25 | 22 |
import android.content.res.Resources; |
| 26 | 23 |
import android.graphics.Bitmap; |
| 27 | 24 |
import android.graphics.Canvas; |
| ... | ... | |
| 55 | 52 |
|
| 56 | 53 |
class DeferredJobRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser |
| 57 | 54 |
{
|
| 58 |
private final GLSurfaceView mView; |
|
| 59 | 55 |
private final Resources mResources; |
| 60 | 56 |
private final DistortedScreen mScreen; |
| 61 | 57 |
private final DistortedEffects mEffects; |
| ... | ... | |
| 74 | 70 |
|
| 75 | 71 |
DeferredJobRenderer(GLSurfaceView v) |
| 76 | 72 |
{
|
| 77 |
mView = v; |
|
| 78 | 73 |
mResources = v.getResources(); |
| 79 | 74 |
|
| 80 | 75 |
mScreen = new DistortedScreen(); |
| src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
|---|---|---|
| 40 | 40 |
import org.distorted.library.type.Static3D; |
| 41 | 41 |
import org.distorted.library.type.Static4D; |
| 42 | 42 |
|
| 43 |
import android.app.ActivityManager; |
|
| 44 |
import android.content.Context; |
|
| 45 |
import android.content.pm.ConfigurationInfo; |
|
| 46 | 43 |
import android.content.res.Resources; |
| 47 | 44 |
import android.graphics.Bitmap; |
| 48 | 45 |
import android.graphics.Canvas; |
| ... | ... | |
| 60 | 57 |
private static final int NUM_LINES = 10; |
| 61 | 58 |
private static final float QUOT = 0.6f; |
| 62 | 59 |
|
| 63 |
private final GLSurfaceView mView; |
|
| 64 | 60 |
private final Resources mResources; |
| 65 | 61 |
private final DistortedTexture mTexture; |
| 66 | 62 |
private final DistortedEffects mEffects; |
| ... | ... | |
| 83 | 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 84 | 80 |
|
| 85 | 81 |
DeformRenderer(GLSurfaceView view) |
| 86 |
{
|
|
| 87 |
mView = view; |
|
| 82 |
{
|
|
| 88 | 83 |
mResources = view.getResources(); |
| 89 | 84 |
|
| 90 | 85 |
mTexture = new DistortedTexture(); |
| src/main/java/org/distorted/examples/dynamic/DynamicSpeedSurfaceView.java | ||
|---|---|---|
| 41 | 41 |
private int mWidth, mHeight, mMargin; |
| 42 | 42 |
private int mMode, mNumRedPoints, mPointSize; |
| 43 | 43 |
private float mFontHeight; |
| 44 |
private Paint mPaint; |
|
| 45 |
private float[] mPoints = new float[NUM_POINTS]; |
|
| 44 |
private final Paint mPaint;
|
|
| 45 |
private final float[] mPoints = new float[NUM_POINTS];
|
|
| 46 | 46 |
private float mMultiplier; |
| 47 | 47 |
|
| 48 | 48 |
///////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/earth/EarthSurfaceViewPicker.java | ||
|---|---|---|
| 50 | 50 |
private GraphicsThread mThread; |
| 51 | 51 |
private EffectName mCurrentEffect; |
| 52 | 52 |
private ArrayList<Integer> mPointsX, mPointsY, mPointsE; |
| 53 |
private WeakReference<EarthActivity> mAct; |
|
| 53 |
private final WeakReference<EarthActivity> mAct;
|
|
| 54 | 54 |
private int mRadius; |
| 55 |
private Bitmap mBitmap; |
|
| 56 |
private Paint mPointPaint; |
|
| 57 |
private Rect mDst; |
|
| 55 |
private final Bitmap mBitmap;
|
|
| 56 |
private final Paint mPointPaint;
|
|
| 57 |
private final Rect mDst;
|
|
| 58 | 58 |
private int mWidth, mHeight; |
| 59 | 59 |
|
| 60 | 60 |
///////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 308 | 308 |
int action = event.getAction(); |
| 309 | 309 |
int x = (int)event.getX(); |
| 310 | 310 |
int y = (int)event.getY(); |
| 311 |
|
|
| 312 |
switch(action) |
|
| 313 |
{
|
|
| 314 |
case MotionEvent.ACTION_DOWN: addNewPoint(x,y); |
|
| 315 |
refreshScreen = true; |
|
| 316 |
break; |
|
| 317 |
} |
|
| 311 |
|
|
| 312 |
if (action == MotionEvent.ACTION_DOWN) {
|
|
| 313 |
addNewPoint(x, y); |
|
| 314 |
refreshScreen = true; |
|
| 315 |
} |
|
| 318 | 316 |
|
| 319 | 317 |
return true; |
| 320 | 318 |
} |
| src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java | ||
|---|---|---|
| 50 | 50 |
private int mCurrentEffect; |
| 51 | 51 |
private int mScrW, mScrH; |
| 52 | 52 |
|
| 53 |
private Dynamic1D mInterA, mInterB, mInterC, mInterS; |
|
| 54 |
private Dynamic3D mInterD; |
|
| 53 |
private final Dynamic1D mInterA; |
|
| 54 |
private final Dynamic1D mInterB; |
|
| 55 |
private final Dynamic1D mInterC; |
|
| 56 |
private final Dynamic1D mInterS; |
|
| 57 |
private final Dynamic3D mInterD; |
|
| 55 | 58 |
|
| 56 | 59 |
private final static Static3D RED = new Static3D(1,0,0); |
| 57 | 60 |
private final static Static3D REGION_F = new Static3D(RADIUS,RADIUS,RADIUS); |
| src/main/java/org/distorted/examples/flatblur/FlatBlurRenderer.java | ||
|---|---|---|
| 37 | 37 |
|
| 38 | 38 |
class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser |
| 39 | 39 |
{
|
| 40 |
private final GLSurfaceView mView; |
|
| 41 | 40 |
private final Resources mResources; |
| 42 | 41 |
private final DistortedScreen mScreen; |
| 43 | 42 |
|
| ... | ... | |
| 45 | 44 |
|
| 46 | 45 |
FlatBlurRenderer(GLSurfaceView v) |
| 47 | 46 |
{
|
| 48 |
mView = v; |
|
| 49 | 47 |
mResources = v.getResources(); |
| 50 | 48 |
mScreen = new DistortedScreen(); |
| 51 | 49 |
} |
| src/main/java/org/distorted/examples/flatblur2/FlatBlur2Renderer.java | ||
|---|---|---|
| 163 | 163 |
|
| 164 | 164 |
public void button1() |
| 165 | 165 |
{
|
| 166 |
/* |
|
| 167 |
OverlayStars stars = new OverlayStars(); |
|
| 168 |
Resources res = mView.getResources(); |
|
| 169 |
DataStars data = new DataStars(10,5,res); |
|
| 170 |
stars.startOverlay(mScreen,this,data); |
|
| 171 |
*/ |
|
| 172 |
|
|
| 173 | 166 |
mMove.set(0,mHeight*0.5f,0); |
| 174 | 167 |
} |
| 175 | 168 |
|
| src/main/java/org/distorted/examples/generic/GenericMeshList.java | ||
|---|---|---|
| 40 | 40 |
|
| 41 | 41 |
static final int LENGTH = values().length; |
| 42 | 42 |
private static final GenericMeshList[] meshes; |
| 43 |
private int mDimension; |
|
| 43 |
private final int mDimension;
|
|
| 44 | 44 |
|
| 45 | 45 |
static |
| 46 | 46 |
{
|
| src/main/java/org/distorted/examples/generic/GenericTab.java | ||
|---|---|---|
| 43 | 43 |
public class GenericTab extends Fragment implements AdapterView.OnItemSelectedListener, View.OnClickListener |
| 44 | 44 |
{
|
| 45 | 45 |
private EffectType mType; |
| 46 |
private ArrayList<GenericEffect> mList; |
|
| 46 |
private final ArrayList<GenericEffect> mList;
|
|
| 47 | 47 |
private int mEffectAdd; |
| 48 | 48 |
private EffectName[] mEffectNames; |
| 49 | 49 |
private DistortedEffects mEffects; |
| src/main/java/org/distorted/examples/generic/GenericViewPager.java | ||
|---|---|---|
| 50 | 50 |
|
| 51 | 51 |
private static final int NUM_TABS = TABS.length; |
| 52 | 52 |
|
| 53 |
private ViewPager mViewPager; |
|
| 53 |
private final ViewPager mViewPager;
|
|
| 54 | 54 |
private int mCurrentTab; |
| 55 | 55 |
|
| 56 | 56 |
private static class GenericTabViewPager extends FragmentPagerAdapter |
| src/main/java/org/distorted/examples/inflate/InflateMeshList.java | ||
|---|---|---|
| 40 | 40 |
|
| 41 | 41 |
static final int LENGTH = values().length; |
| 42 | 42 |
private static final InflateMeshList[] meshes; |
| 43 |
private int mDimension; |
|
| 43 |
private final int mDimension;
|
|
| 44 | 44 |
|
| 45 | 45 |
static |
| 46 | 46 |
{
|
| src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
|---|---|---|
| 40 | 40 |
import org.distorted.library.type.Static4D; |
| 41 | 41 |
import org.distorted.library.message.EffectListener; |
| 42 | 42 |
|
| 43 |
import android.app.ActivityManager; |
|
| 44 |
import android.content.Context; |
|
| 45 |
import android.content.pm.ConfigurationInfo; |
|
| 46 | 43 |
import android.content.res.Resources; |
| 47 | 44 |
import android.graphics.Bitmap; |
| 48 | 45 |
import android.graphics.BitmapFactory; |
| src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java | ||
|---|---|---|
| 48 | 48 |
|
| 49 | 49 |
private LinearLayout mLayout; |
| 50 | 50 |
private int mResource; |
| 51 |
private String[] mNames = new String[] { "triangle" ,
|
|
| 51 |
private final String[] mNames = new String[] |
|
| 52 |
{ "triangle" ,
|
|
| 52 | 53 |
"procedural" , |
| 53 | 54 |
"polygon" , |
| 54 | 55 |
"multigon" , |
| src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java | ||
|---|---|---|
| 314 | 314 |
|
| 315 | 315 |
float C = 2f; |
| 316 | 316 |
float[] bands = { 1.0f, 0.00f*C, 0.9f, 0.04f*C, 0.8f, 0.07f*C, 0.5f, 0.09f*C, 0.0f, 0.10f*C};
|
| 317 |
/* |
|
| 318 |
int numBands = 5; |
|
| 319 |
float[] bands = new float[2*numBands]; |
|
| 320 | 317 |
|
| 321 |
for(int i=0; i<numBands; i++) |
|
| 322 |
{
|
|
| 323 |
bands[2*i ] = 1 + i/(1.0f-numBands); |
|
| 324 |
bands[2*i+1] = B/(numBands-1)*i; |
|
| 325 |
} |
|
| 326 |
*/ |
|
| 327 | 318 |
mMesh = new MeshPolygon(vertices,bands,extraIndex,extraVertices,0.0f,0.0f); |
| 328 | 319 |
mMesh.setEffectAssociation(0,0,0); |
| 329 | 320 |
} |
| ... | ... | |
| 495 | 486 |
} |
| 496 | 487 |
catch(IOException e) |
| 497 | 488 |
{
|
| 498 |
android.util.Log.e("MeshFile", "Error closing InputStream: "+e.toString());
|
|
| 489 |
android.util.Log.e("MeshFile", "Error closing InputStream: "+ e);
|
|
| 499 | 490 |
} |
| 500 | 491 |
} |
| 501 | 492 |
|
| src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.examples.meshjoin; |
| 21 | 21 |
|
| 22 |
import android.app.ActivityManager; |
|
| 23 |
import android.content.Context; |
|
| 24 |
import android.content.pm.ConfigurationInfo; |
|
| 25 | 22 |
import android.content.res.Resources; |
| 26 | 23 |
import android.graphics.Bitmap; |
| 27 | 24 |
import android.graphics.Canvas; |
| ... | ... | |
| 57 | 54 |
|
| 58 | 55 |
class MeshJoinRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser |
| 59 | 56 |
{
|
| 60 |
private final GLSurfaceView mView; |
|
| 61 | 57 |
private final Resources mResources; |
| 62 | 58 |
private final DistortedScreen mScreen; |
| 63 | 59 |
private final DistortedEffects mEffects; |
| ... | ... | |
| 75 | 71 |
|
| 76 | 72 |
MeshJoinRenderer(GLSurfaceView v) |
| 77 | 73 |
{
|
| 78 |
mView = v; |
|
| 79 | 74 |
mResources = v.getResources(); |
| 80 | 75 |
|
| 81 | 76 |
mScreen = new DistortedScreen(); |
| src/main/java/org/distorted/examples/mirror/MirrorRenderer.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.examples.mirror; |
| 21 | 21 |
|
| 22 |
import android.app.ActivityManager; |
|
| 23 |
import android.content.Context; |
|
| 24 |
import android.content.pm.ConfigurationInfo; |
|
| 25 | 22 |
import android.content.res.Resources; |
| 26 | 23 |
import android.graphics.Bitmap; |
| 27 | 24 |
import android.graphics.BitmapFactory; |
| src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
|---|---|---|
| 55 | 55 |
|
| 56 | 56 |
private static final Object lock = new Object(); |
| 57 | 57 |
|
| 58 |
private Dynamic3D mCenter; |
|
| 59 |
private Paint mPaint; |
|
| 58 |
private final Dynamic3D mCenter;
|
|
| 59 |
private final Paint mPaint;
|
|
| 60 | 60 |
private int moving; |
| 61 | 61 |
private int mScrWidth, mScrHeight; |
| 62 | 62 |
private long mTime = 0; |
| 63 | 63 |
|
| 64 | 64 |
private int mCurrEffect; |
| 65 | 65 |
private int mSize1, mSize2; |
| 66 |
private Static3D mDeform; |
|
| 67 |
private Static1D mRadius; |
|
| 66 |
private final Static3D mDeform;
|
|
| 67 |
private final Static1D mRadius;
|
|
| 68 | 68 |
|
| 69 | 69 |
private MovingEffectsRenderer mRenderer; |
| 70 | 70 |
|
| src/main/java/org/distorted/examples/polymesh/PolymeshSurfaceView.java | ||
|---|---|---|
| 55 | 55 |
|
| 56 | 56 |
private static final Object lock = new Object(); |
| 57 | 57 |
|
| 58 |
private Dynamic3D mCenter; |
|
| 59 |
private Paint mPaint; |
|
| 58 |
private final Dynamic3D mCenter;
|
|
| 59 |
private final Paint mPaint;
|
|
| 60 | 60 |
private int moving; |
| 61 | 61 |
private int mScrWidth, mScrHeight; |
| 62 | 62 |
private long mTime = 0; |
| 63 | 63 |
|
| 64 | 64 |
private int mCurrEffect; |
| 65 | 65 |
private int mSize1, mSize2; |
| 66 |
private Static3D mDeform; |
|
| 67 |
private Static1D mRadius; |
|
| 66 |
private final Static3D mDeform;
|
|
| 67 |
private final Static1D mRadius;
|
|
| 68 | 68 |
|
| 69 | 69 |
private PolymeshRenderer mRenderer; |
| 70 | 70 |
|
| src/main/java/org/distorted/examples/predeform/PredeformActivity2.java | ||
|---|---|---|
| 74 | 74 |
mTexture = new DistortedTexture(); |
| 75 | 75 |
|
| 76 | 76 |
setContentView(R.layout.predeformlayout); |
| 77 |
; |
|
| 78 |
mTextLevel = findViewById(R.id.predeformInflateText); |
|
| 77 |
mTextLevel = findViewById(R.id.predeformInflateText); |
|
| 79 | 78 |
|
| 80 | 79 |
SeekBar inflateBar = findViewById(R.id.predeformInflateLevel); |
| 81 | 80 |
inflateBar.setOnSeekBarChangeListener(this); |
| src/main/java/org/distorted/examples/predeform/PredeformEffect.java | ||
|---|---|---|
| 70 | 70 |
private static final int BACKGROUND_ODD = 0xff555555; |
| 71 | 71 |
private static final int BACKGROUND_EVEN= 0xff333333; |
| 72 | 72 |
|
| 73 |
private WeakReference<PredeformActivity> mAct; |
|
| 74 |
|
|
| 75 |
private EffectName mName; |
|
| 76 |
private int[] mInter; |
|
| 77 |
private int[] mInterRegion; |
|
| 78 |
private int[] mInterCenter; |
|
| 79 |
private int[] mSeekID; |
|
| 80 |
private int[] mSeekRegionID; |
|
| 81 |
private int[] mSeekCenterID; |
|
| 82 |
private int mDimension, mRegionDimension; |
|
| 73 |
private final WeakReference<PredeformActivity> mAct; |
|
| 74 |
|
|
| 75 |
private final EffectName mName; |
|
| 76 |
private final int[] mInter; |
|
| 77 |
private final int[] mInterRegion; |
|
| 78 |
private final int[] mInterCenter; |
|
| 79 |
private final int[] mSeekID; |
|
| 80 |
private final int[] mSeekRegionID; |
|
| 81 |
private final int[] mSeekCenterID; |
|
| 82 |
private final int mDimension; |
|
| 83 |
private final int mRegionDimension; |
|
| 83 | 84 |
private TextView mText,mTextRegion,mTextCenter; |
| 84 | 85 |
|
| 85 | 86 |
private Dynamic1D mDyn1; |
| ... | ... | |
| 92 | 93 |
private Static3D mSta3; |
| 93 | 94 |
private Static4D mSta4; |
| 94 | 95 |
private Static5D mSta5; |
| 95 |
private Dynamic4D mRegion4Dyn; |
|
| 96 |
private Static4D mRegion4Sta; |
|
| 97 |
private Dynamic3D mRegion3Dyn; |
|
| 98 |
private Static3D mRegion3Sta; |
|
| 99 |
private Dynamic3D mCenterDyn; |
|
| 100 |
private Static3D mCenterSta; |
|
| 96 |
private final Dynamic4D mRegion4Dyn;
|
|
| 97 |
private final Static4D mRegion4Sta;
|
|
| 98 |
private final Dynamic3D mRegion3Dyn;
|
|
| 99 |
private final Static3D mRegion3Sta;
|
|
| 100 |
private final Dynamic3D mCenterDyn;
|
|
| 101 |
private final Static3D mCenterSta;
|
|
| 101 | 102 |
|
| 102 | 103 |
private View mButton, mEffect, mCenter, mRegion; |
| 103 | 104 |
private long mId; |
| src/main/java/org/distorted/examples/predeform/PredeformEffectList.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
public class PredeformEffectList |
| 29 | 29 |
{
|
| 30 |
private static ArrayList<VertexEffect> mList = new ArrayList<>(); |
|
| 30 |
private static final ArrayList<VertexEffect> mList = new ArrayList<>();
|
|
| 31 | 31 |
|
| 32 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 33 | 33 |
|
| src/main/java/org/distorted/examples/predeform/PredeformMeshList.java | ||
|---|---|---|
| 40 | 40 |
|
| 41 | 41 |
static final int LENGTH = values().length; |
| 42 | 42 |
private static final PredeformMeshList[] meshes; |
| 43 |
private int mDimension; |
|
| 43 |
private final int mDimension;
|
|
| 44 | 44 |
|
| 45 | 45 |
static |
| 46 | 46 |
{
|
| src/main/java/org/distorted/examples/projection/ProjectionRenderer.java | ||
|---|---|---|
| 49 | 49 |
|
| 50 | 50 |
class ProjectionRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser |
| 51 | 51 |
{
|
| 52 |
private final GLSurfaceView mView; |
|
| 53 | 52 |
private final Resources mResources; |
| 54 | 53 |
private final DistortedEffects mEffects; |
| 55 | 54 |
private final DistortedScreen mScreen; |
| ... | ... | |
| 62 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 63 | 62 |
|
| 64 | 63 |
ProjectionRenderer(GLSurfaceView view) |
| 65 |
{
|
|
| 66 |
mView = view; |
|
| 64 |
{
|
|
| 67 | 65 |
mResources = view.getResources(); |
| 68 | 66 |
|
| 69 | 67 |
mEffects= new DistortedEffects(); |
| src/main/java/org/distorted/examples/rubik/RubikCube.java | ||
|---|---|---|
| 55 | 55 |
private static final Static3D VectY = new Static3D(0,1,0); |
| 56 | 56 |
private static final Static3D VectZ = new Static3D(0,0,1); |
| 57 | 57 |
|
| 58 |
private static Random mRnd = new Random(0); |
|
| 59 |
|
|
| 60 |
private DistortedNode[][][] mNodes; |
|
| 61 |
private MeshCubes[][][] mCubes; |
|
| 62 |
private DistortedEffects[][][] mEffects; |
|
| 63 |
private Static3D[][][] mRotationAxis; |
|
| 64 |
private Dynamic1D[][][] mRotationAngle; |
|
| 65 |
private MatrixEffectRotate[][][] mRotate; |
|
| 66 |
private DistortedTexture mTexture; |
|
| 67 |
private int mSize; |
|
| 58 |
private static final Random mRnd = new Random(0);
|
|
| 59 |
|
|
| 60 |
private final DistortedNode[][][] mNodes;
|
|
| 61 |
private final MeshCubes[][][] mCubes;
|
|
| 62 |
private final DistortedEffects[][][] mEffects;
|
|
| 63 |
private final Static3D[][][] mRotationAxis;
|
|
| 64 |
private final Dynamic1D[][][] mRotationAngle;
|
|
| 65 |
private final MatrixEffectRotate[][][] mRotate;
|
|
| 66 |
private final DistortedTexture mTexture;
|
|
| 67 |
private final int mSize;
|
|
| 68 | 68 |
|
| 69 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 70 | 70 |
|
| src/main/java/org/distorted/examples/save/SaveActivity.java | ||
|---|---|---|
| 36 | 36 |
public class SaveActivity extends Activity implements SeekBar.OnSeekBarChangeListener |
| 37 | 37 |
{
|
| 38 | 38 |
private static final int REQUEST_EXTERNAL_STORAGE = 1; |
| 39 |
private static String[] PERMISSIONS_STORAGE = |
|
| 39 |
private static final String[] PERMISSIONS_STORAGE =
|
|
| 40 | 40 |
{
|
| 41 | 41 |
Manifest.permission.READ_EXTERNAL_STORAGE, |
| 42 | 42 |
Manifest.permission.WRITE_EXTERNAL_STORAGE |
| src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java | ||
|---|---|---|
| 107 | 107 |
new Static3D(+DIST,+DIST,+DIST), |
| 108 | 108 |
}; |
| 109 | 109 |
|
| 110 |
private final GLSurfaceView mView; |
|
| 111 | 110 |
private final Resources mResources; |
| 112 | 111 |
private final DistortedScreen mScreen; |
| 113 | 112 |
private final DistortedEffects mEffects; |
| ... | ... | |
| 127 | 126 |
|
| 128 | 127 |
SingleMeshRenderer(GLSurfaceView v) |
| 129 | 128 |
{
|
| 130 |
mView = v; |
|
| 131 | 129 |
mResources = v.getResources(); |
| 132 | 130 |
|
| 133 | 131 |
mScreen = new DistortedScreen(); |
| src/main/java/org/distorted/examples/starwars/StarWarsSurfaceView.java | ||
|---|---|---|
| 28 | 28 |
|
| 29 | 29 |
class StarWarsSurfaceView extends GLSurfaceView |
| 30 | 30 |
{
|
| 31 |
private StarWarsRenderer mRenderer; |
|
| 31 |
private final StarWarsRenderer mRenderer;
|
|
| 32 | 32 |
|
| 33 | 33 |
public StarWarsSurfaceView(Context context) |
| 34 | 34 |
{
|
| src/main/java/org/distorted/examples/surfaceview/RenderHandler.java | ||
|---|---|---|
| 37 | 37 |
private static final int MSG_DO_FRAME = 2; |
| 38 | 38 |
private static final int MSG_SHUTDOWN = 4; |
| 39 | 39 |
|
| 40 |
private WeakReference<RenderThread> mWeakRenderThread; |
|
| 40 |
private final WeakReference<RenderThread> mWeakRenderThread;
|
|
| 41 | 41 |
|
| 42 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 43 | 43 |
|
| src/main/java/org/distorted/examples/surfaceview/RenderThread.java | ||
|---|---|---|
| 72 | 72 |
private EGLSurface eglSurface; |
| 73 | 73 |
private DistortedTexture mTexture; |
| 74 | 74 |
private MeshSquare mMesh; |
| 75 |
private volatile SurfaceHolder mSurfaceHolder; // may be updated by UI thread
|
|
| 75 |
private final SurfaceHolder mSurfaceHolder; // may be updated by UI thread
|
|
| 76 | 76 |
private float mBmpRatio; |
| 77 | 77 |
private boolean mReady = false; |
| 78 | 78 |
|
| src/main/java/org/distorted/examples/transparency/TransparencyRenderer.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.examples.transparency; |
| 21 | 21 |
|
| 22 |
import android.app.ActivityManager; |
|
| 23 |
import android.content.Context; |
|
| 24 |
import android.content.pm.ConfigurationInfo; |
|
| 25 | 22 |
import android.content.res.Resources; |
| 26 | 23 |
import android.opengl.GLSurfaceView; |
| 27 | 24 |
|
| ... | ... | |
| 62 | 59 |
private static final int NUM_OBJECTS = OBJECTS.length/NUM; |
| 63 | 60 |
private static final int OBJ_SIZE = 100; |
| 64 | 61 |
|
| 65 |
private final GLSurfaceView mView; |
|
| 66 | 62 |
private final Resources mResources; |
| 67 | 63 |
private final DistortedNode[] mNode; |
| 68 | 64 |
private final DistortedTexture[] mTex; |
| ... | ... | |
| 81 | 77 |
|
| 82 | 78 |
TransparencyRenderer(GLSurfaceView v) |
| 83 | 79 |
{
|
| 84 |
mView = v; |
|
| 85 | 80 |
mResources = v.getResources(); |
| 86 | 81 |
|
| 87 | 82 |
MeshSquare mesh = new MeshSquare(1,1); |
| src/main/java/org/distorted/examples/wind/WindEffectsManager.java | ||
|---|---|---|
| 41 | 41 |
// fall back down if no wind (milliseconds) |
| 42 | 42 |
private long mLastTime, mPausedTime; |
| 43 | 43 |
private float mWind; |
| 44 |
private int mHeight, mWidth; |
|
| 45 |
|
|
| 46 |
private Static3D shearFactor; |
|
| 47 |
private Static3D scaleFactor; |
|
| 48 |
private Static3D deformForce; |
|
| 49 |
private Static5D windFactor11, windFactor12; |
|
| 50 |
private Dynamic5D windDynamic1; |
|
| 51 |
private Static5D windFactor21, windFactor22; |
|
| 52 |
private Dynamic5D windDynamic2; |
|
| 53 |
private Static5D windFactor31, windFactor32; |
|
| 54 |
private Dynamic5D windDynamic3; |
|
| 55 |
private Static5D windFactor41, windFactor42; |
|
| 56 |
private Dynamic5D windDynamic4; |
|
| 44 |
private final int mHeight; |
|
| 45 |
private final int mWidth; |
|
| 46 |
|
|
| 47 |
private final Static3D shearFactor; |
|
| 48 |
private final Static3D scaleFactor; |
|
| 49 |
private final Static3D deformForce; |
|
| 50 |
private final Static5D windFactor11; |
|
| 51 |
private final Static5D windFactor12; |
|
| 52 |
private final Dynamic5D windDynamic1; |
|
| 53 |
private final Static5D windFactor21; |
|
| 54 |
private final Static5D windFactor22; |
|
| 55 |
private final Dynamic5D windDynamic2; |
|
| 56 |
private final Static5D windFactor31; |
|
| 57 |
private final Static5D windFactor32; |
|
| 58 |
private final Dynamic5D windDynamic3; |
|
| 59 |
private final Static5D windFactor41; |
|
| 60 |
private final Static5D windFactor42; |
|
| 61 |
private final Dynamic5D windDynamic4; |
|
| 57 | 62 |
|
| 58 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 | 64 |
|
| src/main/java/org/distorted/examples/wind/WindGust.java | ||
|---|---|---|
| 29 | 29 |
private int mAvgWind; |
| 30 | 30 |
private boolean mBlowingNow; |
| 31 | 31 |
private long mLastTime, mPausedTime; |
| 32 |
private static Random mRnd = new Random(); |
|
| 32 |
private static final Random mRnd = new Random();
|
|
| 33 | 33 |
|
| 34 | 34 |
WindGust() |
| 35 | 35 |
{
|
| src/main/res/layout/check1layout.xml | ||
|---|---|---|
| 78 | 78 |
<Button |
| 79 | 79 |
android:id="@+id/check1Button" |
| 80 | 80 |
android:layout_width="match_parent" |
| 81 |
android:layout_height="wrap_content"
|
|
| 81 |
android:layout_height="0dp"
|
|
| 82 | 82 |
android:layout_weight="0.10" |
| 83 | 83 |
android:onClick="Check" |
| 84 | 84 |
android:text="@string/check" |
| src/main/res/layout/effectqueuelayout.xml | ||
|---|---|---|
| 20 | 20 |
android:id="@+id/linearLayout1" |
| 21 | 21 |
android:layout_width="fill_parent" |
| 22 | 22 |
android:layout_height="wrap_content" |
| 23 |
android:layout_weight="0.3" |
|
| 24 | 23 |
android:gravity="fill_horizontal|top" |
| 25 | 24 |
android:orientation="vertical" |
| 26 | 25 |
android:weightSum="1"> |
| src/main/res/layout/mirrorlayout.xml | ||
|---|---|---|
| 22 | 22 |
<SeekBar |
| 23 | 23 |
android:id="@+id/mirrorSeek" |
| 24 | 24 |
android:layout_weight="1" |
| 25 |
android:layout_width="wrap_content"
|
|
| 25 |
android:layout_width="0dp"
|
|
| 26 | 26 |
android:layout_height="wrap_content" |
| 27 | 27 |
android:paddingLeft="10dp" |
| 28 | 28 |
android:paddingRight="10dp" /> |
Also available in: Unified diff
Lint