Revision e8b6aa95
Added by Leszek Koltunski almost 9 years ago
| src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
|---|---|---|
| 26 | 26 |
|
| 27 | 27 |
import org.distorted.examples.R; |
| 28 | 28 |
import org.distorted.library.Distorted; |
| 29 |
import org.distorted.library.DistortedBitmap; |
|
| 29 |
import org.distorted.library.DistortedBitmapGrid;
|
|
| 30 | 30 |
import org.distorted.library.DistortedObject; |
| 31 | 31 |
import org.distorted.library.EffectTypes; |
| 32 | 32 |
import org.distorted.library.type.Static3D; |
| ... | ... | |
| 43 | 43 |
{
|
| 44 | 44 |
private GLSurfaceView mView; |
| 45 | 45 |
private DistortedObject mObject; |
| 46 |
private DistortedBitmapGrid mGrid; |
|
| 46 | 47 |
private AroundTheWorldEffectsManager mEffects; |
| 47 | 48 |
private int mObjWidth, mObjHeight; |
| 48 | 49 |
|
| ... | ... | |
| 69 | 70 |
public void onDrawFrame(GL10 glUnused) |
| 70 | 71 |
{
|
| 71 | 72 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 72 |
mObject.draw(System.currentTimeMillis()); |
|
| 73 |
mObject.draw(System.currentTimeMillis(), mGrid);
|
|
| 73 | 74 |
} |
| 74 | 75 |
|
| 75 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 118 | 119 |
catch(IOException e) { }
|
| 119 | 120 |
} |
| 120 | 121 |
|
| 121 |
mObject = new DistortedBitmap(bitmap.getWidth(),bitmap.getHeight(),30); |
|
| 122 | 122 |
|
| 123 | 123 |
mObjWidth = mObject.getWidth(); |
| 124 | 124 |
mObjHeight= mObject.getHeight(); |
| 125 | 125 |
|
| 126 |
mObject.setBitmap(bitmap); |
|
| 126 |
mObject = new DistortedObject(mObjWidth,mObjHeight,1); |
|
| 127 |
mObject.setTexture(bitmap); |
|
| 127 | 128 |
mEffects.apply(mObject); |
| 128 | 129 |
|
| 130 |
mGrid = new DistortedBitmapGrid(30,30*mObjHeight/mObjWidth); |
|
| 131 |
|
|
| 129 | 132 |
try |
| 130 | 133 |
{
|
| 131 | 134 |
Distorted.onSurfaceCreated(mView.getContext()); |
| src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
|---|---|---|
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.library.EffectTypes; |
| 31 | 31 |
import org.distorted.library.Distorted; |
| 32 |
import org.distorted.library.DistortedBitmap; |
|
| 32 |
import org.distorted.library.DistortedObject; |
|
| 33 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 33 | 34 |
import org.distorted.library.type.Dynamic3D; |
| 34 | 35 |
import org.distorted.library.type.Static3D; |
| 35 | 36 |
import org.distorted.library.type.Static4D; |
| ... | ... | |
| 44 | 45 |
class BeanRenderer implements GLSurfaceView.Renderer |
| 45 | 46 |
{
|
| 46 | 47 |
private GLSurfaceView mView; |
| 47 |
private DistortedBitmap mBean; |
|
| 48 |
private DistortedObject mBean; |
|
| 49 |
private DistortedBitmapGrid mGrid; |
|
| 48 | 50 |
private Static3D pLeft, pRight; |
| 49 | 51 |
private Dynamic3D dLeft, dRight; |
| 50 | 52 |
private Static4D rLeft, rRight; |
| ... | ... | |
| 88 | 90 |
public void onDrawFrame(GL10 glUnused) |
| 89 | 91 |
{
|
| 90 | 92 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 91 |
mBean.draw(System.currentTimeMillis()); |
|
| 93 |
mBean.draw(System.currentTimeMillis(), mGrid);
|
|
| 92 | 94 |
} |
| 93 | 95 |
|
| 94 | 96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 142 | 144 |
bmpHeight = bitmap.getHeight(); |
| 143 | 145 |
bmpWidth = bitmap.getWidth(); |
| 144 | 146 |
|
| 145 |
mBean = new DistortedBitmap(bitmap, 25); |
|
| 147 |
mBean = new DistortedObject(bmpWidth, bmpHeight, 1); |
|
| 148 |
mBean.setTexture(bitmap); |
|
| 146 | 149 |
mBean.distort(dLeft , pLeft , rLeft ); |
| 147 | 150 |
mBean.distort(dRight, pRight, rRight); |
| 148 |
|
|
| 151 |
|
|
| 152 |
mGrid = new DistortedBitmapGrid(25,25*bmpHeight/bmpWidth); |
|
| 153 |
|
|
| 149 | 154 |
try |
| 150 | 155 |
{
|
| 151 | 156 |
Distorted.onSurfaceCreated(mView.getContext()); |
| src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
import org.distorted.library.Distorted; |
| 30 |
import org.distorted.library.DistortedBitmap; |
|
| 30 |
import org.distorted.library.DistortedObject; |
|
| 31 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 31 | 32 |
import org.distorted.library.EffectTypes; |
| 32 | 33 |
import org.distorted.library.type.Dynamic1D; |
| 33 | 34 |
import org.distorted.library.type.Dynamic3D; |
| ... | ... | |
| 45 | 46 |
class CatAndDogRenderer implements GLSurfaceView.Renderer |
| 46 | 47 |
{
|
| 47 | 48 |
private GLSurfaceView mView; |
| 48 |
private DistortedBitmap catanddog; |
|
| 49 |
private DistortedObject mObject; |
|
| 50 |
private DistortedBitmapGrid mGrid; |
|
| 49 | 51 |
private Static4D chromaRegion, alphaRegion; |
| 50 | 52 |
private int bmpHeight, bmpWidth; |
| 51 | 53 |
|
| ... | ... | |
| 64 | 66 |
public void onDrawFrame(GL10 glUnused) |
| 65 | 67 |
{
|
| 66 | 68 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 67 |
catanddog.draw(System.currentTimeMillis());
|
|
| 69 |
mObject.draw(System.currentTimeMillis(), mGrid);
|
|
| 68 | 70 |
} |
| 69 | 71 |
|
| 70 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 91 | 93 |
|
| 92 | 94 |
bmpHeight = bitmap.getHeight(); |
| 93 | 95 |
bmpWidth = bitmap.getWidth(); |
| 94 |
|
|
| 95 |
catanddog = new DistortedBitmap(bitmap, 30); |
|
| 96 |
|
|
| 97 |
mGrid = new DistortedBitmapGrid(1,1); // no vertex effects, grid can be a (1x1) quad. |
|
| 98 |
|
|
| 99 |
mObject = new DistortedObject(bmpWidth,bmpHeight,1); |
|
| 100 |
mObject.setTexture(bitmap); |
|
| 96 | 101 |
|
| 97 | 102 |
Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f); |
| 98 | 103 |
chromaDyn.add(new Static1D(1)); |
| 99 | 104 |
chromaDyn.add(new Static1D(0)); |
| 100 | 105 |
|
| 101 |
catanddog.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true);
|
|
| 106 |
mObject.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true);
|
|
| 102 | 107 |
|
| 103 | 108 |
Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f); |
| 104 | 109 |
alphaDyn.add(new Static1D(1)); |
| 105 | 110 |
alphaDyn.add(new Static1D(0)); |
| 106 | 111 |
|
| 107 |
catanddog.alpha( alphaDyn, alphaRegion, false );
|
|
| 112 |
mObject.alpha( alphaDyn, alphaRegion, false );
|
|
| 108 | 113 |
|
| 109 | 114 |
try |
| 110 | 115 |
{
|
| ... | ... | |
| 134 | 139 |
diRotate.add(new Static1D( 0)); |
| 135 | 140 |
diRotate.add(new Static1D(360)); |
| 136 | 141 |
|
| 137 |
catanddog.abortEffects(EffectTypes.MATRIX);
|
|
| 142 |
mObject.abortEffects(EffectTypes.MATRIX);
|
|
| 138 | 143 |
|
| 139 |
catanddog.move(diMove);
|
|
| 140 |
catanddog.scale(diScale);
|
|
| 141 |
catanddog.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
|
|
| 144 |
mObject.move(diMove);
|
|
| 145 |
mObject.scale(diScale);
|
|
| 146 |
mObject.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
|
|
| 142 | 147 |
|
| 143 | 148 |
Distorted.onSurfaceChanged(width, height); |
| 144 | 149 |
} |
| src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
|---|---|---|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.library.Distorted; |
| 31 |
import org.distorted.library.DistortedBitmap; |
|
| 31 |
import org.distorted.library.DistortedObject; |
|
| 32 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 32 | 33 |
import org.distorted.library.EffectTypes; |
| 33 | 34 |
import org.distorted.library.type.Dynamic3D; |
| 34 | 35 |
import org.distorted.library.type.Static1D; |
| 35 |
import org.distorted.library.type.Static2D; |
|
| 36 | 36 |
import org.distorted.library.type.Static3D; |
| 37 | 37 |
import org.distorted.library.type.Static4D; |
| 38 | 38 |
import org.distorted.library.type.Dynamic1D; |
| 39 |
import org.distorted.library.type.Dynamic2D; |
|
| 40 | 39 |
|
| 41 | 40 |
import android.app.AlertDialog; |
| 42 | 41 |
import android.content.Context; |
| ... | ... | |
| 55 | 54 |
private static String compilationTitle; |
| 56 | 55 |
|
| 57 | 56 |
private GLSurfaceView mView; |
| 58 |
private DistortedBitmap mSuccess; |
|
| 57 |
private DistortedObject mSuccess; |
|
| 58 |
private DistortedBitmapGrid mGrid; |
|
| 59 | 59 |
private int bmpHeight, bmpWidth; |
| 60 | 60 |
|
| 61 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 75 | 75 |
public void onDrawFrame(GL10 glUnused) |
| 76 | 76 |
{
|
| 77 | 77 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 78 |
mSuccess.draw(System.currentTimeMillis()); |
|
| 78 |
mSuccess.draw(System.currentTimeMillis(), mGrid);
|
|
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 126 | 126 |
catch(IOException e) { }
|
| 127 | 127 |
} |
| 128 | 128 |
|
| 129 |
mSuccess = new DistortedBitmap(bitmap, 30); |
|
| 130 |
|
|
| 131 | 129 |
bmpHeight = bitmap.getHeight(); |
| 132 | 130 |
bmpWidth = bitmap.getWidth(); |
| 133 | 131 |
|
| 132 |
mSuccess = new DistortedObject(bmpWidth,bmpHeight,1); |
|
| 133 |
mSuccess.setTexture(bitmap); |
|
| 134 |
mGrid = new DistortedBitmapGrid(30,30*bmpHeight/bmpWidth); |
|
| 135 |
|
|
| 134 | 136 |
// Try adding 2 Vertex Effects to the Bitmap. |
| 135 | 137 |
// This will fail if we have set maxVertexEffects to something < 2. |
| 136 | 138 |
// |
| src/main/java/org/distorted/examples/cubes/CubesActivity.java | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
import org.distorted.library.Distorted; |
| 23 | 23 |
import org.distorted.examples.R; |
| 24 |
import org.distorted.library.DistortedCubes; |
|
| 25 | 24 |
import org.distorted.library.DistortedObject; |
| 25 |
import org.distorted.library.DistortedObjectGrid; |
|
| 26 |
import org.distorted.library.DistortedCubesGrid; |
|
| 26 | 27 |
|
| 27 | 28 |
import android.app.Activity; |
| 28 | 29 |
import android.opengl.GLSurfaceView; |
| ... | ... | |
| 48 | 49 |
private LinearLayout mLay; |
| 49 | 50 |
private boolean[] mShape; |
| 50 | 51 |
private DistortedObject mObject; |
| 52 |
private DistortedObjectGrid mGrid; |
|
| 51 | 53 |
|
| 52 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 53 | 55 |
|
| ... | ... | |
| 197 | 199 |
for(int i=0; i<mNumRows*mNumCols; i++) |
| 198 | 200 |
str += mShape[i] ? "1" : "0"; |
| 199 | 201 |
|
| 200 |
mObject = new DistortedCubes(mNumCols, str, 10); |
|
| 202 |
mGrid = new DistortedCubesGrid(mNumCols, str, false); |
|
| 203 |
mObject = new DistortedObject(mNumCols,mNumRows,1); |
|
| 201 | 204 |
|
| 202 | 205 |
setContentView(R.layout.cubeslayout); |
| 203 | 206 |
} |
| ... | ... | |
| 208 | 211 |
{
|
| 209 | 212 |
return mObject; |
| 210 | 213 |
} |
| 214 |
|
|
| 215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 216 |
|
|
| 217 |
public DistortedObjectGrid getGrid() |
|
| 218 |
{
|
|
| 219 |
return mGrid; |
|
| 220 |
} |
|
| 211 | 221 |
} |
| src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
|---|---|---|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.library.DistortedObject; |
| 31 |
import org.distorted.library.DistortedObjectGrid; |
|
| 31 | 32 |
import org.distorted.library.EffectTypes; |
| 32 | 33 |
import org.distorted.library.type.DynamicQuat; |
| 33 | 34 |
import org.distorted.library.type.Static4D; |
| ... | ... | |
| 45 | 46 |
{
|
| 46 | 47 |
private GLSurfaceView mView; |
| 47 | 48 |
private DistortedObject mObject; |
| 49 |
private DistortedObjectGrid mGrid; |
|
| 48 | 50 |
private int mObjWidth, mObjHeight; |
| 49 | 51 |
|
| 50 | 52 |
private DynamicQuat mQuatInt1, mQuatInt2; |
| ... | ... | |
| 58 | 60 |
{
|
| 59 | 61 |
mView = v; |
| 60 | 62 |
|
| 61 |
mObject = ((CubesActivity)v.getContext()).getObject(); |
|
| 63 |
CubesActivity act = (CubesActivity)v.getContext(); |
|
| 64 |
|
|
| 65 |
mObject = act.getObject(); |
|
| 66 |
mGrid = act.getGrid(); |
|
| 62 | 67 |
|
| 63 | 68 |
mObjWidth = mObject.getWidth(); |
| 64 | 69 |
mObjHeight= mObject.getHeight(); |
| ... | ... | |
| 78 | 83 |
public void onDrawFrame(GL10 glUnused) |
| 79 | 84 |
{
|
| 80 | 85 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 81 |
mObject.draw(System.currentTimeMillis()); |
|
| 86 |
mObject.draw(System.currentTimeMillis(),mGrid);
|
|
| 82 | 87 |
} |
| 83 | 88 |
|
| 84 | 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 131 | 136 |
catch(IOException e) { }
|
| 132 | 137 |
} |
| 133 | 138 |
|
| 134 |
mObject.setBitmap(bitmap);
|
|
| 139 |
mObject.setTexture(bitmap);
|
|
| 135 | 140 |
|
| 136 | 141 |
try |
| 137 | 142 |
{
|
| src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
|---|---|---|
| 23 | 23 |
import javax.microedition.khronos.opengles.GL10; |
| 24 | 24 |
|
| 25 | 25 |
import org.distorted.library.Distorted; |
| 26 |
import org.distorted.library.DistortedBitmap; |
|
| 26 |
import org.distorted.library.DistortedObject; |
|
| 27 |
import org.distorted.library.DistortedObjectGrid; |
|
| 28 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 29 |
|
|
| 27 | 30 |
import org.distorted.library.EffectNames; |
| 28 | 31 |
import org.distorted.library.EffectTypes; |
| 29 | 32 |
import org.distorted.library.type.Dynamic3D; |
| ... | ... | |
| 41 | 44 |
|
| 42 | 45 |
class DeformRenderer implements GLSurfaceView.Renderer |
| 43 | 46 |
{
|
| 44 |
private static final int NUM_VECTORS = 8; |
|
| 45 |
private static final int NUM_LINES = 10; |
|
| 46 |
private static final int NUM_FRAMES =10;
|
|
| 47 |
private static final int NUM_VECTORS = 8;
|
|
| 48 |
private static final int NUM_LINES = 10;
|
|
| 49 |
private static final int NUM_FRAMES = 10;
|
|
| 47 | 50 |
|
| 48 | 51 |
private GLSurfaceView mView; |
| 49 |
private DistortedBitmap fps;
|
|
| 50 |
private DistortedBitmap stretch;
|
|
| 52 |
private DistortedObject fps, stretch;
|
|
| 53 |
private DistortedObjectGrid fpsGrid, stretchGrid;
|
|
| 51 | 54 |
private Static3D touchPoint; |
| 52 | 55 |
|
| 53 | 56 |
private Dynamic3D mReleasedDistortDynamic; |
| ... | ... | |
| 169 | 172 |
|
| 170 | 173 |
long time = System.currentTimeMillis(); |
| 171 | 174 |
|
| 172 |
stretch.draw(time); |
|
| 175 |
stretch.draw(time,stretchGrid);
|
|
| 173 | 176 |
|
| 174 | 177 |
mPaint.setColor(0xffffffff); |
| 175 | 178 |
fpsCanvas.drawRect(0, 0, fpsW, fpsH, mPaint); |
| 176 | 179 |
mPaint.setColor(0xff000000); |
| 177 | 180 |
fpsCanvas.drawText(fpsString, fpsW/2, 5*fpsH/6, mPaint); |
| 178 | 181 |
|
| 179 |
fps.setBitmap(fpsBitmap);
|
|
| 180 |
fps.draw(time); |
|
| 182 |
fps.setTexture(fpsBitmap);
|
|
| 183 |
fps.draw(time,fpsGrid);
|
|
| 181 | 184 |
|
| 182 | 185 |
computeFPS(time); |
| 183 | 186 |
} |
| ... | ... | |
| 193 | 196 |
|
| 194 | 197 |
Distorted.onSurfaceChanged(width, height); |
| 195 | 198 |
|
| 196 |
if( bitmapCreated==false )
|
|
| 199 |
if( !bitmapCreated )
|
|
| 197 | 200 |
{
|
| 198 | 201 |
createBitmap(scrWidth/2,scrHeight/2); |
| 199 | 202 |
stretch.move( new Static3D(scrWidth/4,scrHeight/4,0) ); |
| ... | ... | |
| 231 | 234 |
Canvas stretchCanvas; |
| 232 | 235 |
|
| 233 | 236 |
mPaint = new Paint(); |
| 234 |
stretch = new DistortedBitmap(w,h, 50); |
|
| 237 |
stretch = new DistortedObject(w,h,1); |
|
| 238 |
stretchGrid = new DistortedBitmapGrid(50,50*h/w); |
|
| 235 | 239 |
Bitmap stretchBitmap = Bitmap.createBitmap(w,h, Bitmap.Config.ARGB_8888); |
| 236 | 240 |
stretchCanvas = new Canvas(stretchBitmap); |
| 237 | 241 |
|
| ... | ... | |
| 254 | 258 |
|
| 255 | 259 |
touchPoint= new Static3D(0,0,0); |
| 256 | 260 |
|
| 257 |
fps = new DistortedBitmap( fpsW, fpsH, 2); |
|
| 261 |
fps = new DistortedObject( fpsW, fpsH, 1); |
|
| 262 |
fpsGrid = new DistortedBitmapGrid(1,1); |
|
| 263 |
|
|
| 258 | 264 |
fpsBitmap = Bitmap.createBitmap(fpsW,fpsH, Bitmap.Config.ARGB_8888); |
| 259 | 265 |
fpsCanvas = new Canvas(fpsBitmap); |
| 260 | 266 |
|
| 261 |
stretch.setBitmap(stretchBitmap);
|
|
| 262 |
fps.setBitmap(fpsBitmap);
|
|
| 267 |
stretch.setTexture(stretchBitmap);
|
|
| 268 |
fps.setTexture(fpsBitmap);
|
|
| 263 | 269 |
} |
| 264 | 270 |
|
| 265 | 271 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
|---|---|---|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.library.Distorted; |
| 31 |
import org.distorted.library.DistortedBitmap; |
|
| 31 |
import org.distorted.library.DistortedObject; |
|
| 32 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 32 | 33 |
import org.distorted.library.EffectTypes; |
| 33 | 34 |
import org.distorted.library.type.Dynamic3D; |
| 34 | 35 |
import org.distorted.library.type.Static1D; |
| 35 |
import org.distorted.library.type.Static2D; |
|
| 36 | 36 |
import org.distorted.library.type.Static3D; |
| 37 | 37 |
import org.distorted.library.type.Static4D; |
| 38 | 38 |
|
| ... | ... | |
| 48 | 48 |
private static final int NUM = 3; |
| 49 | 49 |
|
| 50 | 50 |
private GLSurfaceView mView; |
| 51 |
private DistortedBitmap[] bmp; |
|
| 51 |
private DistortedObject[] mObj; |
|
| 52 |
private DistortedBitmapGrid mGrid; |
|
| 52 | 53 |
private Static3D mPoint; |
| 53 | 54 |
private Dynamic3D dDistort; |
| 54 | 55 |
private int bmpHeight, bmpWidth; |
| ... | ... | |
| 97 | 98 |
|
| 98 | 99 |
long time = System.currentTimeMillis(); |
| 99 | 100 |
|
| 100 |
for(int i=NUM-1; i>=0; i--) bmp[i].draw(time);
|
|
| 101 |
for(int i=NUM-1; i>=0; i--) mObj[i].draw(time, mGrid);
|
|
| 101 | 102 |
} |
| 102 | 103 |
|
| 103 | 104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 106 | 107 |
{
|
| 107 | 108 |
for(int i=NUM-1; i>=0; i--) |
| 108 | 109 |
{
|
| 109 |
bmp[i].abortEffects(EffectTypes.MATRIX);
|
|
| 110 |
mObj[i].abortEffects(EffectTypes.MATRIX);
|
|
| 110 | 111 |
} |
| 111 | 112 |
|
| 112 | 113 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
| ... | ... | |
| 116 | 117 |
|
| 117 | 118 |
for(int i=NUM-1; i>=0; i--) |
| 118 | 119 |
{
|
| 119 |
bmp[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
| 120 |
bmp[i].scale(factor);
|
|
| 120 |
mObj[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
| 121 |
mObj[i].scale(factor);
|
|
| 121 | 122 |
} |
| 122 | 123 |
} |
| 123 | 124 |
else |
| ... | ... | |
| 128 | 129 |
|
| 129 | 130 |
for(int i=NUM-1; i>=0; i--) |
| 130 | 131 |
{
|
| 131 |
bmp[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
| 132 |
bmp[i].scale(factor);
|
|
| 132 |
mObj[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
| 133 |
mObj[i].scale(factor);
|
|
| 133 | 134 |
} |
| 134 | 135 |
} |
| 135 | 136 |
|
| ... | ... | |
| 150 | 151 |
bmpWidth = bitmap0.getWidth(); |
| 151 | 152 |
|
| 152 | 153 |
// create NUM DistortedBitmaps with shared effects |
| 153 |
bmp = new DistortedBitmap[NUM];
|
|
| 154 |
bmp[0] = new DistortedBitmap(bmpWidth, bmpHeight, 30);
|
|
| 154 |
mObj = new DistortedObject[NUM];
|
|
| 155 |
mObj[0] = new DistortedObject(bmpWidth, bmpHeight, 1);
|
|
| 155 | 156 |
for(int i=1; i<NUM; i++) |
| 156 |
bmp[i] = new DistortedBitmap(bmp[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
|
|
| 157 |
mObj[i] = new DistortedObject(mObj[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
|
|
| 157 | 158 |
|
| 158 |
bmp[0].setBitmap(bitmap0);
|
|
| 159 |
bmp[1].setBitmap(bitmap1);
|
|
| 160 |
bmp[2].setBitmap(bitmap2);
|
|
| 159 |
mObj[0].setTexture(bitmap0);
|
|
| 160 |
mObj[1].setTexture(bitmap1);
|
|
| 161 |
mObj[2].setTexture(bitmap2);
|
|
| 161 | 162 |
|
| 162 |
bmp[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); |
|
| 163 |
bmp[0].distort(dDistort,mPoint); |
|
| 164 |
|
|
| 163 |
mObj[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); |
|
| 164 |
mObj[0].distort(dDistort,mPoint); |
|
| 165 |
|
|
| 166 |
mGrid = new DistortedBitmapGrid(30,30*bmpHeight/bmpWidth); |
|
| 167 |
|
|
| 165 | 168 |
try |
| 166 | 169 |
{
|
| 167 | 170 |
Distorted.onSurfaceCreated(mView.getContext()); |
| src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
|---|---|---|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.library.Distorted; |
| 31 |
import org.distorted.library.DistortedBitmap; |
|
| 31 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 32 |
import org.distorted.library.DistortedObject; |
|
| 32 | 33 |
import org.distorted.library.EffectTypes; |
| 33 | 34 |
import org.distorted.library.type.Dynamic1D; |
| 34 | 35 |
import org.distorted.library.type.Dynamic3D; |
| 35 | 36 |
import org.distorted.library.type.Static1D; |
| 36 |
import org.distorted.library.type.Static2D; |
|
| 37 | 37 |
import org.distorted.library.type.Static3D; |
| 38 | 38 |
import org.distorted.library.type.Static4D; |
| 39 | 39 |
|
| ... | ... | |
| 49 | 49 |
private static final int NUM = 3; |
| 50 | 50 |
|
| 51 | 51 |
private GLSurfaceView mView; |
| 52 |
private DistortedBitmap[] bmp; |
|
| 52 |
private DistortedObject[] mObj; |
|
| 53 |
private DistortedBitmapGrid mGrid; |
|
| 53 | 54 |
private Static3D pLeft, pRight, pNose1; |
| 54 | 55 |
private Static4D RegionEye; |
| 55 | 56 |
private Dynamic3D mDI; |
| ... | ... | |
| 61 | 62 |
{
|
| 62 | 63 |
mView = v; |
| 63 | 64 |
|
| 64 |
// bmp[0] effects
|
|
| 65 |
// mObj[0] effects
|
|
| 65 | 66 |
pLeft = new Static3D(214, 206, 0); |
| 66 | 67 |
pRight= new Static3D(390, 212, 0); |
| 67 | 68 |
RegionEye = new Static4D(0,0,60,60); |
| 68 | 69 |
|
| 69 |
// bmp[1] effects
|
|
| 70 |
// mObj[1] effects
|
|
| 70 | 71 |
mDI = new Dynamic3D(1000,0.0f); |
| 71 | 72 |
mDI.add(new Static3D( 50,0,0)); |
| 72 | 73 |
mDI.add(new Static3D(-50,0,0)); |
| ... | ... | |
| 83 | 84 |
|
| 84 | 85 |
long time = System.currentTimeMillis(); |
| 85 | 86 |
|
| 86 |
for(int i=NUM-1; i>=0; i--) bmp[i].draw(time);
|
|
| 87 |
for(int i=NUM-1; i>=0; i--) mObj[i].draw(time, mGrid);
|
|
| 87 | 88 |
} |
| 88 | 89 |
|
| 89 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 92 | 93 |
{
|
| 93 | 94 |
for(int i=NUM-1; i>=0; i--) |
| 94 | 95 |
{
|
| 95 |
bmp[i].abortEffects(EffectTypes.MATRIX);
|
|
| 96 |
mObj[i].abortEffects(EffectTypes.MATRIX);
|
|
| 96 | 97 |
} |
| 97 | 98 |
|
| 98 | 99 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
| ... | ... | |
| 102 | 103 |
|
| 103 | 104 |
for(int i=NUM-1; i>=0; i--) |
| 104 | 105 |
{
|
| 105 |
bmp[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
|
|
| 106 |
bmp[i].scale(factor);
|
|
| 106 |
mObj[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
|
|
| 107 |
mObj[i].scale(factor);
|
|
| 107 | 108 |
} |
| 108 | 109 |
} |
| 109 | 110 |
else |
| ... | ... | |
| 114 | 115 |
|
| 115 | 116 |
for(int i=NUM-1; i>=0; i--) |
| 116 | 117 |
{
|
| 117 |
bmp[i].move( new Static3D(i*w, (height-h)/2, 0) );
|
|
| 118 |
bmp[i].scale(factor);
|
|
| 118 |
mObj[i].move( new Static3D(i*w, (height-h)/2, 0) );
|
|
| 119 |
mObj[i].scale(factor);
|
|
| 119 | 120 |
} |
| 120 | 121 |
} |
| 121 | 122 |
|
| ... | ... | |
| 146 | 147 |
|
| 147 | 148 |
bmpHeight = bitmap.getHeight(); |
| 148 | 149 |
bmpWidth = bitmap.getWidth(); |
| 150 |
|
|
| 151 |
mGrid = new DistortedBitmapGrid(30,30*bmpHeight/bmpWidth); |
|
| 152 |
|
|
| 153 |
mObj = new DistortedObject[NUM]; |
|
| 154 |
mObj[0] = new DistortedObject(bmpWidth, bmpHeight, 1); |
|
| 149 | 155 |
|
| 150 |
bmp = new DistortedBitmap[NUM]; |
|
| 151 |
bmp[0] = new DistortedBitmap(bmpWidth, bmpHeight, 30); |
|
| 152 |
|
|
| 153 |
for(int i=1; i<NUM; i++) bmp[i] = new DistortedBitmap(bmp[0], Distorted.CLONE_BITMAP); |
|
| 156 |
for(int i=1; i<NUM; i++) mObj[i] = new DistortedObject(mObj[0], Distorted.CLONE_BITMAP); |
|
| 154 | 157 |
|
| 155 | 158 |
// setting the bitmap once is enough; others are cloned! |
| 156 |
bmp[0].setBitmap(bitmap);
|
|
| 159 |
mObj[0].setTexture(bitmap);
|
|
| 157 | 160 |
|
| 158 | 161 |
Dynamic1D sink = new Dynamic1D(2000,0.0f); |
| 159 | 162 |
sink.add(new Static1D( 1)); |
| 160 | 163 |
sink.add(new Static1D(10)); |
| 161 | 164 |
|
| 162 |
bmp[0].sink(sink, pLeft, RegionEye);
|
|
| 163 |
bmp[0].sink(sink, pRight,RegionEye);
|
|
| 164 |
bmp[1].distort(mDI, pNose1);
|
|
| 165 |
mObj[0].sink(sink, pLeft, RegionEye);
|
|
| 166 |
mObj[0].sink(sink, pRight,RegionEye);
|
|
| 167 |
mObj[1].distort(mDI, pNose1);
|
|
| 165 | 168 |
|
| 166 | 169 |
Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f); |
| 167 | 170 |
chromaDyn.add(new Static1D(0)); |
| 168 | 171 |
chromaDyn.add(new Static1D(1)); |
| 169 | 172 |
|
| 170 |
bmp[2].chroma(chromaDyn, new Static3D(0,1,0) );
|
|
| 173 |
mObj[2].chroma(chromaDyn, new Static3D(0,1,0) );
|
|
| 171 | 174 |
|
| 172 | 175 |
try |
| 173 | 176 |
{
|
| src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
|---|---|---|
| 29 | 29 |
import android.opengl.GLES20; |
| 30 | 30 |
import android.opengl.GLSurfaceView; |
| 31 | 31 |
|
| 32 |
import org.distorted.library.DistortedBitmap; |
|
| 32 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 33 |
import org.distorted.library.DistortedObject; |
|
| 33 | 34 |
import org.distorted.library.Distorted; |
| 34 | 35 |
|
| 35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 37 | 38 |
class DynamicRenderer implements GLSurfaceView.Renderer |
| 38 | 39 |
{
|
| 39 | 40 |
private DynamicSurfaceView mView; |
| 40 |
private DistortedBitmap mBackground; |
|
| 41 |
private DistortedObject mBackground; |
|
| 42 |
private DistortedBitmapGrid mGrid; |
|
| 41 | 43 |
private Canvas mCanvas; |
| 42 | 44 |
private Bitmap mBitmap; |
| 43 | 45 |
private Paint mPaint; |
| ... | ... | |
| 78 | 80 |
texW = width; |
| 79 | 81 |
texH = height; |
| 80 | 82 |
|
| 81 |
mBackground = new DistortedBitmap(texW,texH, 2); |
|
| 82 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
|
| 83 |
mCanvas = new Canvas(mBitmap); |
|
| 83 |
mGrid = new DistortedBitmapGrid(1,1); |
|
| 84 |
mBackground = new DistortedObject(texW,texH,1); |
|
| 85 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
|
| 86 |
mCanvas = new Canvas(mBitmap); |
|
| 84 | 87 |
|
| 85 | 88 |
Distorted.onSurfaceChanged(texW,texH); |
| 86 | 89 |
mView.onSurfaceChanged(texW,texH); |
| ... | ... | |
| 96 | 99 |
|
| 97 | 100 |
mCanvas.drawRect(0, 0, texW, texH, mPaint); |
| 98 | 101 |
mView.drawCurve(mCanvas,time); |
| 99 |
mBackground.setBitmap(mBitmap);
|
|
| 100 |
mBackground.draw(time); |
|
| 102 |
mBackground.setTexture(mBitmap);
|
|
| 103 |
mBackground.draw(time,mGrid);
|
|
| 101 | 104 |
} |
| 102 | 105 |
|
| 103 | 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
|---|---|---|
| 29 | 29 |
import android.opengl.GLES20; |
| 30 | 30 |
import android.opengl.GLSurfaceView; |
| 31 | 31 |
|
| 32 |
import org.distorted.library.DistortedBitmap; |
|
| 32 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 33 |
import org.distorted.library.DistortedObject; |
|
| 33 | 34 |
import org.distorted.library.Distorted; |
| 34 | 35 |
import org.distorted.library.EffectNames; |
| 35 | 36 |
import org.distorted.library.EffectTypes; |
| ... | ... | |
| 49 | 50 |
private Paint mPaint; |
| 50 | 51 |
private int texWidth, texHeight; |
| 51 | 52 |
|
| 52 |
DistortedBitmap mBackground; |
|
| 53 |
DistortedObject mBackground; |
|
| 54 |
DistortedBitmapGrid mGrid; |
|
| 53 | 55 |
|
| 54 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 | 57 |
|
| ... | ... | |
| 64 | 66 |
|
| 65 | 67 |
texWidth = BWID; |
| 66 | 68 |
texHeight= BHEI; |
| 69 |
|
|
| 70 |
mGrid = new DistortedBitmapGrid(80,80*texHeight/texWidth); |
|
| 71 |
mBackground= new DistortedObject(texWidth,texHeight,1); |
|
| 72 |
|
|
| 73 |
mBackground.addEventListener(this); |
|
| 67 | 74 |
} |
| 68 | 75 |
|
| 69 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 70 | 77 |
|
| 71 | 78 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
| 72 |
{
|
|
| 73 |
mBackground = new DistortedBitmap(texWidth,texHeight, 80); |
|
| 79 |
{
|
|
| 74 | 80 |
Bitmap bitmap = Bitmap.createBitmap(texWidth,texHeight, Bitmap.Config.ARGB_8888); |
| 75 |
Canvas canvas = new Canvas(bitmap);
|
|
| 76 |
|
|
| 81 |
Canvas canvas = new Canvas(bitmap); |
|
| 82 |
|
|
| 77 | 83 |
mPaint.setColor(0xff008800); |
| 78 | 84 |
canvas.drawRect(0, 0, texWidth, texHeight, mPaint); |
| 79 | 85 |
mPaint.setColor(0xffffffff); |
| 80 |
|
|
| 86 |
|
|
| 81 | 87 |
for(int i=0; i<=NUMLINES ; i++ ) |
| 82 | 88 |
{
|
| 83 | 89 |
canvas.drawRect(texWidth*i/NUMLINES - 1, 0, texWidth*i/NUMLINES + 1, texHeight , mPaint); |
| 84 |
canvas.drawRect( 0, texHeight*i/NUMLINES -1, texWidth , texHeight*i/NUMLINES + 1, mPaint);
|
|
| 90 |
canvas.drawRect( 0, texHeight*i/NUMLINES -1, texWidth , texHeight*i/NUMLINES + 1, mPaint); |
|
| 85 | 91 |
} |
| 86 |
|
|
| 87 |
mBackground.setBitmap(bitmap); |
|
| 88 |
mBackground.addEventListener(this); |
|
| 92 |
mBackground.setTexture(bitmap); |
|
| 89 | 93 |
|
| 90 | 94 |
try |
| 91 | 95 |
{
|
| ... | ... | |
| 93 | 97 |
} |
| 94 | 98 |
catch(Exception ex) |
| 95 | 99 |
{
|
| 96 |
android.util.Log.e("Effects2D", ex.getMessage() );
|
|
| 100 |
android.util.Log.e("EffectQueue", ex.getMessage() );
|
|
| 97 | 101 |
} |
| 98 | 102 |
} |
| 99 | 103 |
|
| ... | ... | |
| 112 | 116 |
public void onDrawFrame(GL10 glUnused) |
| 113 | 117 |
{
|
| 114 | 118 |
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); |
| 115 |
mBackground.draw(System.currentTimeMillis()); |
|
| 119 |
mBackground.draw(System.currentTimeMillis(), mGrid);
|
|
| 116 | 120 |
} |
| 117 | 121 |
|
| 118 | 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java | ||
|---|---|---|
| 38 | 38 |
|
| 39 | 39 |
import org.distorted.examples.R; |
| 40 | 40 |
import org.distorted.library.Distorted; |
| 41 |
import org.distorted.library.DistortedBitmap; |
|
| 42 |
import org.distorted.library.DistortedCubes; |
|
| 41 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 42 |
import org.distorted.library.DistortedCubesGrid; |
|
| 43 |
import org.distorted.library.DistortedObjectGrid; |
|
| 43 | 44 |
import org.distorted.library.DistortedObject; |
| 44 | 45 |
import org.distorted.library.EffectNames; |
| 45 | 46 |
import org.distorted.library.EffectTypes; |
| ... | ... | |
| 66 | 67 |
private NumberPicker mColsPicker, mRowsPicker; |
| 67 | 68 |
private boolean[] mShape; |
| 68 | 69 |
private DistortedObject mObject; |
| 70 |
private DistortedObjectGrid mGrid; |
|
| 69 | 71 |
private int mObjectType; |
| 70 | 72 |
private int mBitmapID; |
| 71 | 73 |
private Bitmap mBitmap; |
| ... | ... | |
| 220 | 222 |
return mObject; |
| 221 | 223 |
} |
| 222 | 224 |
|
| 225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 226 |
|
|
| 227 |
public DistortedObjectGrid getGrid() |
|
| 228 |
{
|
|
| 229 |
return mGrid; |
|
| 230 |
} |
|
| 231 |
|
|
| 223 | 232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 224 | 233 |
|
| 225 | 234 |
public static void setSupportsRegion(boolean supports) |
| ... | ... | |
| 388 | 397 |
if( mObjectType==1 ) |
| 389 | 398 |
{
|
| 390 | 399 |
getBitmap(); |
| 391 |
mObject = new DistortedBitmap(mBitmap.getWidth(),mBitmap.getHeight(),mNumCols); |
|
| 400 |
|
|
| 401 |
int w = mBitmap.getWidth(); |
|
| 402 |
int h = mBitmap.getHeight(); |
|
| 403 |
|
|
| 404 |
mObject = new DistortedObject(w,h,1); |
|
| 405 |
mGrid = new DistortedBitmapGrid(mNumCols,mNumCols*h/w); |
|
| 392 | 406 |
setEffectView(); |
| 393 | 407 |
} |
| 394 | 408 |
else |
| ... | ... | |
| 417 | 431 |
for(int i=0; i<mNumRows*mNumCols; i++) |
| 418 | 432 |
str += mShape[i] ? "1" : "0"; |
| 419 | 433 |
|
| 420 |
mObject = new DistortedCubes(mNumCols, str, 10); |
|
| 434 |
mObject = new DistortedObject(mNumCols,mNumRows,1); |
|
| 435 |
mGrid = new DistortedCubesGrid(mNumCols, str, false); |
|
| 421 | 436 |
|
| 422 | 437 |
setEffectView(); |
| 423 | 438 |
} |
| src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
|---|---|---|
| 26 | 26 |
|
| 27 | 27 |
import org.distorted.examples.R; |
| 28 | 28 |
import org.distorted.library.Distorted; |
| 29 |
import org.distorted.library.DistortedBitmap; |
|
| 29 |
import org.distorted.library.DistortedBitmapGrid;
|
|
| 30 | 30 |
import org.distorted.library.DistortedObject; |
| 31 |
import org.distorted.library.DistortedObjectGrid; |
|
| 31 | 32 |
import org.distorted.library.EffectTypes; |
| 32 | 33 |
import org.distorted.library.type.Dynamic3D; |
| 33 | 34 |
import org.distorted.library.type.DynamicQuat; |
| ... | ... | |
| 46 | 47 |
{
|
| 47 | 48 |
private GLSurfaceView mView; |
| 48 | 49 |
private DistortedObject mObject; |
| 49 |
private DistortedBitmap mBackground; |
|
| 50 |
private DistortedBitmap mCenter; |
|
| 51 |
private DistortedBitmap mRegion; |
|
| 50 |
private DistortedObject mBackground; |
|
| 51 |
private DistortedObject mCenter; |
|
| 52 |
private DistortedObject mRegion; |
|
| 53 |
private DistortedBitmapGrid mQuad; |
|
| 54 |
private DistortedObjectGrid mGrid; |
|
| 52 | 55 |
private int mObjWidth, mObjHeight, mObjDepth; |
| 53 | 56 |
private DynamicQuat mQuatInt1, mQuatInt2; |
| 54 | 57 |
|
| ... | ... | |
| 68 | 71 |
{
|
| 69 | 72 |
mView = v; |
| 70 | 73 |
|
| 71 |
mObject = ((Effects3DActivity)v.getContext()).getObject(); |
|
| 72 |
mBackground = new DistortedBitmap(100, 100, 1); |
|
| 73 |
mCenter = new DistortedBitmap(100, 100, 1); |
|
| 74 |
mRegion = new DistortedBitmap(100, 100, 1); |
|
| 74 |
Effects3DActivity act = (Effects3DActivity)v.getContext(); |
|
| 75 |
|
|
| 76 |
mObject = act.getObject(); |
|
| 77 |
mGrid = act.getGrid(); |
|
| 78 |
mBackground = new DistortedObject(100, 100, 1); |
|
| 79 |
mCenter = new DistortedObject(100, 100, 1); |
|
| 80 |
mRegion = new DistortedObject(100, 100, 1); |
|
| 81 |
mQuad = new DistortedBitmapGrid(1,1); |
|
| 75 | 82 |
|
| 76 | 83 |
mObjWidth = mObject.getWidth(); |
| 77 | 84 |
mObjHeight= mObject.getHeight(); |
| ... | ... | |
| 123 | 130 |
|
| 124 | 131 |
long time = System.currentTimeMillis(); |
| 125 | 132 |
|
| 126 |
mBackground.draw(time); |
|
| 127 |
mObject.draw(time); |
|
| 133 |
mBackground.draw(time,mQuad);
|
|
| 134 |
mObject.draw(time,mGrid);
|
|
| 128 | 135 |
|
| 129 | 136 |
if( Effects3DActivity.supportsCenter() ) |
| 130 | 137 |
{
|
| 131 |
mCenter.draw(time); |
|
| 132 |
if( Effects3DActivity.supportsRegion() ) mRegion.draw(time); |
|
| 138 |
mCenter.draw(time, mQuad);
|
|
| 139 |
if( Effects3DActivity.supportsRegion() ) mRegion.draw(time, mQuad);
|
|
| 133 | 140 |
} |
| 134 | 141 |
} |
| 135 | 142 |
|
| ... | ... | |
| 234 | 241 |
catch(IOException e) { }
|
| 235 | 242 |
} |
| 236 | 243 |
|
| 237 |
mObject.setBitmap( act.getBitmap() );
|
|
| 238 |
mBackground.setBitmap(bitmap1);
|
|
| 239 |
mCenter.setBitmap(bitmap2);
|
|
| 240 |
mRegion.setBitmap(bitmap3);
|
|
| 244 |
mObject.setTexture( act.getBitmap() );
|
|
| 245 |
mBackground.setTexture(bitmap1);
|
|
| 246 |
mCenter.setTexture(bitmap2);
|
|
| 247 |
mRegion.setTexture(bitmap3);
|
|
| 241 | 248 |
|
| 242 | 249 |
try |
| 243 | 250 |
{
|
| src/main/java/org/distorted/examples/fbo/FBORenderer.java | ||
|---|---|---|
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.library.DistortedNode; |
| 31 | 31 |
import org.distorted.library.Distorted; |
| 32 |
import org.distorted.library.DistortedBitmap; |
|
| 32 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 33 |
import org.distorted.library.DistortedObject; |
|
| 33 | 34 |
import org.distorted.library.EffectTypes; |
| 34 | 35 |
import org.distorted.library.type.Dynamic1D; |
| 35 | 36 |
import org.distorted.library.type.Static1D; |
| 36 |
import org.distorted.library.type.Static2D; |
|
| 37 | 37 |
import org.distorted.library.type.Static3D; |
| 38 | 38 |
|
| 39 | 39 |
import android.graphics.Bitmap; |
| ... | ... | |
| 46 | 46 |
class FBORenderer implements GLSurfaceView.Renderer |
| 47 | 47 |
{
|
| 48 | 48 |
private GLSurfaceView mView; |
| 49 |
private DistortedBitmap mLisa;
|
|
| 49 |
private DistortedObject mLisa;
|
|
| 50 | 50 |
private int lisaHeight, lisaWidth; |
| 51 | 51 |
|
| 52 | 52 |
private DistortedNode mRoot; |
| ... | ... | |
| 121 | 121 |
lisaHeight = bitmap1.getHeight(); |
| 122 | 122 |
lisaWidth = bitmap1.getWidth(); |
| 123 | 123 |
|
| 124 |
mLisa = new DistortedBitmap(bitmap1, 20); |
|
| 125 |
DistortedBitmap text = new DistortedBitmap(bitmap2, 20); |
|
| 126 |
|
|
| 127 |
mRoot = new DistortedNode(mLisa); |
|
| 128 |
mRoot.attach(text); |
|
| 124 |
mLisa = new DistortedObject(lisaWidth, lisaHeight, 1); |
|
| 125 |
mLisa.setTexture(bitmap1); |
|
| 126 |
DistortedObject text = new DistortedObject(bitmap2.getWidth(),bitmap2.getHeight(),1); |
|
| 127 |
text.setTexture(bitmap2); |
|
| 128 |
|
|
| 129 |
mRoot = new DistortedNode(mLisa,new DistortedBitmapGrid(1,1)); |
|
| 130 |
mRoot.attach(text,new DistortedBitmapGrid(20,5)); |
|
| 129 | 131 |
|
| 130 | 132 |
int textWidth = text.getWidth(); |
| 131 | 133 |
int textHeight = text.getHeight(); |
| ... | ... | |
| 153 | 155 |
} |
| 154 | 156 |
catch(Exception ex) |
| 155 | 157 |
{
|
| 156 |
android.util.Log.e("MonaLisa", ex.getMessage() );
|
|
| 158 |
android.util.Log.e("FBO", ex.getMessage() );
|
|
| 157 | 159 |
} |
| 158 | 160 |
} |
| 159 | 161 |
} |
| src/main/java/org/distorted/examples/flag/FlagRenderer.java | ||
|---|---|---|
| 26 | 26 |
|
| 27 | 27 |
import org.distorted.examples.R; |
| 28 | 28 |
import org.distorted.library.Distorted; |
| 29 |
import org.distorted.library.DistortedCubes; |
|
| 29 |
import org.distorted.library.DistortedCubesGrid;
|
|
| 30 | 30 |
import org.distorted.library.DistortedObject; |
| 31 | 31 |
import org.distorted.library.EffectTypes; |
| 32 | 32 |
import org.distorted.library.type.Dynamic; |
| 33 | 33 |
import org.distorted.library.type.Dynamic5D; |
| 34 | 34 |
import org.distorted.library.type.DynamicQuat; |
| 35 |
import org.distorted.library.type.Static2D; |
|
| 36 | 35 |
import org.distorted.library.type.Static3D; |
| 37 | 36 |
import org.distorted.library.type.Static4D; |
| 38 | 37 |
import org.distorted.library.type.Static5D; |
| ... | ... | |
| 49 | 48 |
{
|
| 50 | 49 |
private GLSurfaceView mView; |
| 51 | 50 |
private DistortedObject mObject; |
| 51 |
private DistortedCubesGrid mGrid; |
|
| 52 | 52 |
private int mObjWidth, mObjHeight; |
| 53 | 53 |
private DynamicQuat mQuatInt1, mQuatInt2; |
| 54 | 54 |
private Dynamic5D mWaveDyn; |
| ... | ... | |
| 63 | 63 |
{
|
| 64 | 64 |
mView = v; |
| 65 | 65 |
|
| 66 |
mObject = new DistortedCubes(50,30,10,false); |
|
| 66 |
mGrid = new DistortedCubesGrid(50,30,false); |
|
| 67 |
mObject = new DistortedObject(50,30,1); |
|
| 67 | 68 |
|
| 68 | 69 |
mObjWidth = mObject.getWidth(); |
| 69 | 70 |
mObjHeight= mObject.getHeight(); |
| ... | ... | |
| 135 | 136 |
public void onDrawFrame(GL10 glUnused) |
| 136 | 137 |
{
|
| 137 | 138 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 138 |
mObject.draw(System.currentTimeMillis()); |
|
| 139 |
mObject.draw(System.currentTimeMillis(), mGrid);
|
|
| 139 | 140 |
} |
| 140 | 141 |
|
| 141 | 142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 188 | 189 |
catch(IOException e) { }
|
| 189 | 190 |
} |
| 190 | 191 |
|
| 191 |
mObject.setBitmap(bitmap);
|
|
| 192 |
mObject.setTexture(bitmap);
|
|
| 192 | 193 |
|
| 193 | 194 |
try |
| 194 | 195 |
{
|
| src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
|---|---|---|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.library.Distorted; |
| 31 |
import org.distorted.library.DistortedBitmap; |
|
| 31 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 32 |
import org.distorted.library.DistortedObject; |
|
| 32 | 33 |
import org.distorted.library.EffectTypes; |
| 33 | 34 |
import org.distorted.library.type.Dynamic1D; |
| 34 | 35 |
import org.distorted.library.type.Dynamic3D; |
| 35 | 36 |
import org.distorted.library.type.Static1D; |
| 36 |
import org.distorted.library.type.Static2D; |
|
| 37 | 37 |
import org.distorted.library.type.Static3D; |
| 38 | 38 |
import org.distorted.library.type.Static4D; |
| 39 | 39 |
|
| ... | ... | |
| 47 | 47 |
class GirlRenderer implements GLSurfaceView.Renderer |
| 48 | 48 |
{
|
| 49 | 49 |
private GLSurfaceView mView; |
| 50 |
private DistortedBitmap mGirl; |
|
| 50 |
private DistortedObject mGirl; |
|
| 51 |
private DistortedBitmapGrid mGrid; |
|
| 51 | 52 |
private Static3D pLeft, pRight, pHips; |
| 52 | 53 |
private Static4D Region, sinkRegion, HipsRegion; |
| 53 | 54 |
private Dynamic3D diL, diR; |
| ... | ... | |
| 152 | 153 |
public void onDrawFrame(GL10 glUnused) |
| 153 | 154 |
{
|
| 154 | 155 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 155 |
mGirl.draw(System.currentTimeMillis()); |
|
| 156 |
mGirl.draw(System.currentTimeMillis(),mGrid);
|
|
| 156 | 157 |
} |
| 157 | 158 |
|
| 158 | 159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 205 | 206 |
|
| 206 | 207 |
bmpHeight = bitmap.getHeight(); |
| 207 | 208 |
bmpWidth = bitmap.getWidth(); |
| 208 |
|
|
| 209 |
mGirl = new DistortedBitmap(bitmap, 30); |
|
| 209 |
|
|
| 210 |
mGrid = new DistortedBitmapGrid(30,30*bmpHeight/bmpWidth); |
|
| 211 |
mGirl = new DistortedObject(bmpWidth,bmpHeight,1); |
|
| 212 |
mGirl.setTexture(bitmap); |
|
| 210 | 213 |
|
| 211 | 214 |
mGirl.sink( diSink, pLeft, sinkRegion ); |
| 212 | 215 |
mGirl.sink( diSink, pRight,sinkRegion ); |
| src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
|---|---|---|
| 29 | 29 |
import org.distorted.examples.R; |
| 30 | 30 |
|
| 31 | 31 |
import org.distorted.library.Distorted; |
| 32 |
import org.distorted.library.DistortedBitmap; |
|
| 32 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 33 |
import org.distorted.library.DistortedObject; |
|
| 33 | 34 |
import org.distorted.library.EffectNames; |
| 34 | 35 |
import org.distorted.library.EffectTypes; |
| 35 | 36 |
import org.distorted.library.type.Dynamic3D; |
| 36 |
import org.distorted.library.type.Static2D; |
|
| 37 | 37 |
import org.distorted.library.type.Static3D; |
| 38 | 38 |
import org.distorted.library.type.Static4D; |
| 39 | 39 |
import org.distorted.library.message.EffectListener; |
| ... | ... | |
| 51 | 51 |
private final int NUM_BUBBLES = 12; |
| 52 | 52 |
|
| 53 | 53 |
private GLSurfaceView mView; |
| 54 |
private DistortedBitmap water; |
|
| 54 |
private DistortedObject mWater; |
|
| 55 |
private DistortedBitmapGrid mGrid; |
|
| 55 | 56 |
private int bmpHeight, bmpWidth; |
| 56 | 57 |
private Random mRnd; |
| 57 | 58 |
|
| ... | ... | |
| 77 | 78 |
dDistort.add(new Static3D(0,0, 0)); |
| 78 | 79 |
dDistort.add(new Static3D(0,0,height)); |
| 79 | 80 |
|
| 80 |
return water.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
|
|
| 81 |
return mWater.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
|
|
| 81 | 82 |
} |
| 82 | 83 |
|
| 83 | 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 97 | 98 |
public void onDrawFrame(GL10 glUnused) |
| 98 | 99 |
{
|
| 99 | 100 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 100 |
water.draw(System.currentTimeMillis());
|
|
| 101 |
mWater.draw(System.currentTimeMillis(), mGrid);
|
|
| 101 | 102 |
} |
| 102 | 103 |
|
| 103 | 104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 104 | 105 |
|
| 105 | 106 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 106 | 107 |
{
|
| 107 |
water.abortEffects(EffectTypes.MATRIX);
|
|
| 108 |
mWater.abortEffects(EffectTypes.MATRIX);
|
|
| 108 | 109 |
|
| 109 | 110 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
| 110 | 111 |
{
|
| 111 | 112 |
int w = (height*bmpWidth)/bmpHeight; |
| 112 | 113 |
float factor = (float)height/bmpHeight; |
| 113 | 114 |
|
| 114 |
water.move( new Static3D((width-w)/2,0,0) );
|
|
| 115 |
water.scale(factor);
|
|
| 115 |
mWater.move( new Static3D((width-w)/2,0,0) );
|
|
| 116 |
mWater.scale(factor);
|
|
| 116 | 117 |
} |
| 117 | 118 |
else |
| 118 | 119 |
{
|
| 119 | 120 |
int h = (width*bmpHeight)/bmpWidth; |
| 120 | 121 |
float factor = (float)width/bmpWidth; |
| 121 | 122 |
|
| 122 |
water.move( new Static3D(0,(height-h)/2,0) );
|
|
| 123 |
water.scale(factor);
|
|
| 123 |
mWater.move( new Static3D(0,(height-h)/2,0) );
|
|
| 124 |
mWater.scale(factor);
|
|
| 124 | 125 |
} |
| 125 | 126 |
|
| 126 | 127 |
Distorted.onSurfaceChanged(width, height); |
| ... | ... | |
| 152 | 153 |
|
| 153 | 154 |
bmpHeight = bitmap.getHeight(); |
| 154 | 155 |
bmpWidth = bitmap.getWidth(); |
| 155 |
|
|
| 156 |
water = new DistortedBitmap(bitmap, 50); |
|
| 157 |
water.addEventListener(this); |
|
| 156 |
|
|
| 157 |
mGrid = new DistortedBitmapGrid(50,50*bmpHeight/bmpWidth); |
|
| 158 |
mWater = new DistortedObject(bmpWidth,bmpHeight,1); |
|
| 159 |
mWater.setTexture(bitmap); |
|
| 160 |
mWater.addEventListener(this); |
|
| 158 | 161 |
|
| 159 | 162 |
for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble(); |
| 160 | 163 |
|
| src/main/java/org/distorted/examples/matrix3d/Matrix3DActivity.java | ||
|---|---|---|
| 32 | 32 |
|
| 33 | 33 |
import org.distorted.examples.R; |
| 34 | 34 |
import org.distorted.library.Distorted; |
| 35 |
import org.distorted.library.DistortedCubes; |
|
| 35 |
import org.distorted.library.DistortedObjectGrid; |
|
| 36 |
import org.distorted.library.DistortedCubesGrid; |
|
| 36 | 37 |
import org.distorted.library.DistortedObject; |
| 37 | 38 |
import org.distorted.library.EffectNames; |
| 38 | 39 |
import org.distorted.library.EffectTypes; |
| ... | ... | |
| 46 | 47 |
public class Matrix3DActivity extends Activity implements AdapterView.OnItemSelectedListener |
| 47 | 48 |
{
|
| 48 | 49 |
private DistortedObject mObject; |
| 50 |
private DistortedObjectGrid mGrid; |
|
| 49 | 51 |
|
| 50 | 52 |
private ArrayList<Matrix3DEffect> mEffects; |
| 51 | 53 |
private int mEffectAdd; |
| ... | ... | |
| 66 | 68 |
|
| 67 | 69 |
createEffectNames(); |
| 68 | 70 |
|
| 69 |
mObject = new DistortedCubes( 1, "1", 100); |
|
| 71 |
mGrid = new DistortedCubesGrid(1,1,false); |
|
| 72 |
mObject = new DistortedObject(1,1,1); |
|
| 70 | 73 |
|
| 71 | 74 |
setEffectView(); |
| 72 | 75 |
} |
| ... | ... | |
| 102 | 105 |
return mObject; |
| 103 | 106 |
} |
| 104 | 107 |
|
| 108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 109 |
|
|
| 110 |
public DistortedObjectGrid getGrid() |
|
| 111 |
{
|
|
| 112 |
return mGrid; |
|
| 113 |
} |
|
| 114 |
|
|
| 105 | 115 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 106 | 116 |
|
| 107 | 117 |
public void setRegion(float x, float y, float r) |
| src/main/java/org/distorted/examples/matrix3d/Matrix3DRenderer.java | ||
|---|---|---|
| 23 | 23 |
import android.opengl.GLSurfaceView; |
| 24 | 24 |
|
| 25 | 25 |
import org.distorted.library.Distorted; |
| 26 |
import org.distorted.library.DistortedObjectGrid; |
|
| 26 | 27 |
import org.distorted.library.DistortedObject; |
| 27 | 28 |
import org.distorted.library.EffectTypes; |
| 28 | 29 |
|
| ... | ... | |
| 35 | 36 |
{
|
| 36 | 37 |
private GLSurfaceView mView; |
| 37 | 38 |
private DistortedObject mObject; |
| 39 |
private DistortedObjectGrid mGrid; |
|
| 38 | 40 |
|
| 39 | 41 |
private int mWidth, mHeight; |
| 40 | 42 |
|
| ... | ... | |
| 44 | 46 |
{
|
| 45 | 47 |
mView = v; |
| 46 | 48 |
|
| 47 |
mObject= ((Matrix3DActivity)v.getContext()).getObject(); |
|
| 49 |
Matrix3DActivity act = (Matrix3DActivity)v.getContext(); |
|
| 50 |
|
|
| 51 |
mObject= act.getObject(); |
|
| 52 |
mGrid = act.getGrid(); |
|
| 48 | 53 |
} |
| 49 | 54 |
|
| 50 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 55 | 60 |
|
| 56 | 61 |
long time = System.currentTimeMillis(); |
| 57 | 62 |
|
| 58 |
mObject.draw(time); |
|
| 63 |
mObject.draw(time,mGrid);
|
|
| 59 | 64 |
} |
| 60 | 65 |
|
| 61 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 92 | 97 |
|
| 93 | 98 |
Matrix3DActivity act = (Matrix3DActivity)mView.getContext(); |
| 94 | 99 |
|
| 95 |
mObject.setBitmap( act.getBitmap() );
|
|
| 100 |
mObject.setTexture(act.getBitmap());
|
|
| 96 | 101 |
|
| 97 | 102 |
try |
| 98 | 103 |
{
|
| src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
import org.distorted.library.Distorted; |
| 30 |
import org.distorted.library.DistortedBitmap; |
|
| 30 |
import org.distorted.library.DistortedObject; |
|
| 31 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 31 | 32 |
import org.distorted.library.EffectTypes; |
| 32 | 33 |
import org.distorted.library.type.Dynamic3D; |
| 33 |
import org.distorted.library.type.Static2D; |
|
| 34 | 34 |
import org.distorted.library.type.Static3D; |
| 35 | 35 |
import org.distorted.library.type.Static4D; |
| 36 | 36 |
|
| ... | ... | |
| 44 | 44 |
class MonaLisaRenderer implements GLSurfaceView.Renderer |
| 45 | 45 |
{
|
| 46 | 46 |
private GLSurfaceView mView; |
| 47 |
private DistortedBitmap monaLisa; |
|
| 47 |
private DistortedObject mObject; |
|
| 48 |
private DistortedBitmapGrid mGrid; |
|
| 48 | 49 |
private Static3D pLeft, pRight; |
| 49 | 50 |
private Static4D rLeft, rRight; |
| 50 | 51 |
private Dynamic3D dLeft, dRight; |
| ... | ... | |
| 75 | 76 |
public void onDrawFrame(GL10 glUnused) |
| 76 | 77 |
{
|
| 77 | 78 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 78 |
monaLisa.draw(System.currentTimeMillis());
|
|
| 79 |
mObject.draw(System.currentTimeMillis(),mGrid);
|
|
| 79 | 80 |
} |
| 80 | 81 |
|
| 81 | 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 82 | 83 |
|
| 83 | 84 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 84 | 85 |
{
|
| 85 |
monaLisa.abortEffects(EffectTypes.MATRIX);
|
|
| 86 |
mObject.abortEffects(EffectTypes.MATRIX);
|
|
| 86 | 87 |
|
| 87 | 88 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
| 88 | 89 |
{
|
| 89 | 90 |
int w = (height*bmpWidth)/bmpHeight; |
| 90 | 91 |
float factor = (float)height/bmpHeight; |
| 91 |
monaLisa.move( new Static3D((width-w)/2,0,0) );
|
|
| 92 |
monaLisa.scale(factor);
|
|
| 92 |
mObject.move( new Static3D((width-w)/2,0,0) );
|
|
| 93 |
mObject.scale(factor);
|
|
| 93 | 94 |
} |
| 94 | 95 |
else |
| 95 | 96 |
{
|
| 96 | 97 |
int h = (width*bmpHeight)/bmpWidth; |
| 97 | 98 |
float factor = (float)width/bmpWidth; |
| 98 |
monaLisa.move( new Static3D(0,(height-h)/2,0) );
|
|
| 99 |
monaLisa.scale(factor);
|
|
| 99 |
mObject.move( new Static3D(0,(height-h)/2,0) );
|
|
| 100 |
mObject.scale(factor);
|
|
| 100 | 101 |
} |
| 101 | 102 |
|
| 102 | 103 |
Distorted.onSurfaceChanged(width, height); |
| ... | ... | |
| 127 | 128 |
bmpHeight = bitmap.getHeight(); |
| 128 | 129 |
bmpWidth = bitmap.getWidth(); |
| 129 | 130 |
|
| 130 |
monaLisa = new DistortedBitmap(bitmap, 9); |
|
| 131 |
monaLisa.distort( dLeft, pLeft , rLeft ); |
|
| 132 |
monaLisa.distort(dRight, pRight, rRight); |
|
| 131 |
mGrid = new DistortedBitmapGrid(9,9*bmpHeight/bmpWidth); |
|
| 132 |
mObject = new DistortedObject(bmpWidth,bmpHeight,1); |
|
| 133 |
mObject.setTexture(bitmap); |
|
| 134 |
mObject.distort( dLeft, pLeft , rLeft ); |
|
| 135 |
mObject.distort(dRight, pRight, rRight); |
|
| 133 | 136 |
|
| 134 | 137 |
try |
| 135 | 138 |
{
|
| src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
|---|---|---|
| 29 | 29 |
import android.opengl.GLES20; |
| 30 | 30 |
import android.opengl.GLSurfaceView; |
| 31 | 31 |
|
| 32 |
import org.distorted.library.DistortedBitmap; |
|
| 32 |
import org.distorted.library.DistortedObject; |
|
| 33 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 33 | 34 |
import org.distorted.library.Distorted; |
| 34 | 35 |
|
| 35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 42 | 43 |
private Paint mPaint; |
| 43 | 44 |
private int texW, texH; |
| 44 | 45 |
|
| 45 |
static DistortedBitmap mBackground; |
|
| 46 |
private DistortedBitmapGrid mGrid; |
|
| 47 |
|
|
| 48 |
static DistortedObject mBackground; |
|
| 46 | 49 |
|
| 47 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 48 | 51 |
|
| ... | ... | |
| 102 | 105 |
texW = width; |
| 103 | 106 |
texH = height; |
| 104 | 107 |
|
| 105 |
mBackground = new DistortedBitmap(texW,texH, 80); |
|
| 108 |
mGrid = new DistortedBitmapGrid(80,80*height/width); |
|
| 109 |
mBackground = new DistortedObject(texW,texH,1); |
|
| 106 | 110 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
| 107 | 111 |
mCanvas = new Canvas(mBitmap); |
| 108 | 112 |
|
| ... | ... | |
| 122 | 126 |
{
|
| 123 | 127 |
drawBackground(); |
| 124 | 128 |
mView.drawCurve(mCanvas,time); |
| 125 |
mBackground.setBitmap(mBitmap);
|
|
| 129 |
mBackground.setTexture(mBitmap);
|
|
| 126 | 130 |
} |
| 127 | 131 |
|
| 128 |
mBackground.draw(time); |
|
| 132 |
mBackground.draw(time,mGrid);
|
|
| 129 | 133 |
} |
| 130 | 134 |
|
| 131 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
|---|---|---|
| 33 | 33 |
import org.distorted.library.type.Static3D; |
| 34 | 34 |
import org.distorted.library.type.Static1D; |
| 35 | 35 |
import org.distorted.library.Distorted; |
| 36 |
import org.distorted.library.DistortedBitmap; |
|
| 36 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 37 |
import org.distorted.library.DistortedObject; |
|
| 37 | 38 |
|
| 38 | 39 |
import android.graphics.Bitmap; |
| 39 | 40 |
import android.graphics.BitmapFactory; |
| ... | ... | |
| 50 | 51 |
|
| 51 | 52 |
private GLSurfaceView mView; |
| 52 | 53 |
private DistortedNode mScreen; |
| 53 |
private DistortedBitmap mLeaf;
|
|
| 54 |
private DistortedObject mLeaf;
|
|
| 54 | 55 |
|
| 55 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 56 | 57 |
|
| 57 | 58 |
OlimpicRenderer(GLSurfaceView v) |
| 58 | 59 |
{
|
| 59 | 60 |
mView = v; |
| 60 |
|
|
| 61 |
mLeaf = new DistortedBitmap(LEAF_SIZE,LEAF_SIZE,1); |
|
| 62 |
|
|
| 63 |
mScreen = new DistortedNode(new DistortedBitmap(9*LEAF_SIZE,9*LEAF_SIZE,1)); |
|
| 61 |
|
|
| 62 |
mLeaf = new DistortedObject(LEAF_SIZE,LEAF_SIZE,1); |
|
| 63 |
DistortedBitmapGrid grid = new DistortedBitmapGrid(1,1); |
|
| 64 |
|
|
| 65 |
mScreen = new DistortedNode(new DistortedObject(9*LEAF_SIZE,9*LEAF_SIZE,1), grid); |
|
| 64 | 66 |
|
| 65 | 67 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
| 66 | 68 |
rot.setMode(Dynamic1D.MODE_JUMP); |
| ... | ... | |
| 72 | 74 |
int[] colors = new int[] {0,0,1, 0,0,0, 1,0,0, 1,1,0, 0,1,0}; // blue, black, red, yellow, green
|
| 73 | 75 |
int[] positions = new int[] {0*LEAF_SIZE,2*LEAF_SIZE, 3*LEAF_SIZE,2*LEAF_SIZE, 6*LEAF_SIZE,2*LEAF_SIZE, 3*LEAF_SIZE/2,9*LEAF_SIZE/2, 9*LEAF_SIZE/2,9*LEAF_SIZE/2};
|
| 74 | 76 |
|
| 75 |
DistortedBitmap tmp;
|
|
| 77 |
DistortedObject tmp;
|
|
| 76 | 78 |
Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0); |
| 77 | 79 |
Static3D axis = new Static3D(0,0,1); |
| 78 | 80 |
Static3D moveVector = new Static3D(0,LEAF_SIZE,0); |
| ... | ... | |
| 81 | 83 |
{
|
| 82 | 84 |
if( i==0 ) |
| 83 | 85 |
{
|
| 84 |
mCircleNode[i] = new DistortedNode(new DistortedBitmap(3*LEAF_SIZE,3*LEAF_SIZE,1));
|
|
| 86 |
mCircleNode[i] = new DistortedNode(new DistortedObject(3*LEAF_SIZE,3*LEAF_SIZE,1), grid);
|
|
| 85 | 87 |
|
| 86 | 88 |
for(int j=0; j<NUM_LEAVES; j++) |
| 87 | 89 |
{
|
| 88 |
tmp = new DistortedBitmap(mLeaf, Distorted.CLONE_BITMAP);
|
|
| 89 |
mCircleNode[i].attach(tmp); |
|
| 90 |
tmp = new DistortedObject(mLeaf, Distorted.CLONE_BITMAP);
|
|
| 91 |
mCircleNode[i].attach(tmp,grid);
|
|
| 90 | 92 |
tmp.rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center ); |
| 91 | 93 |
tmp.move(moveVector); |
| 92 | 94 |
} |
| ... | ... | |
| 97 | 99 |
} |
| 98 | 100 |
|
| 99 | 101 |
mScreen.attach(mCircleNode[i]); |
| 100 |
tmp = (DistortedBitmap)mCircleNode[i].getObject();
|
|
| 102 |
tmp = mCircleNode[i].getObject(); |
|
| 101 | 103 |
tmp.move( new Static3D(positions[2*i], positions[2*i+1], 0) ); |
| 102 | 104 |
tmp.rotate( rot, axis, center ); |
| 103 | 105 |
tmp.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) ); |
| ... | ... | |
| 116 | 118 |
|
| 117 | 119 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 118 | 120 |
{
|
| 119 |
DistortedBitmap bmp = (DistortedBitmap)mScreen.getObject();
|
|
| 121 |
DistortedObject bmp = mScreen.getObject();
|
|
| 120 | 122 |
int bmpWidth = bmp.getWidth(); |
| 121 | 123 |
int bmpHeight = bmp.getHeight(); |
| 122 | 124 |
|
| ... | ... | |
| 164 | 166 |
catch(IOException e) { }
|
| 165 | 167 |
} |
| 166 | 168 |
|
| 167 |
mLeaf.setBitmap(leaf);
|
|
| 169 |
mLeaf.setTexture(leaf);
|
|
| 168 | 170 |
|
| 169 | 171 |
try |
| 170 | 172 |
{
|
| src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
|---|---|---|
| 31 | 31 |
import android.view.SurfaceView; |
| 32 | 32 |
|
| 33 | 33 |
import org.distorted.library.Distorted; |
| 34 |
import org.distorted.library.DistortedBitmap; |
|
| 34 |
import org.distorted.library.DistortedBitmapGrid; |
|
| 35 |
import org.distorted.library.DistortedObject; |
|
| 35 | 36 |
import org.distorted.library.EffectTypes; |
| 36 | 37 |
import org.distorted.library.type.Dynamic3D; |
| 37 |
import org.distorted.library.type.Static2D; |
|
| 38 | 38 |
import org.distorted.library.type.Static3D; |
| 39 | 39 |
import org.distorted.library.type.Static4D; |
| 40 | 40 |
import org.distorted.examples.R; |
| ... | ... | |
| 60 | 60 |
private EglCore eglCore; |
Also available in: Unified diff
Major change in API: separate the GRID from DistortedObject; completely remove classes derived from DistortedObject.