Revision 687263cc
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
|---|---|---|
| 68 | 68 |
|
| 69 | 69 |
mView = view; |
| 70 | 70 |
mManager = new AroundTheWorldEffectsManager(); |
| 71 |
mEffects = new DistortedEffects(); |
|
| 71 |
mEffects = new DistortedEffects(1);
|
|
| 72 | 72 |
mEffects.apply(new MatrixEffectScale(mScale)); |
| 73 | 73 |
mEffects.apply(new MatrixEffectMove(mMove)); |
| 74 | 74 |
|
| ... | ... | |
| 136 | 136 |
mObjWidth = bitmap.getWidth(); |
| 137 | 137 |
mObjHeight= bitmap.getHeight(); |
| 138 | 138 |
|
| 139 |
if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight); |
|
| 139 |
mEffects.setStretch(mObjWidth,mObjHeight,0); |
|
| 140 |
|
|
| 141 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 140 | 142 |
mTexture.setTexture(bitmap); |
| 141 | 143 |
|
| 142 | 144 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*mObjHeight/mObjWidth); |
| src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
|---|---|---|
| 88 | 88 |
mMove = new Static3D(0,0,0); |
| 89 | 89 |
mScale= new Static3D(1,1,1); |
| 90 | 90 |
|
| 91 |
mEffects = new DistortedEffects(); |
|
| 91 |
mEffects = new DistortedEffects(1);
|
|
| 92 | 92 |
mEffects.apply( new VertexEffectDistort(dynLeft , pointLeft , regionLeft) ); |
| 93 | 93 |
mEffects.apply( new VertexEffectDistort(dynRight, pointRight, regionRight)); |
| 94 | 94 |
mEffects.apply( new MatrixEffectScale(mScale) ); |
| ... | ... | |
| 148 | 148 |
|
| 149 | 149 |
mObjHeight = bitmap.getHeight(); |
| 150 | 150 |
mObjWidth = bitmap.getWidth(); |
| 151 |
|
|
| 152 |
if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight); |
|
| 151 |
|
|
| 152 |
mEffects.setStretch(mObjWidth,mObjHeight,0); |
|
| 153 |
|
|
| 154 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 153 | 155 |
mTexture.setTexture(bitmap); |
| 154 | 156 |
if( mMesh==null ) mMesh = new MeshRectangles(25,25*mObjHeight/mObjWidth); |
| 155 | 157 |
|
| src/main/java/org/distorted/examples/blur/BlurRenderer.java | ||
|---|---|---|
| 78 | 78 |
mBufferMove = new Static3D(0,0,0); |
| 79 | 79 |
mBufferScale= new Static3D(1,1,1); |
| 80 | 80 |
|
| 81 |
mBufferEffects = new DistortedEffects(); |
|
| 81 |
mBufferEffects = new DistortedEffects(1);
|
|
| 82 | 82 |
mBufferEffects.apply(new MatrixEffectScale(mBufferScale)); |
| 83 | 83 |
mBufferEffects.apply(new MatrixEffectMove(mBufferMove)); |
| 84 | 84 |
|
| 85 |
mEffects = new DistortedEffects(); |
|
| 85 |
mEffects = new DistortedEffects(1);
|
|
| 86 | 86 |
mEffects.apply( new PostprocessEffectBlur(radiusDyn) ); |
| 87 | 87 |
mEffects.apply(new MatrixEffectScale(mScale)); |
| 88 | 88 |
mEffects.apply(new MatrixEffectMove(mMove)); |
| ... | ... | |
| 155 | 155 |
mObjHeight = bitmap.getHeight(); |
| 156 | 156 |
mObjWidth = bitmap.getWidth(); |
| 157 | 157 |
|
| 158 |
if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight); |
|
| 158 |
mEffects.setStretch(mObjWidth,mObjHeight,0); |
|
| 159 |
mBufferEffects.setStretch(SIZE,SIZE,0); |
|
| 160 |
|
|
| 161 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 159 | 162 |
mTexture.setTexture(bitmap); |
| 160 | 163 |
|
| 161 | 164 |
mScreen.detachAll(); |
| src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
|---|---|---|
| 92 | 92 |
diRotate.add(new Static1D( 0)); |
| 93 | 93 |
diRotate.add(new Static1D(360)); |
| 94 | 94 |
|
| 95 |
mEffects = new DistortedEffects(); |
|
| 95 |
mEffects = new DistortedEffects(1);
|
|
| 96 | 96 |
|
| 97 | 97 |
mEffects.apply( new MatrixEffectRotate( diRotate, new Static3D(0,0,1), mRotate) ); |
| 98 | 98 |
mEffects.apply( new MatrixEffectScale(diScale)); |
| ... | ... | |
| 142 | 142 |
mObjWidth = bitmap.getWidth(); |
| 143 | 143 |
mRotate.set(mObjWidth/2,mObjHeight/2,0); |
| 144 | 144 |
|
| 145 |
if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight); |
|
| 145 |
mEffects.setStretch(mObjWidth,mObjHeight,0); |
|
| 146 |
|
|
| 147 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 146 | 148 |
mTexture.setTexture(bitmap); |
| 147 | 149 |
|
| 148 | 150 |
mScreen.detachAll(); |
| src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
|---|---|---|
| 92 | 92 |
mScale = new Static3D(1,1,1); |
| 93 | 93 |
mCenter = new Static3D(0,0,0); |
| 94 | 94 |
|
| 95 |
mEffects = new DistortedEffects(); |
|
| 95 |
mEffects = new DistortedEffects(1);
|
|
| 96 | 96 |
mEffects.apply(new MatrixEffectScale(mScale)); |
| 97 | 97 |
mEffects.apply(new MatrixEffectMove(mMove)); |
| 98 | 98 |
|
| ... | ... | |
| 181 | 181 |
mObjHeight = bitmap.getHeight(); |
| 182 | 182 |
mObjWidth = bitmap.getWidth(); |
| 183 | 183 |
|
| 184 |
if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight); |
|
| 184 |
mEffects.setStretch(mObjWidth,mObjHeight,0); |
|
| 185 |
|
|
| 186 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 185 | 187 |
mTexture.setTexture(bitmap); |
| 186 | 188 |
|
| 187 | 189 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*mObjHeight/mObjWidth); |
| src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
|---|---|---|
| 81 | 81 |
{
|
| 82 | 82 |
mView = view; |
| 83 | 83 |
|
| 84 |
mEffects = new DistortedEffects(); |
|
| 84 |
mEffects = new DistortedEffects(1);
|
|
| 85 | 85 |
mRegion = new Static4D(0,0,0,0); |
| 86 | 86 |
mMove = new Static3D(0,0,0); |
| 87 | 87 |
mTouchPoint = new Static3D(0,0,0); |
| ... | ... | |
| 209 | 209 |
stretchCanvas.drawRect( 0, h*i/NUM_LINES-1, w , h*i/NUM_LINES+1, paint); |
| 210 | 210 |
} |
| 211 | 211 |
|
| 212 |
if( mTexture==null ) mTexture = new DistortedTexture(w,h); |
|
| 212 |
mEffects.setStretch(w,h,0); |
|
| 213 |
|
|
| 214 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 213 | 215 |
mTexture.setTexture(stretchBitmap); |
| 214 | 216 |
|
| 215 | 217 |
mMove.set(scrWidth/4,scrHeight/4,0); |
| src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
|---|---|---|
| 72 | 72 |
Static3D mPoint = new Static3D(305, 220, 0); |
| 73 | 73 |
|
| 74 | 74 |
mEffects = new DistortedEffects[NUM]; |
| 75 |
mEffects[0] = new DistortedEffects(); |
|
| 75 |
mEffects[0] = new DistortedEffects(1);
|
|
| 76 | 76 |
for(int i=1; i<NUM; i++) |
| 77 | 77 |
mEffects[i] = new DistortedEffects(mEffects[0], DistortedLibrary.CLONE_VERTEX| DistortedLibrary.CLONE_FRAGMENT); |
| 78 | 78 |
|
| ... | ... | |
| 174 | 174 |
bmpHeight = bitmap0.getHeight(); |
| 175 | 175 |
bmpWidth = bitmap0.getWidth(); |
| 176 | 176 |
|
| 177 |
mEffects[0].setStretch(bmpWidth,bmpHeight,0); |
|
| 178 |
|
|
| 177 | 179 |
if( mTexture==null ) |
| 178 | 180 |
{
|
| 179 | 181 |
mTexture = new DistortedTexture[NUM]; |
| 180 | 182 |
|
| 181 | 183 |
for(int i=0; i<NUM; i++) |
| 182 |
mTexture[i] = new DistortedTexture(bmpWidth,bmpHeight);
|
|
| 184 |
mTexture[i] = new DistortedTexture(); |
|
| 183 | 185 |
} |
| 184 | 186 |
|
| 185 | 187 |
mTexture[0].setTexture(bitmap0); |
| src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
|---|---|---|
| 83 | 83 |
|
| 84 | 84 |
mEffects = new DistortedEffects[NUM]; |
| 85 | 85 |
|
| 86 |
for(int i=0; i<NUM; i++) mEffects[i] = new DistortedEffects(); |
|
| 86 |
for(int i=0; i<NUM; i++) mEffects[i] = new DistortedEffects(1);
|
|
| 87 | 87 |
|
| 88 | 88 |
Dynamic1D sink = new Dynamic1D(2000,0.0f); |
| 89 | 89 |
sink.add(new Static1D( 1)); |
| ... | ... | |
| 173 | 173 |
bmpHeight = bitmap.getHeight(); |
| 174 | 174 |
bmpWidth = bitmap.getWidth(); |
| 175 | 175 |
|
| 176 |
for(int i=0; i<NUM; i++) |
|
| 177 |
{
|
|
| 178 |
mEffects[i].setStretch(bmpWidth, bmpHeight, 0); |
|
| 179 |
} |
|
| 180 |
|
|
| 176 | 181 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
| 177 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
| 182 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 178 | 183 |
mTexture.setTexture(bitmap); |
| 179 | 184 |
|
| 180 | 185 |
mScreen.detachAll(); |
| src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
|---|---|---|
| 61 | 61 |
|
| 62 | 62 |
mView = v; |
| 63 | 63 |
mMesh = new MeshRectangles(1,1); |
| 64 |
mEffects = new DistortedEffects(); |
|
| 65 | 64 |
mScreen = new DistortedScreen(); |
| 66 | 65 |
} |
| 67 | 66 |
|
| ... | ... | |
| 90 | 89 |
DynamicSurfaceView.setHalfWidth(texW/2); |
| 91 | 90 |
|
| 92 | 91 |
if( mTexture!=null ) mTexture.markForDeletion(); |
| 93 |
mTexture= new DistortedTexture(texW,texH); |
|
| 92 |
mTexture= new DistortedTexture(); |
|
| 93 |
mEffects = new DistortedEffects(texW, texH, 0); |
|
| 94 | 94 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
| 95 | 95 |
mCanvas = new Canvas(mBitmap); |
| 96 | 96 |
|
| src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
|---|---|---|
| 116 | 116 |
scale.add(mScaleFactor); |
| 117 | 117 |
|
| 118 | 118 |
mMesh = new MeshSphere(LEVEL); |
| 119 |
mTexture = new DistortedTexture(SIZE,SIZE);
|
|
| 119 |
mTexture = new DistortedTexture(); |
|
| 120 | 120 |
|
| 121 |
mObjWidth = mTexture.getWidth(); |
|
| 122 |
mObjHeight= mTexture.getHeight(); |
|
| 123 |
mObjDepth = mTexture.getDepth(mMesh); |
|
| 121 |
mObjWidth = mObjHeight = mObjDepth = SIZE; |
|
| 124 | 122 |
|
| 125 | 123 |
mQuat1 = new Static4D(0,0,0,1); // unity |
| 126 | 124 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
| ... | ... | |
| 131 | 129 |
quatInt1.add(mQuat1); |
| 132 | 130 |
quatInt2.add(mQuat2); |
| 133 | 131 |
|
| 134 |
mEffects = new DistortedEffects(); |
|
| 132 |
mEffects = new DistortedEffects(SIZE,SIZE,SIZE);
|
|
| 135 | 133 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
| 136 | 134 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
| 137 | 135 |
mEffects.apply( new MatrixEffectScale(scale)); |
| src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
|---|---|---|
| 78 | 78 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale); |
| 79 | 79 |
|
| 80 | 80 |
mMesh = new MeshRectangles(MESH_QUALITY,MESH_QUALITY*texHeight/texWidth); |
| 81 |
mTexture = new DistortedTexture(texWidth,texHeight);
|
|
| 82 |
mEffects = new DistortedEffects(); |
|
| 81 |
mTexture = new DistortedTexture(); |
|
| 82 |
mEffects = new DistortedEffects(texWidth,texHeight,0);
|
|
| 83 | 83 |
mEffects.apply(scaleEffect); |
| 84 | 84 |
|
| 85 | 85 |
mScreen = new DistortedScreen(); |
| src/main/java/org/distorted/examples/flag/FlagRenderer.java | ||
|---|---|---|
| 66 | 66 |
{
|
| 67 | 67 |
mView = v; |
| 68 | 68 |
|
| 69 |
mTexture = new DistortedTexture(500,300); |
|
| 69 |
final int GRIDX = 50; |
|
| 70 |
final int GRIDY = 30; |
|
| 71 |
|
|
| 72 |
final Static4D mapFB = new Static4D(0.0f,0.0f,1.0f ,1.0f ); |
|
| 73 |
final Static4D mapLR = new Static4D(0.0f,0.0f,1.0f/GRIDX,1.0f ); |
|
| 74 |
final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f ,1.0f/GRIDY); |
|
| 75 |
|
|
| 76 |
MeshCubes mesh = new MeshCubes(GRIDX,GRIDY,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
|
| 70 | 77 |
|
| 71 |
mObjWidth = mTexture.getWidth(); |
|
| 72 |
mObjHeight= mTexture.getHeight(); |
|
| 78 |
mTexture = new DistortedTexture(); |
|
| 79 |
|
|
| 80 |
mObjWidth = 500; |
|
| 81 |
mObjHeight= 300; |
|
| 73 | 82 |
|
| 74 | 83 |
mWaveDyn = new Dynamic5D(1000,0.0f); |
| 75 | 84 |
mWaveSta1= new Static5D(0,0,-180,0,0); // all other values besides the |
| ... | ... | |
| 85 | 94 |
Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, 0); // middle of the right edge |
| 86 | 95 |
Static4D waveRegion = new Static4D(0,0,0,mObjWidth); |
| 87 | 96 |
|
| 88 |
DistortedEffects effects = new DistortedEffects(); |
|
| 97 |
DistortedEffects effects = new DistortedEffects(mObjWidth,mObjHeight,1);
|
|
| 89 | 98 |
effects.apply( new VertexEffectWave(mWaveDyn, waveCenter, waveRegion) ); |
| 90 | 99 |
|
| 91 | 100 |
mMove = new Static3D(0,0,0); |
| ... | ... | |
| 97 | 106 |
effects.apply( new MatrixEffectScale(mScale)); |
| 98 | 107 |
effects.apply( new MatrixEffectMove(mMove)); |
| 99 | 108 |
|
| 100 |
final int GRIDX = 50; |
|
| 101 |
final int GRIDY = 30; |
|
| 102 |
|
|
| 103 |
final Static4D mapFB = new Static4D(0.0f,0.0f,1.0f ,1.0f ); |
|
| 104 |
final Static4D mapLR = new Static4D(0.0f,0.0f,1.0f/GRIDX,1.0f ); |
|
| 105 |
final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f ,1.0f/GRIDY); |
|
| 106 | 109 |
|
| 107 | 110 |
mScreen = new DistortedScreen(); |
| 108 |
mScreen.attach(mTexture, effects, new MeshCubes(GRIDX,GRIDY,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB) );
|
|
| 111 |
mScreen.attach(mTexture, effects, mesh );
|
|
| 109 | 112 |
} |
| 110 | 113 |
|
| 111 | 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/generic/GenericActivity2.java | ||
|---|---|---|
| 80 | 80 |
mShowNormal = false; |
| 81 | 81 |
mUseOIT = false; |
| 82 | 82 |
|
| 83 |
mEffects= new DistortedEffects(1); |
|
| 84 |
|
|
| 83 | 85 |
int maxsize = numCols > numRows ? (numCols>numSlic ? numCols:numSlic) : (numRows>numSlic ? numRows:numSlic) ; |
| 84 | 86 |
|
| 85 | 87 |
createBitmap(maxsize, bitmapID); |
| ... | ... | |
| 98 | 100 |
|
| 99 | 101 |
mMesh = new MeshCubes(numCols, str, numSlic, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
| 100 | 102 |
} |
| 103 |
mEffects.setStretch(numCols,numRows,numSlic); |
|
| 101 | 104 |
break; |
| 102 | 105 |
case 1: mMesh = new MeshRectangles(numCols,numRows); |
| 106 |
mEffects.setStretch(numCols,numRows,0); |
|
| 103 | 107 |
break; |
| 104 | 108 |
case 2: mMesh = new MeshSphere(numRows); |
| 109 |
mEffects.setStretch(numRows,numRows,numRows); |
|
| 105 | 110 |
break; |
| 106 | 111 |
case 3: mMesh = new MeshQuad(); |
| 107 | 112 |
break; |
| 108 | 113 |
} |
| 109 | 114 |
|
| 110 | 115 |
mMesh.setShowNormals(mShowNormal); |
| 111 |
mTexture= new DistortedTexture(numCols,numRows); |
|
| 112 |
mEffects= new DistortedEffects(); |
|
| 116 |
mTexture= new DistortedTexture(); |
|
| 113 | 117 |
|
| 114 | 118 |
final View view = getLayoutInflater().inflate(R.layout.genericlayout, null); |
| 115 | 119 |
|
| ... | ... | |
| 204 | 208 |
|
| 205 | 209 |
public int getWidth() |
| 206 | 210 |
{
|
| 207 |
return mTexture==null ? 0: mTexture.getWidth();
|
|
| 211 |
return mEffects==null ? 0: mEffects.getStartchX();
|
|
| 208 | 212 |
} |
| 209 | 213 |
|
| 210 | 214 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 211 | 215 |
|
| 212 | 216 |
public int getHeight() |
| 213 | 217 |
{
|
| 214 |
return mTexture==null ? 0: mTexture.getHeight();
|
|
| 218 |
return mEffects==null ? 0: mEffects.getStartchY();
|
|
| 215 | 219 |
} |
| 216 | 220 |
|
| 217 | 221 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 218 | 222 |
|
| 219 | 223 |
public int getDepth() |
| 220 | 224 |
{
|
| 221 |
return mTexture==null ? 0: mTexture.getDepth(mMesh);
|
|
| 225 |
return mEffects==null ? 0: mEffects.getStartchZ();
|
|
| 222 | 226 |
} |
| 223 | 227 |
|
| 224 | 228 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/generic/GenericEffect.java | ||
|---|---|---|
| 107 | 107 |
|
| 108 | 108 |
switch(mName) |
| 109 | 109 |
{
|
| 110 |
case ROTATE : effect = new MatrixEffectRotate (mDyn1, mDyn3, mCenterDyn); break; |
|
| 110 |
case ROTATE : effect = new MatrixEffectRotate (mDyn1, mDyn3, mCenterDyn); android.util.Log.e("eff", "adding rotate with center "+mCenterSta.get0());break;
|
|
| 111 | 111 |
case QUATERNION : effect = new MatrixEffectQuaternion (mDyn4, mCenterDyn); break; |
| 112 | 112 |
case MOVE : effect = new MatrixEffectMove (mDyn3) ; break; |
| 113 | 113 |
case SCALE : effect = new MatrixEffectScale (mDyn3) ; break; |
| src/main/java/org/distorted/examples/generic/GenericRenderer.java | ||
|---|---|---|
| 55 | 55 |
|
| 56 | 56 |
private GLSurfaceView mView; |
| 57 | 57 |
private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture; |
| 58 |
private DistortedEffects mObjectEffects,mBackgroundEffects,mCenterEffects,mRegionEffects; |
|
| 58 | 59 |
private DistortedScreen mScreen; |
| 59 | 60 |
private DistortedNode mCenterNode, mRegionNode; |
| 60 | 61 |
private int mObjWidth, mObjHeight, mObjDepth; |
| ... | ... | |
| 87 | 88 |
mScaleBackground= new Static3D(1,1,1); |
| 88 | 89 |
|
| 89 | 90 |
mObjectTexture = act.getTexture(); |
| 90 |
mBackgroundTexture = new DistortedTexture(100,100);
|
|
| 91 |
mCenterTexture = new DistortedTexture(100,100);
|
|
| 92 |
mRegionTexture = new DistortedTexture(100,100);
|
|
| 91 |
mBackgroundTexture = new DistortedTexture(); |
|
| 92 |
mCenterTexture = new DistortedTexture(); |
|
| 93 |
mRegionTexture = new DistortedTexture(); |
|
| 93 | 94 |
|
| 94 | 95 |
mFactorObj = 1.0f; |
| 95 | 96 |
|
| 96 |
DistortedEffects objectEffects = act.getEffects();
|
|
| 97 |
DistortedEffects backgroundEffects = new DistortedEffects();
|
|
| 98 |
DistortedEffects centerEffects = new DistortedEffects();
|
|
| 99 |
DistortedEffects regionEffects = new DistortedEffects();
|
|
| 97 |
mObjectEffects = act.getEffects();
|
|
| 98 |
mBackgroundEffects = new DistortedEffects(1);
|
|
| 99 |
mCenterEffects = new DistortedEffects(1);
|
|
| 100 |
mRegionEffects = new DistortedEffects(1);
|
|
| 100 | 101 |
|
| 101 |
MeshBase mesh = act.getMesh(); |
|
| 102 |
MeshRectangles quad = new MeshRectangles(1,1);
|
|
| 102 |
MeshBase mesh = act.getMesh();
|
|
| 103 |
MeshRectangles quad = new MeshRectangles(1,1); |
|
| 103 | 104 |
|
| 104 | 105 |
mFactor = mesh instanceof MeshSphere ? 1.0f : 0.7f; |
| 105 | 106 |
|
| 106 |
mObjWidth = mObjectTexture.getWidth();
|
|
| 107 |
mObjHeight= mObjectTexture.getHeight();
|
|
| 108 |
mObjDepth = mObjectTexture.getDepth(mesh);
|
|
| 107 |
mObjWidth = act.getWidth();
|
|
| 108 |
mObjHeight= act.getHeight();
|
|
| 109 |
mObjDepth = act.getDepth();
|
|
| 109 | 110 |
|
| 110 | 111 |
mQuat1 = new Static4D(0,0,0,1); // unity |
| 111 | 112 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
| ... | ... | |
| 114 | 115 |
mRegionPoint= new Static3D(0,0,0); |
| 115 | 116 |
mRegionScalePoint = new Static3D(0,0,0); |
| 116 | 117 |
|
| 117 |
mCenterNode = new DistortedNode(mCenterTexture, centerEffects, quad);
|
|
| 118 |
mRegionNode = new DistortedNode(mRegionTexture, regionEffects, quad);
|
|
| 118 |
mCenterNode = new DistortedNode(mCenterTexture, mCenterEffects, quad);
|
|
| 119 |
mRegionNode = new DistortedNode(mRegionTexture, mRegionEffects, quad);
|
|
| 119 | 120 |
|
| 120 | 121 |
mScreen = new DistortedScreen(); |
| 121 | 122 |
mScreen.setProjection(FOV, NEAR); |
| 122 |
mScreen.attach(mBackgroundTexture, backgroundEffects, quad );
|
|
| 123 |
mScreen.attach(mObjectTexture , objectEffects , mesh );
|
|
| 123 |
mScreen.attach(mBackgroundTexture, mBackgroundEffects, quad );
|
|
| 124 |
mScreen.attach(mObjectTexture , mObjectEffects , mesh );
|
|
| 124 | 125 |
|
| 125 |
int regionSize = mRegionTexture.getWidth();
|
|
| 126 |
int regionSize = mRegionEffects.getStartchX();
|
|
| 126 | 127 |
mRotateCen = new Static3D(0 ,0, 0); |
| 127 | 128 |
|
| 128 | 129 |
MatrixEffectQuaternion quat1cen = new MatrixEffectQuaternion(mQuat1, mRotateCen); |
| 129 | 130 |
MatrixEffectQuaternion quat2cen = new MatrixEffectQuaternion(mQuat2, mRotateCen); |
| 130 | 131 |
MatrixEffectMove centerMove = new MatrixEffectMove(mCenterPoint); |
| 131 | 132 |
|
| 132 |
centerEffects.apply( new MatrixEffectScale(mScaleCenter) );
|
|
| 133 |
centerEffects.apply( centerMove );
|
|
| 134 |
centerEffects.apply( new MatrixEffectMove(mMoveCenter) );
|
|
| 135 |
centerEffects.apply(quat2cen);
|
|
| 136 |
centerEffects.apply(quat1cen);
|
|
| 133 |
mCenterEffects.apply( new MatrixEffectScale(mScaleCenter) );
|
|
| 134 |
mCenterEffects.apply( centerMove );
|
|
| 135 |
mCenterEffects.apply( new MatrixEffectMove(mMoveCenter) );
|
|
| 136 |
mCenterEffects.apply(quat2cen);
|
|
| 137 |
mCenterEffects.apply(quat1cen);
|
|
| 137 | 138 |
|
| 138 |
regionEffects.apply( new MatrixEffectMove(new Static3D( -regionSize*0.5f , -regionSize*0.5f , 0)) );
|
|
| 139 |
regionEffects.apply( new MatrixEffectScale(mRegionScalePoint) );
|
|
| 140 |
regionEffects.apply( new MatrixEffectMove(mRegionPoint) );
|
|
| 141 |
regionEffects.apply( centerMove );
|
|
| 142 |
regionEffects.apply( new MatrixEffectMove(mMoveRegion) );
|
|
| 143 |
regionEffects.apply(quat2cen);
|
|
| 144 |
regionEffects.apply(quat1cen);
|
|
| 139 |
mRegionEffects.apply( new MatrixEffectMove(new Static3D( -regionSize*0.5f , -regionSize*0.5f , 0)) );
|
|
| 140 |
mRegionEffects.apply( new MatrixEffectScale(mRegionScalePoint) );
|
|
| 141 |
mRegionEffects.apply( new MatrixEffectMove(mRegionPoint) );
|
|
| 142 |
mRegionEffects.apply( centerMove );
|
|
| 143 |
mRegionEffects.apply( new MatrixEffectMove(mMoveRegion) );
|
|
| 144 |
mRegionEffects.apply(quat2cen);
|
|
| 145 |
mRegionEffects.apply(quat1cen);
|
|
| 145 | 146 |
|
| 146 | 147 |
resetMatrixEffects(); |
| 147 | 148 |
|
| 148 | 149 |
// quite tricky: move the background exactly to the FAR plane! (see InternalOutputSurface.setProjection() ) |
| 149 |
backgroundEffects.apply(new MatrixEffectScale(mScaleBackground) );
|
|
| 150 |
backgroundEffects.apply(new MatrixEffectMove(mMoveBackground) );
|
|
| 150 |
mBackgroundEffects.apply(new MatrixEffectScale(mScaleBackground) );
|
|
| 151 |
mBackgroundEffects.apply(new MatrixEffectMove(mMoveBackground) );
|
|
| 151 | 152 |
} |
| 152 | 153 |
|
| 153 | 154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 154 | 155 |
|
| 155 | 156 |
void resetMatrixEffects() |
| 156 | 157 |
{
|
| 157 |
GenericActivity2 act = (GenericActivity2)mView.getContext(); |
|
| 158 |
DistortedEffects objectEffects= act.getEffects(); |
|
| 159 | 158 |
Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 ); |
| 160 | 159 |
|
| 161 | 160 |
MatrixEffectQuaternion quat1obj = new MatrixEffectQuaternion(mQuat1, rotateObj); |
| 162 | 161 |
MatrixEffectQuaternion quat2obj = new MatrixEffectQuaternion(mQuat2, rotateObj); |
| 163 | 162 |
|
| 164 |
objectEffects.apply(quat2obj);
|
|
| 165 |
objectEffects.apply(quat1obj);
|
|
| 166 |
objectEffects.apply( new MatrixEffectScale(mScaleObject) );
|
|
| 167 |
objectEffects.apply( new MatrixEffectMove(mMoveObject));
|
|
| 163 |
mObjectEffects.apply(quat2obj);
|
|
| 164 |
mObjectEffects.apply(quat1obj);
|
|
| 165 |
mObjectEffects.apply( new MatrixEffectScale(mScaleObject) );
|
|
| 166 |
mObjectEffects.apply( new MatrixEffectMove(mMoveObject));
|
|
| 168 | 167 |
|
| 169 | 168 |
mQuat1.set(0,0,0,1); |
| 170 | 169 |
mQuat2.set(0,0,0,1); |
| ... | ... | |
| 217 | 216 |
|
| 218 | 217 |
void setRegion(float x, float y, float z, float r) |
| 219 | 218 |
{
|
| 220 |
float factorReg = 2*mFactorObj*r/mRegionTexture.getWidth();
|
|
| 219 |
float factorReg = 2*mFactorObj*r/mRegionEffects.getStartchX();
|
|
| 221 | 220 |
mRegionPoint.set(mFactorObj*x,mFactorObj*y, mFactorObj*z); |
| 222 | 221 |
mRegionScalePoint.set(factorReg,factorReg,factorReg); |
| 223 | 222 |
} |
| ... | ... | |
| 244 | 243 |
mScreenMin = width<height ? width:height; |
| 245 | 244 |
|
| 246 | 245 |
float factorCen; |
| 247 |
int centerSize = mCenterTexture.getWidth();
|
|
| 246 |
int centerSize = mCenterEffects.getStartchX();
|
|
| 248 | 247 |
|
| 249 | 248 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
| 250 | 249 |
{
|
| ... | ... | |
| 268 | 267 |
mScaleCenter.set(factorCen,factorCen,factorCen); |
| 269 | 268 |
mMoveRegion.set( (width -mFactorObj*mObjWidth )/2 ,(height-mFactorObj*mObjHeight)/2 , 12 ); |
| 270 | 269 |
|
| 271 |
int backgroundSize = mBackgroundTexture.getWidth();
|
|
| 270 |
int backgroundSize = mBackgroundEffects.getStartchX();
|
|
| 272 | 271 |
float factorBackX = ((float)width)/backgroundSize; |
| 273 | 272 |
float factorBackY = ((float)height)/backgroundSize; |
| 274 | 273 |
|
| src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
|---|---|---|
| 115 | 115 |
diHips.add(dMiddle); |
| 116 | 116 |
diHips.add(dBegin); |
| 117 | 117 |
|
| 118 |
mEffects = new DistortedEffects(); |
|
| 118 |
mEffects = new DistortedEffects(1);
|
|
| 119 | 119 |
|
| 120 | 120 |
mEffects.apply( new VertexEffectSink ( diSink, pLeft , sinkRegion) ); |
| 121 | 121 |
mEffects.apply( new VertexEffectSink ( diSink, pRight, sinkRegion) ); |
| ... | ... | |
| 210 | 210 |
bmpHeight = bitmap.getHeight(); |
| 211 | 211 |
bmpWidth = bitmap.getWidth(); |
| 212 | 212 |
|
| 213 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight); |
|
| 213 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
| 214 |
|
|
| 215 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 214 | 216 |
mTexture.setTexture(bitmap); |
| 215 | 217 |
|
| 216 | 218 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
| src/main/java/org/distorted/examples/glow/GlowRenderer.java | ||
|---|---|---|
| 66 | 66 |
|
| 67 | 67 |
mRootW = LEAF_SIZE; |
| 68 | 68 |
mRootH = LEAF_SIZE; |
| 69 |
mLeaf = new DistortedTexture(mRootW,mRootH);
|
|
| 69 |
mLeaf = new DistortedTexture(); |
|
| 70 | 70 |
mMove = new Static3D(0,0,0); |
| 71 | 71 |
mScale = new Static3D(1,1,1); |
| 72 | 72 |
mRadius= new Static1D(25); |
| ... | ... | |
| 74 | 74 |
|
| 75 | 75 |
mGlow = new PostprocessEffectGlow(mRadius,mColor); |
| 76 | 76 |
|
| 77 |
DistortedEffects effects = new DistortedEffects(); |
|
| 77 |
DistortedEffects effects = new DistortedEffects(mRootW,mRootH,0);
|
|
| 78 | 78 |
effects.apply(new MatrixEffectScale(mScale)); |
| 79 | 79 |
effects.apply(new MatrixEffectMove(mMove)); |
| 80 | 80 |
effects.apply(mGlow); |
| src/main/java/org/distorted/examples/inflate/InflateActivity2.java | ||
|---|---|---|
| 54 | 54 |
private TextView mTextLevel; |
| 55 | 55 |
private DistortedTexture mTexture; |
| 56 | 56 |
private MeshBase mMesh; |
| 57 |
private int mNumCols, mNumRows, mNumSlic; |
|
| 57 | 58 |
|
| 58 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 | 60 |
|
| ... | ... | |
| 98 | 99 |
|
| 99 | 100 |
String str = b.getString("string");
|
| 100 | 101 |
int objectType = b.getInt("type");
|
| 101 |
int numCols = b.getInt("cols");
|
|
| 102 |
int numRows = b.getInt("rows");
|
|
| 103 |
int numSlic = b.getInt("slices");
|
|
| 104 | 102 |
int bitmapID = b.getInt("bitmap");
|
| 103 |
mNumCols = b.getInt("cols");
|
|
| 104 |
mNumRows = b.getInt("rows");
|
|
| 105 |
mNumSlic = b.getInt("slices");
|
|
| 105 | 106 |
|
| 106 |
int maxsize = numCols > numRows ? (numCols>numSlic ? numCols:numSlic) : (numRows>numSlic ? numRows:numSlic) ;
|
|
| 107 |
int maxsize = mNumCols > mNumRows ? (mNumCols>mNumSlic ? mNumCols:mNumSlic) : (mNumRows>mNumSlic ? mNumRows:mNumSlic) ;
|
|
| 107 | 108 |
|
| 108 | 109 |
createBitmap(maxsize,bitmapID); |
| 109 | 110 |
|
| ... | ... | |
| 111 | 112 |
{
|
| 112 | 113 |
case 0: if( bitmapID!=-1 ) |
| 113 | 114 |
{
|
| 114 |
mMesh = new MeshCubes(numCols, str, numSlic);
|
|
| 115 |
mMesh = new MeshCubes(mNumCols, str, mNumSlic);
|
|
| 115 | 116 |
} |
| 116 | 117 |
else |
| 117 | 118 |
{
|
| 118 |
Static4D mapFB = new Static4D(0.0f,0.0f, (float)numCols/maxsize, (float)numRows/maxsize);
|
|
| 119 |
Static4D mapLR = new Static4D(0.0f,0.0f, (float)numSlic/maxsize, (float)numRows/maxsize);
|
|
| 120 |
Static4D mapTB = new Static4D(0.0f,0.0f, (float)numCols/maxsize, (float)numSlic/maxsize);
|
|
| 119 |
Static4D mapFB = new Static4D(0.0f,0.0f, (float)mNumCols/maxsize, (float)mNumRows/maxsize);
|
|
| 120 |
Static4D mapLR = new Static4D(0.0f,0.0f, (float)mNumSlic/maxsize, (float)mNumRows/maxsize);
|
|
| 121 |
Static4D mapTB = new Static4D(0.0f,0.0f, (float)mNumCols/maxsize, (float)mNumSlic/maxsize);
|
|
| 121 | 122 |
|
| 122 |
mMesh = new MeshCubes(numCols, str, numSlic, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB);
|
|
| 123 |
mMesh = new MeshCubes(mNumCols, str, mNumSlic, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB);
|
|
| 123 | 124 |
} |
| 124 | 125 |
break; |
| 125 |
case 1: mMesh = new MeshRectangles(numCols,numRows);
|
|
| 126 |
case 1: mMesh = new MeshRectangles(mNumCols,mNumRows);
|
|
| 126 | 127 |
break; |
| 127 |
case 2: mMesh = new MeshSphere(numRows);
|
|
| 128 |
case 2: mMesh = new MeshSphere(mNumRows);
|
|
| 128 | 129 |
break; |
| 129 | 130 |
case 3: mMesh = new MeshQuad(); |
| 130 | 131 |
break; |
| 131 | 132 |
} |
| 132 | 133 |
|
| 133 |
mTexture = new DistortedTexture(numCols,numRows);
|
|
| 134 |
mTexture = new DistortedTexture(); |
|
| 134 | 135 |
|
| 135 | 136 |
setContentView(R.layout.inflatelayout); |
| 136 | 137 |
|
| ... | ... | |
| 263 | 264 |
{
|
| 264 | 265 |
return mMesh; |
| 265 | 266 |
} |
| 267 |
|
|
| 268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 269 |
|
|
| 270 |
public int getNumCols() |
|
| 271 |
{
|
|
| 272 |
return mNumCols; |
|
| 273 |
} |
|
| 274 |
|
|
| 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 276 |
|
|
| 277 |
public int getNumRows() |
|
| 278 |
{
|
|
| 279 |
return mNumRows; |
|
| 280 |
} |
|
| 281 |
|
|
| 282 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 283 |
|
|
| 284 |
public int getNumSlic() |
|
| 285 |
{
|
|
| 286 |
return mNumSlic; |
|
| 287 |
} |
|
| 266 | 288 |
} |
| src/main/java/org/distorted/examples/inflate/InflateRenderer.java | ||
|---|---|---|
| 72 | 72 |
InflateActivity2 act = (InflateActivity2)v.getContext(); |
| 73 | 73 |
|
| 74 | 74 |
mTexture = act.getTexture(); |
| 75 |
mMesh = act.getMesh(); |
|
| 75 |
mMesh = act.getMesh();
|
|
| 76 | 76 |
|
| 77 |
mObjWidth = mTexture.getWidth();
|
|
| 78 |
mObjHeight= mTexture.getHeight();
|
|
| 79 |
mObjDepth = mTexture.getDepth(mMesh);
|
|
| 77 |
mObjWidth = act.getNumCols();
|
|
| 78 |
mObjHeight= act.getNumRows();
|
|
| 79 |
mObjDepth = act.getNumSlic();
|
|
| 80 | 80 |
|
| 81 | 81 |
mQuat1 = new Static4D(0,0,0,1); // unity |
| 82 | 82 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
| ... | ... | |
| 87 | 87 |
quatInt1.add(mQuat1); |
| 88 | 88 |
quatInt2.add(mQuat2); |
| 89 | 89 |
|
| 90 |
mEffects = new DistortedEffects(); |
|
| 90 |
mEffects = new DistortedEffects(mObjWidth,mObjHeight,mObjDepth);
|
|
| 91 | 91 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
| 92 | 92 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
| 93 | 93 |
mEffects.apply( new MatrixEffectScale(mScale)); |
| src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
|---|---|---|
| 66 | 66 |
ListenerRenderer(GLSurfaceView v) |
| 67 | 67 |
{
|
| 68 | 68 |
mView = v; |
| 69 |
mEffects = new DistortedEffects(); |
|
| 69 |
|
|
| 70 | 70 |
mScreen = new DistortedScreen(); |
| 71 | 71 |
mRnd = new Random(0); |
| 72 | 72 |
|
| 73 | 73 |
mMove = new Static3D(0,0,0); |
| 74 | 74 |
mScale= new Static3D(1,1,1); |
| 75 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
| 76 |
mEffects.apply(new MatrixEffectMove(mMove)); |
|
| 77 | 75 |
} |
| 78 | 76 |
|
| 79 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 162 | 160 |
bmpHeight = bitmap.getHeight(); |
| 163 | 161 |
bmpWidth = bitmap.getWidth(); |
| 164 | 162 |
|
| 165 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
| 163 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 166 | 164 |
mTexture.setTexture(bitmap); |
| 167 | 165 |
|
| 168 | 166 |
if( mMesh==null ) mMesh = new MeshRectangles(50,50*bmpHeight/bmpWidth); |
| 169 | 167 |
|
| 168 |
if( mEffects==null ) |
|
| 169 |
{
|
|
| 170 |
mEffects = new DistortedEffects(bmpWidth,bmpHeight,0); |
|
| 171 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
| 172 |
mEffects.apply(new MatrixEffectMove(mMove)); |
|
| 173 |
} |
|
| 174 |
|
|
| 170 | 175 |
mScreen.detachAll(); |
| 171 | 176 |
mScreen.attach(mTexture,mEffects,mMesh); |
| 172 | 177 |
|
| src/main/java/org/distorted/examples/mirror/MirrorRenderer.java | ||
|---|---|---|
| 55 | 55 |
private static final float MIRROR_MOVE_V =0.22f; // Move the mirror up |
| 56 | 56 |
|
| 57 | 57 |
private GLSurfaceView mView; |
| 58 |
private DistortedEffects mEffectsMirror, mEffectsHead, mEffectsNull;
|
|
| 58 |
private DistortedEffects mEffectsMirror, mEffectsHead, mEffectsScreen;
|
|
| 59 | 59 |
private DistortedEffects mEffectsOffscreen1, mEffectsOffscreen2; |
| 60 | 60 |
private DistortedTexture mTextureMirror, mTextureHead; |
| 61 | 61 |
private DistortedFramebuffer mOffScreen1, mOffScreen2; |
| ... | ... | |
| 75 | 75 |
mQuad = new MeshRectangles(1,1); |
| 76 | 76 |
mScreen = new DistortedScreen(); |
| 77 | 77 |
|
| 78 |
mEffectsMirror = new DistortedEffects(); |
|
| 79 |
mEffectsHead = new DistortedEffects(); |
|
| 80 |
mEffectsOffscreen1= new DistortedEffects(); |
|
| 81 |
mEffectsOffscreen2= new DistortedEffects(); |
|
| 82 |
mEffectsNull = new DistortedEffects();
|
|
| 78 |
mEffectsMirror = new DistortedEffects(1);
|
|
| 79 |
mEffectsHead = new DistortedEffects(1);
|
|
| 80 |
mEffectsOffscreen1= new DistortedEffects(1);
|
|
| 81 |
mEffectsOffscreen2= new DistortedEffects(1);
|
|
| 82 |
mEffectsScreen = new DistortedEffects(1);
|
|
| 83 | 83 |
|
| 84 | 84 |
mX = MirrorActivity.INIT_POSITION; |
| 85 | 85 |
|
| ... | ... | |
| 138 | 138 |
if( mOffScreen1!=null ) mOffScreen1.markForDeletion(); |
| 139 | 139 |
if( mOffScreen2!=null ) mOffScreen2.markForDeletion(); |
| 140 | 140 |
|
| 141 |
mOffScreen1 = new DistortedFramebuffer( mScreenW, mScreenH, 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL ); |
|
| 142 |
mOffScreen2 = new DistortedFramebuffer( (int)(MIRROR_SCALE*mScreenW), (int)(MIRROR_SCALE*mScreenH), 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL ); |
|
| 141 |
int offscreen1W = mScreenW; |
|
| 142 |
int offscreen1H = mScreenH; |
|
| 143 |
int offscreen2W = (int)(MIRROR_SCALE*mScreenW); |
|
| 144 |
int offscreen2H = (int)(MIRROR_SCALE*mScreenH); |
|
| 145 |
|
|
| 146 |
mEffectsOffscreen1.setStretch(offscreen1W, offscreen1H, 0); |
|
| 147 |
mEffectsOffscreen2.setStretch(offscreen2W, offscreen2H, 0); |
|
| 148 |
mEffectsScreen.setStretch(offscreen1W, offscreen1H, 0); |
|
| 149 |
|
|
| 150 |
mOffScreen1 = new DistortedFramebuffer( offscreen1W, offscreen1H, 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL ); |
|
| 151 |
mOffScreen2 = new DistortedFramebuffer( offscreen2W, offscreen2H, 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL ); |
|
| 143 | 152 |
|
| 144 | 153 |
mScaleMirror.set( (float)mScreenW/mMirrorW, (float)mScreenH/mMirrorH, 1.0f); |
| 145 | 154 |
mMoveOffscreen2.set( MIRROR_MOVE_H*mScreenW, MIRROR_MOVE_V*mScreenH*mMirrorW/mMirrorH, 0); |
| ... | ... | |
| 155 | 164 |
mOffScreen2.attach( mOffScreen1 , mEffectsOffscreen1, mQuad ); |
| 156 | 165 |
|
| 157 | 166 |
mScreen.detachAll(); |
| 158 |
mScreen.attach ( mOffScreen1 , mEffectsNull , mQuad );
|
|
| 167 |
mScreen.attach ( mOffScreen1 , mEffectsScreen , mQuad );
|
|
| 159 | 168 |
mScreen.resize(mScreenW,mScreenH); |
| 160 | 169 |
} |
| 161 | 170 |
} |
| ... | ... | |
| 189 | 198 |
mHeadW = bitmapH.getWidth(); |
| 190 | 199 |
mHeadH = bitmapH.getHeight(); |
| 191 | 200 |
|
| 192 |
if( mTextureMirror==null ) mTextureMirror = new DistortedTexture(mMirrorW,mMirrorH); |
|
| 193 |
if( mTextureHead ==null ) mTextureHead = new DistortedTexture(mHeadW, mHeadH); |
|
| 201 |
mEffectsMirror.setStretch(mMirrorW,mMirrorH,0); |
|
| 202 |
mEffectsHead.setStretch(mHeadW, mHeadH,0); |
|
| 203 |
|
|
| 204 |
if( mTextureMirror==null ) mTextureMirror = new DistortedTexture(); |
|
| 205 |
if( mTextureHead ==null ) mTextureHead = new DistortedTexture(); |
|
| 194 | 206 |
|
| 195 | 207 |
mTextureMirror.setTexture(bitmapM); |
| 196 | 208 |
mTextureHead.setTexture(bitmapH); |
| src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
|---|---|---|
| 84 | 84 |
dRight.add( new Static3D( 0, 0, 0) ); |
| 85 | 85 |
dRight.add( new Static3D( 20, 10, 0) ); |
| 86 | 86 |
|
| 87 |
mEffects = new DistortedEffects(); |
|
| 87 |
mEffects = new DistortedEffects(1);
|
|
| 88 | 88 |
mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) ); |
| 89 | 89 |
mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) ); |
| 90 | 90 |
|
| ... | ... | |
| 150 | 150 |
bmpHeight = bitmap.getHeight(); |
| 151 | 151 |
bmpWidth = bitmap.getWidth(); |
| 152 | 152 |
|
| 153 |
// This will make the Mesh stretched by bmpWidth x bmpHeight even before any effects |
|
| 154 |
// are applied to it (the Mesh - MeshRectangles - is flat, so the third parameter does not |
|
| 155 |
// not matter). bmpWight x bmpHeight is the size of the Bitmap, thus this means that we can |
|
| 156 |
// conveniently work with Effects thinking in Bitmap's native size in pixels. The origin is |
|
| 157 |
// in Bitmap's lower-left corner, thus e.g. a rotation which is meant to rotate the bitmap |
|
| 158 |
// around its center has to be centered at (bmpWidth/2, bmpHeight/2, 0). |
|
| 159 |
// Without this call, the default size of the Mesh is 1x1x0 ( or 1x1x1 in case of not-flat |
|
| 160 |
// Meshes) so we would need to be rotating around (0.5,0.5,0.0). |
|
| 161 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
| 162 |
|
|
| 153 | 163 |
// We could have gotten here after the activity went to the background |
| 154 | 164 |
// for a brief amount of time; in this case mTexture is already created. |
| 155 | 165 |
// Do not leak memory by creating it the second time around. |
| 156 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
| 166 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 157 | 167 |
|
| 158 | 168 |
// likewise the Mesh |
| 159 | 169 |
if( mMesh==null ) mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth); |
| src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
|---|---|---|
| 65 | 65 |
mPaint.setStyle(Style.FILL); |
| 66 | 66 |
|
| 67 | 67 |
mView = v; |
| 68 |
mEffects= new DistortedEffects(); |
|
| 68 |
mEffects= new DistortedEffects(1);
|
|
| 69 | 69 |
mScreen = new DistortedScreen(); |
| 70 | 70 |
mRefresh= true; |
| 71 | 71 |
} |
| ... | ... | |
| 137 | 137 |
texH = height; |
| 138 | 138 |
|
| 139 | 139 |
if( mTexture!=null ) mTexture.markForDeletion(); |
| 140 |
mTexture = new DistortedTexture(texW,texH);
|
|
| 140 |
mTexture = new DistortedTexture(); |
|
| 141 | 141 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
| 142 | 142 |
mCanvas = new Canvas(mBitmap); |
| 143 | 143 |
|
| 144 |
mEffects.setStretch(texW,texH,0); |
|
| 145 |
|
|
| 144 | 146 |
if( mMesh!=null ) mMesh.markForDeletion(); |
| 145 | 147 |
mMesh = new MeshRectangles(80,80*texH/texW); |
| 146 | 148 |
|
| src/main/java/org/distorted/examples/movingglow/MovingGlowRenderer.java | ||
|---|---|---|
| 76 | 76 |
mRootW = 5*LEAF_SIZE; |
| 77 | 77 |
mRootH = 5*LEAF_SIZE; |
| 78 | 78 |
|
| 79 |
mLeaf = new DistortedTexture(LEAF_SIZE,LEAF_SIZE);
|
|
| 80 |
DistortedTexture surface = new DistortedTexture(mRootW,mRootH);
|
|
| 79 |
mLeaf = new DistortedTexture(); |
|
| 80 |
DistortedTexture surface = new DistortedTexture(); |
|
| 81 | 81 |
MeshBase mesh = new MeshRectangles(1,1); |
| 82 | 82 |
|
| 83 |
DistortedNode root = new DistortedNode(surface, new DistortedEffects(), mesh); |
|
| 83 |
DistortedNode root = new DistortedNode(surface, new DistortedEffects(mRootW,mRootH,0), mesh);
|
|
| 84 | 84 |
|
| 85 | 85 |
Static3D moveVector = new Static3D(0.55f*LEAF_SIZE, (mRootH-LEAF_SIZE)/2, 0); |
| 86 | 86 |
Static1D chromaLevel= new Static1D(0.5f); |
| ... | ... | |
| 91 | 91 |
|
| 92 | 92 |
for(int j=0; j<NUM_LEAVES; j++) |
| 93 | 93 |
{
|
| 94 |
mLeafEffects[j] = new DistortedEffects(); |
|
| 94 |
mLeafEffects[j] = new DistortedEffects(LEAF_SIZE,LEAF_SIZE,0);
|
|
| 95 | 95 |
mLeafEffects[j].apply(leafMove); |
| 96 | 96 |
mLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) ); |
| 97 | 97 |
mLeafEffects[j].apply( new FragmentEffectChroma(chromaLevel, new Static3D(colors[3*j],colors[3*j+1], colors[3*j+2])) ); |
| src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java | ||
|---|---|---|
| 94 | 94 |
for(int i=0; i<NUM_OBJECTS; i++) |
| 95 | 95 |
{
|
| 96 | 96 |
mMoveVector[i] = new Static3D(0,0,0); |
| 97 |
effects[i] = new DistortedEffects(); |
|
| 97 |
effects[i] = new DistortedEffects(OBJ_SIZE,OBJ_SIZE,OBJ_SIZE);
|
|
| 98 | 98 |
mBlurStatus[i] = false; |
| 99 | 99 |
} |
| 100 | 100 |
|
| ... | ... | |
| 102 | 102 |
|
| 103 | 103 |
MeshCubes mesh = new MeshCubes(1,1,1); |
| 104 | 104 |
|
| 105 |
mTex1 = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
|
|
| 106 |
mTex2 = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
|
|
| 105 |
mTex1 = new DistortedTexture(); |
|
| 106 |
mTex2 = new DistortedTexture(); |
|
| 107 | 107 |
|
| 108 | 108 |
mQuat1 = new Static4D(0,0,0,1); // unity |
| 109 | 109 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
| src/main/java/org/distorted/examples/objecttree/ObjectTreeRenderer.java | ||
|---|---|---|
| 78 | 78 |
chromaDyn.add(new Static1D(0.0f)); |
| 79 | 79 |
chromaDyn.add(new Static1D(0.8f)); |
| 80 | 80 |
|
| 81 |
mEffects= new DistortedEffects(); |
|
| 81 |
mEffects= new DistortedEffects(1);
|
|
| 82 | 82 |
mEffects.apply(new MatrixEffectScale(mScale)); |
| 83 | 83 |
mEffects.apply(new MatrixEffectMove(mMove)); |
| 84 | 84 |
mEffects.apply(new FragmentEffectChroma(chromaDyn, new Static3D(0,0,1))); |
| ... | ... | |
| 169 | 169 |
} |
| 170 | 170 |
catch(IOException e) { }
|
| 171 | 171 |
} |
| 172 |
|
|
| 172 |
|
|
| 173 |
final int GRID = 20; |
|
| 174 |
final Static4D mapFB = new Static4D(0.0f,0.0f,1.0f ,1.0f ); |
|
| 175 |
final Static4D mapLR = new Static4D(0.0f,0.0f,1.0f/GRID,1.0f ); |
|
| 176 |
final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f ,1.0f/GRID); |
|
| 177 |
|
|
| 173 | 178 |
lisaWidth = bitmap1.getWidth(); |
| 174 | 179 |
lisaHeight = bitmap1.getHeight(); |
| 175 | 180 |
int gridWidth = bitmap2.getWidth(); |
| 176 | 181 |
int gridHeight= bitmap2.getHeight(); |
| 182 |
int gridDepth = gridWidth/GRID; |
|
| 177 | 183 |
|
| 178 |
if( mLisaTexture==null ) mLisaTexture = new DistortedTexture(lisaWidth,lisaHeight); |
|
| 179 |
if( mGridTexture==null ) mGridTexture = new DistortedTexture(gridWidth,gridHeight); |
|
| 184 |
mEffects.setStretch(lisaWidth,lisaHeight,0); |
|
| 185 |
|
|
| 186 |
if( mLisaTexture==null ) mLisaTexture = new DistortedTexture(); |
|
| 187 |
if( mGridTexture==null ) mGridTexture = new DistortedTexture(); |
|
| 180 | 188 |
mLisaTexture.setTexture(bitmap1); |
| 181 | 189 |
mGridTexture.setTexture(bitmap2); |
| 182 |
DistortedEffects gridEffects = new DistortedEffects(); |
|
| 183 | 190 |
|
| 184 |
final int GRID = 20; |
|
| 185 |
final Static4D mapFB = new Static4D(0.0f,0.0f,1.0f ,1.0f ); |
|
| 186 |
final Static4D mapLR = new Static4D(0.0f,0.0f,1.0f/GRID,1.0f ); |
|
| 187 |
final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f ,1.0f/GRID); |
|
| 191 |
DistortedEffects gridEffects = new DistortedEffects(gridWidth,gridHeight,gridDepth); |
|
| 188 | 192 |
|
| 189 | 193 |
if( mMeshRectangles ==null ) mMeshRectangles = new MeshRectangles(1,1); |
| 190 | 194 |
if( mMeshCubes==null) mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
| 191 | 195 |
|
| 192 |
int gridDepth = mGridTexture.getDepth(mMeshCubes); |
|
| 193 |
|
|
| 194 | 196 |
mRoot = new DistortedNode(mLisaTexture, mEffects, mMeshRectangles); |
| 195 | 197 |
mRoot.attach(mGridTexture,gridEffects,mMeshCubes); |
| 196 | 198 |
|
| src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
|---|---|---|
| 93 | 93 |
mPrevRendered = -1; |
| 94 | 94 |
mCurrRendered = -1; |
| 95 | 95 |
|
| 96 |
mLeaf = new DistortedTexture(LEAF_SIZE,LEAF_SIZE); |
|
| 97 |
DistortedTexture surface = new DistortedTexture(3*LEAF_SIZE,3*LEAF_SIZE); |
|
| 96 |
mScreenW = 9*LEAF_SIZE; |
|
| 97 |
mScreenH = 9*LEAF_SIZE; |
|
| 98 |
|
|
| 99 |
mLeaf = new DistortedTexture(); |
|
| 100 |
DistortedTexture surface = new DistortedTexture(); |
|
| 98 | 101 |
mMesh = new MeshRectangles(1,1); |
| 99 | 102 |
mMove = new Static3D(0,0,0); |
| 100 | 103 |
mScale= new Static3D(1,1,1); |
| 101 | 104 |
|
| 102 |
DistortedEffects effects = new DistortedEffects();
|
|
| 103 |
effects.apply(new MatrixEffectScale(mScale));
|
|
| 104 |
effects.apply(new MatrixEffectMove(mMove));
|
|
| 105 |
DistortedEffects rootEffects = new DistortedEffects(mScreenW,mScreenH,0);
|
|
| 106 |
rootEffects.apply(new MatrixEffectScale(mScale));
|
|
| 107 |
rootEffects.apply(new MatrixEffectMove(mMove));
|
|
| 105 | 108 |
|
| 106 |
mScreenW = 9*LEAF_SIZE; |
|
| 107 |
mScreenH = 9*LEAF_SIZE; |
|
| 108 |
mRoot = new DistortedNode(new DistortedTexture(mScreenW,mScreenH), effects, mMesh); |
|
| 109 |
mRoot = new DistortedNode(new DistortedTexture(), rootEffects, mMesh); |
|
| 109 | 110 |
|
| 110 | 111 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
| 111 | 112 |
rot.setMode(Dynamic1D.MODE_JUMP); |
| ... | ... | |
| 121 | 122 |
|
| 122 | 123 |
for(int j=0; j<NUM_LEAVES; j++) |
| 123 | 124 |
{
|
| 124 |
mEffects[j] = new DistortedEffects(); |
|
| 125 |
mEffects[j] = new DistortedEffects(LEAF_SIZE,LEAF_SIZE,0);
|
|
| 125 | 126 |
mEffects[j].apply(new MatrixEffectMove(moveVector)); |
| 126 | 127 |
mEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) ); |
| 127 | 128 |
} |
| 128 | 129 |
|
| 129 | 130 |
for(int i=0; i<NUM_CIRCLES; i++) |
| 130 | 131 |
{
|
| 131 |
effects = new DistortedEffects();
|
|
| 132 |
DistortedEffects effects = new DistortedEffects(3*LEAF_SIZE,3*LEAF_SIZE,0);
|
|
| 132 | 133 |
effects.apply( new MatrixEffectRotate(rot, axis, center) ); |
| 133 | 134 |
effects.apply( new MatrixEffectMove(new Static3D(positions[2*i], positions[2*i+1], 0)) ); |
| 134 | 135 |
effects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2])) ); |
| src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
|---|---|---|
| 95 | 95 |
dRight.add( new Static3D( 0, 0, 0) ); |
| 96 | 96 |
dRight.add( new Static3D( 20, 10, 0) ); |
| 97 | 97 |
|
| 98 |
mEffects = new DistortedEffects(); |
|
| 98 |
mEffects = new DistortedEffects(1);
|
|
| 99 | 99 |
mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) ); |
| 100 | 100 |
mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) ); |
| 101 | 101 |
|
| ... | ... | |
| 262 | 262 |
bmpHeight = bmp.getHeight(); |
| 263 | 263 |
bmpWidth = bmp.getWidth(); |
| 264 | 264 |
|
| 265 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight); |
|
| 265 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
| 266 |
|
|
| 267 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 266 | 268 |
mTexture.setTexture(bmp); |
| 267 | 269 |
|
| 268 | 270 |
if( mMesh==null ) mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth); |
| src/main/java/org/distorted/examples/postprocesstree/PostprocessTreeRenderer.java | ||
|---|---|---|
| 76 | 76 |
radiusDyn.add(mRadius); |
| 77 | 77 |
PostprocessEffectBlur blurEffect = new PostprocessEffectBlur(radiusDyn); |
| 78 | 78 |
|
| 79 |
mLeaf = new DistortedTexture(LEAF_SIZE,LEAF_SIZE);
|
|
| 79 |
mLeaf = new DistortedTexture(); |
|
| 80 | 80 |
|
| 81 | 81 |
MeshRectangles mesh = new MeshRectangles(1,1); |
| 82 | 82 |
mMove = new Static3D(0,0,0); |
| 83 | 83 |
mScale= new Static3D(1,1,1); |
| 84 | 84 |
|
| 85 |
DistortedEffects rootEffects = new DistortedEffects(); |
|
| 86 |
DistortedEffects innerEffects = new DistortedEffects(); |
|
| 85 |
DistortedEffects rootEffects = new DistortedEffects(mScreenW,mScreenH,0);
|
|
| 86 |
DistortedEffects innerEffects = new DistortedEffects(INNER*LEAF_SIZE,INNER*LEAF_SIZE,0);
|
|
| 87 | 87 |
DistortedEffects[] innerLeafEffects= new DistortedEffects[NUM_LEAVES]; |
| 88 | 88 |
DistortedEffects[] outerLeafEffects= new DistortedEffects[NUM_LEAVES]; |
| 89 | 89 |
|
| 90 |
DistortedNode root = new DistortedNode(new DistortedTexture(mScreenW,mScreenH), rootEffects, mesh);
|
|
| 90 |
DistortedNode root = new DistortedNode(new DistortedTexture(), rootEffects, mesh); |
|
| 91 | 91 |
|
| 92 | 92 |
rootEffects.apply(new MatrixEffectScale(mScale)); |
| 93 | 93 |
rootEffects.apply(new MatrixEffectMove(mMove)); |
| ... | ... | |
| 107 | 107 |
|
| 108 | 108 |
for(int j=0; j<NUM_LEAVES; j++) |
| 109 | 109 |
{
|
| 110 |
outerLeafEffects[j] = new DistortedEffects(); |
|
| 110 |
outerLeafEffects[j] = new DistortedEffects(LEAF_SIZE,LEAF_SIZE,0);
|
|
| 111 | 111 |
outerLeafEffects[j].apply(new MatrixEffectMove(outerMoveVector)); |
| 112 | 112 |
outerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, outerCenter) ); |
| 113 | 113 |
|
| ... | ... | |
| 119 | 119 |
innerEffects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0) ) ); |
| 120 | 120 |
innerEffects.apply(blurEffect); |
| 121 | 121 |
|
| 122 |
DistortedNode innerNode = new DistortedNode( new DistortedTexture(INNER*LEAF_SIZE,INNER*LEAF_SIZE), innerEffects, mesh);
|
|
| 122 |
DistortedNode innerNode = new DistortedNode( new DistortedTexture(), innerEffects, mesh); |
|
| 123 | 123 |
root.attach(innerNode); |
| 124 | 124 |
|
| 125 | 125 |
for(int j=0; j<NUM_LEAVES; j++) |
| 126 | 126 |
{
|
| 127 |
innerLeafEffects[j] = new DistortedEffects(); |
|
| 127 |
innerLeafEffects[j] = new DistortedEffects(LEAF_SIZE,LEAF_SIZE,0);
|
|
| 128 | 128 |
innerLeafEffects[j].apply(new MatrixEffectMove(innerMoveVector)); |
| 129 | 129 |
innerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, innerCenter) ); |
| 130 | 130 |
|
| src/main/java/org/distorted/examples/projection/ProjectionRenderer.java | ||
|---|---|---|
| 56 | 56 |
ProjectionRenderer(GLSurfaceView view) |
| 57 | 57 |
{
|
| 58 | 58 |
mView = view; |
| 59 |
mEffects= new DistortedEffects(); |
|
| 59 |
mEffects= new DistortedEffects(1);
|
|
| 60 | 60 |
mScreen = new DistortedScreen(); |
| 61 | 61 |
|
| 62 | 62 |
mVector = new Static3D(0,0,0); |
| ... | ... | |
| 130 | 130 |
mPoint3.set( width/4, 3*height/4, 0); |
| 131 | 131 |
mPoint4.set(3*width/4, 3*height/4, 0); |
| 132 | 132 |
|
| 133 |
mEffects.setStretch(width,height,0); |
|
| 134 |
|
|
| 133 | 135 |
// Avoid memory leaks: delete old texture if it exists (it might if we |
| 134 | 136 |
// got here after a brief amount of time spent in the background) |
| 135 | 137 |
if( mTexture!=null ) mTexture.markForDeletion(); |
| 136 | 138 |
|
| 137 |
mTexture= new DistortedTexture(width,height);
|
|
| 139 |
mTexture= new DistortedTexture(); |
|
| 138 | 140 |
mTexture.setTexture(bmp); |
| 139 | 141 |
|
| 140 | 142 |
// likewise with the Mesh |
| src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
|---|---|---|
| 35 | 35 |
import org.distorted.library.main.DistortedLibrary; |
| 36 | 36 |
import org.distorted.library.main.DistortedScreen; |
| 37 | 37 |
import org.distorted.library.main.DistortedTexture; |
| 38 |
import org.distorted.library.mesh.MeshBase; |
|
| 39 | 38 |
import org.distorted.library.mesh.MeshCubes; |
| 40 | 39 |
import org.distorted.library.type.Dynamic; |
| 41 | 40 |
import org.distorted.library.type.DynamicQuat; |
| ... | ... | |
| 54 | 53 |
|
| 55 | 54 |
private GLSurfaceView mView; |
| 56 | 55 |
private DistortedTexture mTexture; |
| 57 |
private MeshBase mMesh; |
|
| 58 | 56 |
private DistortedScreen mScreen; |
| 59 | 57 |
private Static3D mMove, mScale, mCenter; |
| 60 | 58 |
|
| ... | ... | |
| 63 | 61 |
QuaternionRenderer(GLSurfaceView v) |
| 64 | 62 |
{
|
| 65 | 63 |
mView = v; |
| 66 |
mTexture = new DistortedTexture(1,1); |
|
| 67 |
mMesh = new MeshCubes(1,1,1); |
|
| 64 |
mTexture = new DistortedTexture(); |
|
| 68 | 65 |
|
| 69 |
DistortedEffects effects = new DistortedEffects(); |
|
| 66 |
DistortedEffects effects = new DistortedEffects(1);
|
|
| 70 | 67 |
DynamicQuat rot = new DynamicQuat(); |
| 71 | 68 |
|
| 72 | 69 |
Random rnd = new Random(System.currentTimeMillis()); |
| ... | ... | |
| 97 | 94 |
effects.apply( new MatrixEffectMove(mMove)); |
| 98 | 95 |
|
| 99 | 96 |
mScreen = new DistortedScreen(); |
| 100 |
mScreen.attach(mTexture,effects,mMesh);
|
|
| 97 |
mScreen.attach(mTexture,effects,new MeshCubes(1,1,1));
|
|
| 101 | 98 |
} |
| 102 | 99 |
|
| 103 | 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 111 | 108 |
|
| 112 | 109 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 113 | 110 |
{
|
| 114 |
float w = mTexture.getWidth(); |
|
| 115 |
float h = mTexture.getHeight(); |
|
| 116 |
float d = mTexture.getDepth(mMesh); |
|
| 111 |
float factor = 0.5f*(width>height ? height:width); |
|
| 117 | 112 |
|
| 118 |
float factor = 0.5f*(width>height ? height/h:width/w); |
|
| 119 |
|
|
| 120 |
mCenter.set(w/2,h/2,d/2); |
|
| 121 |
mMove.set( (width-factor*w)/2 , (height-factor*h)/2 , -factor*d/2 ); |
|
| 113 |
mCenter.set(0.5f,0.5f,0.5f); |
|
| 114 |
mMove.set( (width-factor)/2 , (height-factor)/2 , -factor/2 ); |
|
| 122 | 115 |
mScale.set(factor,factor,factor); |
| 123 | 116 |
|
| 124 | 117 |
mScreen.resize(width, height); |
| src/main/java/org/distorted/examples/rubik/RubikCube.java | ||
|---|---|---|
| 50 | 50 |
private static final int VECTZ = 2; |
| 51 | 51 |
|
| 52 | 52 |
private static final int ROTATION_MILLISEC = 1500; |
| 53 |
private static final int TEXTURE_SIZE = 100;
|
|
| 53 |
private static final int STRETCH_SIZE = 100;
|
|
| 54 | 54 |
|
| 55 | 55 |
private static final Static3D VectX = new Static3D(1,0,0); |
| 56 | 56 |
private static final Static3D VectY = new Static3D(0,1,0); |
| ... | ... | |
| 73 | 73 |
{
|
| 74 | 74 |
mSize = size; |
| 75 | 75 |
|
| 76 |
mTexture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
|
|
| 76 |
mTexture = new DistortedTexture(); |
|
| 77 | 77 |
|
| 78 | 78 |
mNodes = new DistortedNode[mSize][mSize][mSize]; |
| 79 | 79 |
mCubes = new MeshCubes[mSize][mSize][mSize]; |
| ... | ... | |
| 84 | 84 |
|
| 85 | 85 |
Static3D[][][] cubeVectors = new Static3D[mSize][mSize][mSize]; |
| 86 | 86 |
|
| 87 |
Static3D center = new Static3D(TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f);
|
|
| 88 |
Static4D region = new Static4D(0,0,0, TEXTURE_SIZE*0.72f);
|
|
| 87 |
Static3D center = new Static3D(STRETCH_SIZE*0.5f, STRETCH_SIZE*0.5f, STRETCH_SIZE*0.5f);
|
|
| 88 |
Static4D region = new Static4D(0,0,0, STRETCH_SIZE*0.72f);
|
|
| 89 | 89 |
|
| 90 | 90 |
VertexEffectSink sinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), center, region ); |
| 91 | 91 |
MatrixEffectMove moveEffect = new MatrixEffectMove(move); |
| ... | ... | |
| 130 | 130 |
tmpBottom= (y== 0 ? mapBottom:mapBlack); |
| 131 | 131 |
|
| 132 | 132 |
mCubes[x][y][z] = new MeshCubes(vertices,vertices,vertices, tmpFront, tmpBack, tmpLeft, tmpRight, tmpTop, tmpBottom); |
| 133 |
cubeVectors[x][y][z] = new Static3D( TEXTURE_SIZE*(x-nc), TEXTURE_SIZE*(y-nc), TEXTURE_SIZE*(z-nc) );
|
|
| 133 |
cubeVectors[x][y][z] = new Static3D( STRETCH_SIZE*(x-nc), STRETCH_SIZE*(y-nc), STRETCH_SIZE*(z-nc) );
|
|
| 134 | 134 |
mRotationAngle[x][y][z] = new Dynamic1D(); |
| 135 | 135 |
mRotationAxis[x][y][z] = new Static3D(1,0,0); |
| 136 | 136 |
|
| ... | ... | |
| 138 | 138 |
mRotationAngle[x][y][z].add(new Static1D(0.0f)); |
| 139 | 139 |
mRotate[x][y][z] = new MatrixEffectRotate( mRotationAngle[x][y][z], mRotationAxis[x][y][z], center); |
| 140 | 140 |
|
| 141 |
mEffects[x][y][z] = new DistortedEffects(); |
|
| 141 |
mEffects[x][y][z] = new DistortedEffects(STRETCH_SIZE,STRETCH_SIZE,STRETCH_SIZE);
|
|
| 142 | 142 |
mEffects[x][y][z].apply( new MatrixEffectMove(cubeVectors[x][y][z]) ); |
| 143 | 143 |
mEffects[x][y][z].apply( mRotate[x][y][z] ); |
| 144 | 144 |
mEffects[x][y][z].apply(quatEffect); |
| ... | ... | |
| 308 | 308 |
|
| 309 | 309 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 310 | 310 |
|
| 311 |
float getTextureSize()
|
|
| 311 |
float getStretchSize()
|
|
| 312 | 312 |
{
|
| 313 |
return TEXTURE_SIZE;
|
|
| 313 |
return STRETCH_SIZE;
|
|
| 314 | 314 |
} |
| 315 | 315 |
|
| 316 | 316 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/rubik/RubikRenderer.java | ||
|---|---|---|
| 155 | 155 |
private void recomputeScaleFactor(int screenWidth, int screenHeight) |
| 156 | 156 |
{
|
| 157 | 157 |
float cubeSizeInScreenSpace = CUBE_SCREEN_RATIO*(screenWidth>screenHeight ? screenHeight:screenWidth); |
| 158 |
float texSize = mCube.getTextureSize();
|
|
| 158 |
float texSize = mCube.getStretchSize();
|
|
| 159 | 159 |
float scaleFactor = cubeSizeInScreenSpace/(texSize*mCube.getSize()); |
| 160 | 160 |
|
| 161 | 161 |
mMove.set( (screenWidth-scaleFactor*texSize)/2 , (screenHeight-scaleFactor*texSize)/2 , -scaleFactor*texSize/2 ); |
| src/main/java/org/distorted/examples/rubik/RubikSurfaceView.java | ||
|---|---|---|
| 31 | 31 |
|
| 32 | 32 |
class RubikSurfaceView extends GLSurfaceView |
| 33 | 33 |
{
|
| 34 |
private WeakReference<RubikActivity> mWeakAct; |
|
| 35 |
|
|
| 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 37 |
|
|
| 38 | 34 |
public RubikSurfaceView(Context context, AttributeSet attrs) |
| 39 | 35 |
{
|
| 40 | 36 |
super(context,attrs); |
| 41 | 37 |
|
| 42 | 38 |
if(!isInEditMode()) |
| 43 | 39 |
{
|
| 44 |
mWeakAct = new WeakReference<>( (RubikActivity)context); |
|
| 45 |
|
|
| 46 | 40 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
| 47 | 41 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
| 48 | 42 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
| ... | ... | |
| 54 | 48 |
|
| 55 | 49 |
RubikActivity getRubikActivity() |
| 56 | 50 |
{
|
| 57 |
return mWeakAct.get();
|
|
| 51 |
return (RubikActivity)getContext();
|
|
| 58 | 52 |
} |
| 59 | 53 |
} |
| 60 | 54 |
|
| src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
|---|---|---|
| 93 | 93 |
mMove = new Static3D(0,0,0); |
| 94 | 94 |
mScaleMain = new Static3D(1,1,1); |
| 95 | 95 |
|
| 96 |
mEffects = new DistortedEffects(); |
|
| 96 |
mEffects = new DistortedEffects(1);
|
|
| 97 | 97 |
mEffects.apply( new VertexEffectSink(diSink, pLeft , sinkRegion) ); |
| 98 | 98 |
mEffects.apply( new VertexEffectSink(diSink, pRight, sinkRegion) ); |
| 99 | 99 |
mEffects.apply( new MatrixEffectScale(mScaleMain)); |
| ... | ... | |
| 245 | 245 |
bmpHeight = bitmap.getHeight(); |
| 246 | 246 |
bmpWidth = bitmap.getWidth(); |
| 247 | 247 |
|
| 248 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
| 249 |
|
|
| 248 | 250 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
| 249 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
| 251 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 250 | 252 |
mTexture.setTexture(bitmap); |
| 251 | 253 |
|
| 252 | 254 |
if( mOffscreen==null ) mOffscreen = new DistortedFramebuffer( (int)(mScale*bmpWidth) , (int)(mScale*bmpHeight), |
| src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
|---|---|---|
| 65 | 65 |
sink.add(new Static1D(1.0f)); |
| 66 | 66 |
sink.add(new Static1D(0.2f)); |
| 67 | 67 |
|
| 68 |
mEffects = new DistortedEffects(); |
|
| 68 |
mEffects = new DistortedEffects(1);
|
|
| 69 | 69 |
VertexEffectSink sinkEffect = new VertexEffectSink(sink, new Static3D(297, 280, 0), null); |
| 70 | 70 |
mEffects.apply(sinkEffect); |
| 71 | 71 |
|
| ... | ... | |
| 129 | 129 |
bmpHeight = bitmap.getHeight(); |
| 130 | 130 |
bmpWidth = bitmap.getWidth(); |
| 131 | 131 |
|
| 132 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight); |
|
| 132 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
| 133 |
|
|
| 134 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 133 | 135 |
mTexture.setTexture(bitmap); |
| 134 | 136 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
| 135 | 137 |
|
| src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
|---|---|---|
| 124 | 124 |
|
| 125 | 125 |
mQuad = new MeshRectangles(1,1); |
| 126 | 126 |
|
| 127 |
mGFFAEffects = new DistortedEffects(); |
|
| 128 |
mLogoEffects = new DistortedEffects(); |
|
| 129 |
mCrawlEffects = new DistortedEffects(); |
|
| 130 |
mCrawlBackgroundEffects = new DistortedEffects(); |
|
| 127 |
mGFFAEffects = new DistortedEffects(1);
|
|
| 128 |
mLogoEffects = new DistortedEffects(1);
|
|
| 129 |
mCrawlEffects = new DistortedEffects(1);
|
|
| 130 |
mCrawlBackgroundEffects = new DistortedEffects(1);
|
|
| 131 | 131 |
|
| 132 | 132 |
if( NUM_STARS>0 ) |
| 133 | 133 |
{
|
| 134 | 134 |
mStarEffects = new DistortedEffects[NUM_STARS]; |
| 135 |
mStarEffects[0] = new DistortedEffects(); |
|
| 135 |
mStarEffects[0] = new DistortedEffects(1);
|
|
| 136 | 136 |
|
| 137 | 137 |
for (int i = 1; i < NUM_STARS; i++) |
| 138 | 138 |
mStarEffects[i] = new DistortedEffects(mStarEffects[0], DistortedLibrary.CLONE_VERTEX); |
| ... | ... | |
| 205 | 205 |
double angleB = (90.0f - FOV_ANGLE/2 +CRAWL_ANGLE)*Math.PI/180; |
| 206 | 206 |
|
| 207 | 207 |
if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion(); |
| 208 |
mCrawlBackgroundTexture = new DistortedTexture(w,(int)(h*Math.sin(angleA)/Math.sin(angleB))); |
|
| 209 |
|
|
| 208 |
mCrawlBackgroundTexture = new DistortedTexture(); |
|
| 209 |
|
|
| 210 |
mCrawlBackgroundEffects.setStretch(w,(int)(h*Math.sin(angleA)/Math.sin(angleB)),0); |
|
| 211 |
|
|
| 210 | 212 |
int randomA, randomX, randomY, randomTime; |
| 211 | 213 |
float randomS, randomAlpha1, randomAlpha2; |
| 212 | 214 |
|
| ... | ... | |
| 238 | 240 |
mScreen.attach(mStarTexture, mStarEffects[i], mQuad); |
| 239 | 241 |
} |
| 240 | 242 |
|
| 241 |
float scale = (0.5f*w/mGFFATexture.getWidth());
|
|
| 243 |
float scale = (0.5f*w/mGFFAEffects.getStartchX());
|
|
| 242 | 244 |
|
| 243 | 245 |
Dynamic1D di = new Dynamic1D(6000,0.5f); |
| 244 | 246 |
di.add(new Static1D(1.0f)); |
| ... | ... | |
| 290 | 292 |
paint.setTypeface(tf); |
| 291 | 293 |
|
| 292 | 294 |
///// create GFFA /////////////////// |
| 293 |
if( mGFFATexture==null ) mGFFATexture = new DistortedTexture(GFFA_WIDTH,GFFA_HEIGHT); |
|
| 295 |
mGFFAEffects.setStretch(GFFA_WIDTH,GFFA_HEIGHT,0); |
|
| 296 |
if( mGFFATexture==null ) mGFFATexture = new DistortedTexture(); |
|
| 294 | 297 |
bitmapGFFA = Bitmap.createBitmap(GFFA_WIDTH,GFFA_HEIGHT,Bitmap.Config.ARGB_8888); |
| 295 | 298 |
bitmapGFFA.eraseColor(0x00000000); |
| 296 | 299 |
Canvas gffaCanvas = new Canvas(bitmapGFFA); |
| ... | ... | |
| 303 | 306 |
mGFFATexture.setTexture(bitmapGFFA); |
| 304 | 307 |
|
| 305 | 308 |
///// create Logo /////////////////// |
| 306 |
if( mLogoTexture==null ) mLogoTexture = new DistortedTexture(bitmapLogo.getWidth(),bitmapLogo.getHeight()); |
|
| 309 |
mLogoEffects.setStretch(bitmapLogo.getWidth(),bitmapLogo.getHeight(),0); |
|
| 310 |
if( mLogoTexture==null ) mLogoTexture = new DistortedTexture(); |
|
| 307 | 311 |
mLogoTexture.setTexture(bitmapLogo); |
| 308 | 312 |
|
| 309 | 313 |
///// create CRAWL ////////////////// |
| 310 |
if( mCrawlTexture==null ) mCrawlTexture = new DistortedTexture(CRAWL_WIDTH,CRAWL_HEIGHT); |
|
| 314 |
mCrawlEffects.setStretch(CRAWL_WIDTH,CRAWL_HEIGHT,0); |
|
| 315 |
if( mCrawlTexture==null ) mCrawlTexture = new DistortedTexture(); |
|
| 311 | 316 |
bitmapText = Bitmap.createBitmap(CRAWL_WIDTH,CRAWL_HEIGHT,Bitmap.Config.ARGB_8888); |
| 312 | 317 |
bitmapText.eraseColor(0x00000000); |
| 313 | 318 |
Canvas textCanvas = new Canvas(bitmapText); |
| ... | ... | |
| 321 | 326 |
mCrawlTexture.setTexture(bitmapText); |
| 322 | 327 |
|
| 323 | 328 |
///// create Stars /////////////////// |
| 324 |
if( mStarTexture==null ) mStarTexture = new DistortedTexture(bitmapStar.getWidth(),bitmapStar.getHeight()); |
|
| 329 |
mStarEffects[0].setStretch(bitmapStar.getWidth(),bitmapStar.getHeight(),0); |
|
| 330 |
if( mStarTexture==null ) mStarTexture = new DistortedTexture(); |
|
| 325 | 331 |
mStarTexture.setTexture(bitmapStar); |
| 326 | 332 |
} |
| 327 | 333 |
|
| ... | ... | |
| 379 | 385 |
int screenW=mScreen.getWidth(); |
| 380 | 386 |
int screenH=mScreen.getHeight(); |
| 381 | 387 |
|
| 382 |
int logoW = mLogoTexture.getWidth();
|
|
| 383 |
int logoH = mLogoTexture.getHeight();
|
|
| 388 |
int logoW = mLogoEffects.getStartchX();
|
|
| 389 |
int logoH = mLogoEffects.getStartchY();
|
|
| 384 | 390 |
|
| 385 | 391 |
int initSize= (int)(3.0f*screenW/logoW); |
| 386 | 392 |
int finaSize= (int)(0.1f*screenW/logoW); |
| ... | ... | |
| 403 | 409 |
mScreen.detach(mLogoEffects); |
| 404 | 410 |
mLogoTexture.markForDeletion(); |
| 405 | 411 |
|
| 406 |
int crawlW = mCrawlTexture.getWidth();
|
|
| 407 |
int crawlH = mCrawlTexture.getHeight();
|
|
| 412 |
int crawlW = mCrawlEffects.getStartchX();
|
|
| 413 |
int crawlH = mCrawlEffects.getStartchY();
|
|
| 408 | 414 |
int screenW= mScreen.getWidth(); |
| 409 |
int backH = mCrawlBackgroundTexture.getHeight();
|
|
| 415 |
int backH = mCrawlBackgroundEffects.getStartchY();
|
|
| 410 | 416 |
float scale= (float)screenW/crawlW; |
| 411 | 417 |
|
| 412 | 418 |
mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,0,0)) ); |
| src/main/java/org/distorted/examples/stencil/StencilRenderer.java | ||
|---|---|---|
| 36 | 36 |
import org.distorted.library.main.DistortedScreen; |
| 37 | 37 |
import org.distorted.library.main.DistortedTexture; |
| 38 | 38 |
import org.distorted.library.mesh.MeshCubes; |
| 39 |
import org.distorted.library.mesh.MeshBase; |
|
| 40 | 39 |
import org.distorted.library.mesh.MeshQuad; |
| 41 | 40 |
import org.distorted.library.type.Dynamic1D; |
| 42 | 41 |
import org.distorted.library.type.Static1D; |
Also available in: Unified diff
Move the 'pre-multiply mesh before applying any effects' thing from [(Xsize of texture, Ysize of texture) x Mesh's zFactor] to Effects.setStretch(sx,sy,sz)