Project

General

Profile

« Previous | Next » 

Revision 7589635e

Added by Leszek Koltunski almost 8 years ago

Major push towards simplifying DistortedObject's public API.
All MATRIX effects are using the new API - the 'DataND' marker interfaces.

View differences:

src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
30 30
import org.distorted.library.Distorted;
31 31
import org.distorted.library.DistortedBitmap;
32 32
import org.distorted.library.EffectTypes;
33
import org.distorted.library.type.Float2D;
34
import org.distorted.library.type.Float3D;
35
import org.distorted.library.type.Float4D;
36
import org.distorted.library.type.Interpolator3D;
33
import org.distorted.library.type.Dynamic3D;
34
import org.distorted.library.type.Static2D;
35
import org.distorted.library.type.Static3D;
36
import org.distorted.library.type.Static4D;
37 37

  
38 38
import android.graphics.Bitmap;
39 39
import android.graphics.BitmapFactory;
......
48 48
   
49 49
   private GLSurfaceView mView;
50 50
   private DistortedBitmap[] bmp;
51
   private Float2D pLeft, pRight, pNose1;
52
   private Float4D RegionEye;
53
   private Interpolator3D mDI;
54
   private Float3D[] vec;
51
   private Static2D pLeft, pRight, pNose1;
52
   private Static4D RegionEye;
53
   private Dynamic3D mDI;
54
   private Static3D[] vec;
55 55
   private int bmpHeight, bmpWidth;
56 56
    
57 57
///////////////////////////////////////////////////////////////////////////////////////////////////
......
61 61
      mView = v;
62 62
      
63 63
      // bmp[0] effects
64
      pLeft = new Float2D(214, 206);
65
      pRight= new Float2D(390, 212);
66
      RegionEye = new Float4D(0,0,60,60);
64
      pLeft = new Static2D(214, 206);
65
      pRight= new Static2D(390, 212);
66
      RegionEye = new Static4D(0,0,60,60);
67 67
      
68 68
      // bmp[1] effects
69
      mDI = new Interpolator3D();
69
      mDI = new Dynamic3D();
70 70
      mDI.setCount(0.0f);
71 71
      mDI.setDuration(1000);
72
      vec = new Float3D[2];
73
      vec[0] = new Float3D( 50,0,0);
74
      vec[1] = new Float3D(-50,0,0);
72
      vec = new Static3D[2];
73
      vec[0] = new Static3D( 50,0,0);
74
      vec[1] = new Static3D(-50,0,0);
75 75
      mDI.add(vec[0]);
76 76
      mDI.add(vec[1]);
77
      pNose1 = new Float2D(305, 340);
77
      pNose1 = new Static2D(305, 340);
78 78
      
79 79
      // we don't need to prepare anything for bmp[2] effects
80 80
      }
......
103 103
      if( bmpHeight/(NUM*bmpWidth) > height/width )
104 104
        {
105 105
        int w = (height*bmpWidth)/bmpHeight;
106
      
106
        float factor = (float)height/bmpHeight;
107
        Static3D scaleFactor = new Static3D(factor,factor,factor);
108

  
107 109
        for(int i=NUM-1; i>=0; i--) 
108 110
          {
109
          bmp[i].move( (width-NUM*w)/2 +i*w ,0, 0);
110
          bmp[i].scale((float)height/bmpHeight);
111
          bmp[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
112
          bmp[i].scale(scaleFactor);
111 113
          }
112 114
        }
113 115
      else
114 116
        {
115 117
        int w = width/NUM;  
116 118
        int h = (width*bmpHeight)/(bmpWidth*NUM);
117
      
119
        float factor = (float)width/(bmpWidth*NUM);
120
        Static3D scaleFactor = new Static3D(factor,factor,factor);
121

  
118 122
        for(int i=NUM-1; i>=0; i--) 
119 123
          {
120
          bmp[i].move(i*w, (height-h)/2, 0);  
121
          bmp[i].scale((float)width/(bmpWidth*NUM));
124
          bmp[i].move( new Static3D(i*w, (height-h)/2, 0) );
125
          bmp[i].scale(scaleFactor);
122 126
          }
123 127
        }
124 128
       

Also available in: Unified diff