Project

General

Profile

« Previous | Next » 

Revision 20e888ea

Added by Leszek Koltunski over 7 years ago

Further progress with Apps.

View differences:

src/main/java/org/distorted/examples/listener/ListenerRenderer.java
28 28

  
29 29
import org.distorted.examples.R;
30 30

  
31
import org.distorted.library.effect.EffectName;
32
import org.distorted.library.effect.MatrixEffectMove;
33
import org.distorted.library.effect.MatrixEffectScale;
34
import org.distorted.library.effect.VertexEffectDistort;
31 35
import org.distorted.library.main.Distorted;
32 36
import org.distorted.library.main.DistortedScreen;
33 37
import org.distorted.library.main.MeshFlat;
34 38
import org.distorted.library.main.DistortedTexture;
35 39
import org.distorted.library.main.DistortedEffects;
36
import org.distorted.library.EffectNames;
37
import org.distorted.library.EffectTypes;
38 40
import org.distorted.library.type.Dynamic3D;
39 41
import org.distorted.library.type.Static3D;
40 42
import org.distorted.library.type.Static4D;
......
58 60
   private MeshFlat mMesh;
59 61
   private int bmpHeight, bmpWidth;
60 62
   private Random mRnd;
63
   private Static3D mMove, mScale;
61 64

  
62 65
///////////////////////////////////////////////////////////////////////////////////////////////////
63 66

  
......
69 72
      mEffects.registerForMessages(this);
70 73
      mScreen = new DistortedScreen(mView);
71 74
      mRnd = new Random(0);
75

  
76
      mMove = new Static3D(0,0,0);
77
      mScale= new Static3D(1,1,1);
78
      mEffects.apply(new MatrixEffectMove(mMove));
79
      mEffects.apply(new MatrixEffectScale(mScale));
72 80
      }
73 81

  
74 82
///////////////////////////////////////////////////////////////////////////////////////////////////
75 83

  
76
   private long randomizeNewBubble()
84
   private boolean randomizeNewBubble()
77 85
      {
78 86
      int radius   = (int)(( 0.10f + 0.70f*mRnd.nextFloat())*bmpWidth);           // pop up a bubble of size (radius,height)
79 87
      int height   = (int)((-0.10f + 0.20f*mRnd.nextFloat())*bmpWidth);           // 
......
85 93
      dDistort.add(new Static3D(0,0,     0));
86 94
      dDistort.add(new Static3D(0,0,height));
87 95

  
88
      return mEffects.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
96
      return mEffects.apply( new VertexEffectDistort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius)) );
89 97
      }
90 98
   
91 99
///////////////////////////////////////////////////////////////////////////////////////////////////
92 100
// the library sending messages to us. This is running on a library 'MessageSender' thread.
93 101

  
94
   public void effectMessage(final EffectMessage em, final long effectID, final EffectNames effectName, final long objectID)
102
   public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
95 103
     {
96 104
     switch(em)
97 105
        {
......
111 119
    
112 120
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
113 121
     {
114
     mEffects.abortEffects(EffectTypes.MATRIX);
115
         
116 122
     if( (float)bmpHeight/bmpWidth > (float)height/width )
117 123
       {
118 124
       int w = (height*bmpWidth)/bmpHeight;
119 125
       float factor = (float)height/bmpHeight;
120 126

  
121
       mEffects.move( new Static3D((width-w)/2,0,0) );
122
       mEffects.scale(factor);
127
       mMove.set((width-w)/2,0,0);
128
       mScale.set(factor,factor,factor);
123 129
       }
124 130
     else
125 131
       {
126 132
       int h = (width*bmpHeight)/bmpWidth;
127 133
       float factor = (float)width/bmpWidth;
128 134

  
129
       mEffects.move( new Static3D(0,(height-h)/2,0) );
130
       mEffects.scale(factor);
135
       mMove.set(0,(height-h)/2,0);
136
       mScale.set(factor,factor,factor);
131 137
       }
132 138
      
133 139
     mScreen.resize(width, height);
......
166 172

  
167 173
     for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble();
168 174

  
169
     DistortedEffects.enableEffect(EffectNames.DISTORT);
175
     DistortedEffects.enableEffect(EffectName.DISTORT);
170 176

  
171 177
     try
172 178
       {

Also available in: Unified diff