Project

General

Profile

« Previous | Next » 

Revision e8b6aa95

Added by Leszek Koltunski over 7 years ago

Major change in API: separate the GRID from DistortedObject; completely remove classes derived from DistortedObject.

View differences:

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
      }

Also available in: Unified diff