Project

General

Profile

« Previous | Next » 

Revision f6d884d5

Added by Leszek Koltunski over 7 years ago

Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)

View differences:

src/main/java/org/distorted/examples/fbo/FBORenderer.java
30 30
import org.distorted.library.DistortedObjectTree;
31 31
import org.distorted.library.Distorted;
32 32
import org.distorted.library.GridFlat;
33
import org.distorted.library.DistortedObject;
33
import org.distorted.library.DistortedTexture;
34
import org.distorted.library.DistortedEffectQueues;
34 35
import org.distorted.library.EffectTypes;
35 36
import org.distorted.library.type.Dynamic1D;
36 37
import org.distorted.library.type.Static1D;
......
46 47
class FBORenderer implements GLSurfaceView.Renderer 
47 48
{
48 49
   private GLSurfaceView mView;
49
   private DistortedObject mLisa;
50
   private DistortedEffectQueues mQueues;
50 51
   private int lisaHeight, lisaWidth;
51 52
    
52 53
   private DistortedObjectTree mRoot;
......
56 57
   FBORenderer(GLSurfaceView v)
57 58
      {
58 59
      mView = v;
60
      mQueues = new DistortedEffectQueues();
59 61
      }
60 62

  
61 63
///////////////////////////////////////////////////////////////////////////////////////////////////
......
70 72
    
71 73
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
72 74
      { 
73
      mLisa.abortEffects(EffectTypes.MATRIX);
75
      mQueues.abortEffects(EffectTypes.MATRIX);
74 76
         
75 77
      if( (float)lisaHeight/lisaWidth > (float)height/width )
76 78
        {
77 79
        int w = (height*lisaWidth)/lisaHeight;
78 80
        float factor = (float)height/lisaHeight;
79 81

  
80
        mLisa.move( new Static3D((width-w)/2,0,0) );
81
        mLisa.scale(factor);
82
        mQueues.move( new Static3D((width-w)/2,0,0) );
83
        mQueues.scale(factor);
82 84
        }
83 85
      else
84 86
        {
85 87
        int h = (width*lisaHeight)/lisaWidth;
86 88
        float factor = (float)width/lisaWidth;
87 89

  
88
        mLisa.move( new Static3D(0,(height-h)/2,0) );
89
        mLisa.scale(factor);
90
        mQueues.move( new Static3D(0,(height-h)/2,0) );
91
        mQueues.scale(factor);
90 92
        }
91 93
      
92 94
      Distorted.onSurfaceChanged(width, height); 
......
118 120
        catch(IOException e) { }
119 121
        }  
120 122
      
121
      lisaHeight = bitmap1.getHeight();
122
      lisaWidth  = bitmap1.getWidth();
123
      
124
      mLisa = new DistortedObject(lisaWidth, lisaHeight, 1);
125
      mLisa.setTexture(bitmap1);
126
      DistortedObject text = new DistortedObject(bitmap2.getWidth(),bitmap2.getHeight(),1);
123
      lisaWidth     = bitmap1.getWidth();
124
      lisaHeight    = bitmap1.getHeight();
125
      int textWidth = bitmap2.getWidth();
126
      int textHeight= bitmap2.getHeight();
127

  
128
      DistortedTexture lisa = new DistortedTexture(lisaWidth,lisaHeight,0);
129
      DistortedTexture text = new DistortedTexture(textWidth,textHeight,0);
130
      lisa.setTexture(bitmap1);
127 131
      text.setTexture(bitmap2);
132
      DistortedEffectQueues textQueues = new DistortedEffectQueues();
128 133

  
129
      mRoot = new DistortedObjectTree(mLisa,new GridFlat(1,1));
130
      mRoot.attach(text,new GridFlat(20,5));
131
     
132
      int textWidth  = text.getWidth();
133
      int textHeight = text.getHeight();
134
      mRoot = new DistortedObjectTree(lisa,mQueues,new GridFlat(1,1));
135
      mRoot.attach(text,textQueues,new GridFlat(20,5));
134 136

  
135 137
      float factor = lisaWidth/(1.5f*textWidth);
136 138

  
137
      text.move( new Static3D(lisaWidth/6,lisaHeight/3,0) );
138
      text.scale(factor);
139
      textQueues.move( new Static3D(lisaWidth/6,lisaHeight/3,0) );
140
      textQueues.scale(factor);
139 141

  
140 142
      Dynamic1D sinkDyn = new Dynamic1D(5000,0.0f);
141 143
      sinkDyn.add(new Static1D(1.0f));
142 144
      sinkDyn.add(new Static1D(0.5f));
143 145

  
144
      text.sink(sinkDyn, new Static3D(textWidth/2,textHeight/2, 0));
146
      textQueues.sink(sinkDyn, new Static3D(textWidth/2,textHeight/2, 0));
145 147

  
146 148
      Dynamic1D chromaDyn = new Dynamic1D(10000,0.0f);
147 149
      chromaDyn.add(new Static1D(0.0f));
148 150
      chromaDyn.add(new Static1D(0.5f));
149 151

  
150
      mLisa.chroma(chromaDyn, new Static3D(0,0,1) );
152
      mQueues.chroma(chromaDyn, new Static3D(0,0,1) );
151 153
      
152 154
      try
153 155
        {

Also available in: Unified diff