Project

General

Profile

« Previous | Next » 

Revision 5a683295

Added by Leszek Koltunski about 4 years ago

Size of the FBO internal to Nodes is now NO MORE taken from the Mesh's stretch values.
Instead, the size is copied from child's FBO size (if there is one) or if the child is a leaf with texture in it (which is sizeless) then we get the default 100x100 ( which means we probably have to explicitly call Node.resizeFBO() )

View differences:

src/main/java/org/distorted/examples/movingglow/MovingGlowRenderer.java
62 62
   private DistortedScreen mScreen;
63 63
   private DistortedEffects[] mLeafEffects = new DistortedEffects[NUM_LEAVES];
64 64
   private PostprocessEffectGlow[] mGlow = new PostprocessEffectGlow[NUM_LEAVES];
65
   private int mRootW, mRootH;
66 65
   private int mGlowing;
67 66
   private Static3D mScale;
68 67

  
......
72 71
      {     
73 72
      mView = v;
74 73

  
75
      mRootW = 5*LEAF_SIZE;
76
      mRootH = 5*LEAF_SIZE;
77

  
74
      MeshQuad mesh = new MeshQuad();
75
      mScale= new Static3D(1,1,1);
78 76
      mLeaf = new DistortedTexture();
79 77
      DistortedTexture surface = new DistortedTexture();
80 78

  
81
      MeshQuad rootMesh = new MeshQuad();
82
      rootMesh.setStretch(mRootW,mRootH,0);
83
      MeshQuad leafMesh = new MeshQuad();
84
      leafMesh.setStretch(LEAF_SIZE,LEAF_SIZE,0);
85

  
86
      DistortedEffects rootEffects = new DistortedEffects();
87
      DistortedNode root = new DistortedNode(surface, rootEffects, rootMesh);
88

  
89 79
      Static3D moveVector = new Static3D(-1.45f*LEAF_SIZE, 0, 0);
90 80
      Static1D chromaLevel= new Static1D(0.5f);
91 81
      Static3D center     = new Static3D(0,0,0);
92 82
      Static3D axis       = new Static3D(0,0,1);
93 83

  
84
      Dynamic1D rot = new Dynamic1D(5000,0.0f);
85
      rot.setMode(Dynamic1D.MODE_JUMP);
86
      rot.add(new Static1D(  0));
87
      rot.add(new Static1D(360));
88

  
89
      DistortedEffects rootEffects = new DistortedEffects();
90
      rootEffects.apply(new MatrixEffectRotate(rot, axis, center) );
91
      rootEffects.apply(new MatrixEffectScale(mScale));
92

  
93
      DistortedNode root = new DistortedNode(surface, rootEffects, mesh);
94
      root.resizeFBO(5*LEAF_SIZE,5*LEAF_SIZE);
95

  
94 96
      MatrixEffectMove leafMove = new MatrixEffectMove(moveVector);
95 97

  
96 98
      for(int j=0; j<NUM_LEAVES; j++)
97 99
        {
98 100
        mLeafEffects[j] = new DistortedEffects();
101
        mLeafEffects[j].apply( new MatrixEffectScale(LEAF_SIZE) );
99 102
        mLeafEffects[j].apply(leafMove);
100 103
        mLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
101 104
        mLeafEffects[j].apply( new FragmentEffectChroma(chromaLevel, new Static3D(colors[3*j],colors[3*j+1], colors[3*j+2])) );
102
        DistortedNode node = new DistortedNode( mLeaf, mLeafEffects[j], leafMesh);
105
        DistortedNode node = new DistortedNode( mLeaf, mLeafEffects[j], mesh);
103 106
        root.attach(node);
104 107
        }
105 108

  
106
      mScale= new Static3D(1,1,1);
107

  
108
      Dynamic1D rot = new Dynamic1D(5000,0.0f);
109
      rot.setMode(Dynamic1D.MODE_JUMP);
110
      rot.add(new Static1D(  0));
111
      rot.add(new Static1D(360));
112

  
113
      DistortedEffects effects = root.getEffects();
114
      effects.apply(new MatrixEffectRotate(rot, axis, center) );
115
      effects.apply(new MatrixEffectScale(mScale));
116

  
117 109
      Dynamic1D radiusDyn = new Dynamic1D(FLASH_TIME,1.0f);
118 110
      radiusDyn.add(new Static1D( 0));
119 111
      radiusDyn.add(new Static1D(50));
......
167 159
    
168 160
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
169 161
     {
170
     float qw = (float)width /mRootW;
171
     float qh = (float)height/mRootH;
162
     float qw = (float)width ;
163
     float qh = (float)height;
172 164
     float factor = 0.9f* (qw<qh ? qw:qh);
173 165

  
174 166
     mScale.set( factor,factor,factor );
src/main/java/org/distorted/examples/objecttree/ObjectTreeRenderer.java
37 37
import org.distorted.library.main.DistortedScreen;
38 38
import org.distorted.library.main.DistortedLibrary;
39 39
import org.distorted.library.mesh.MeshCubes;
40
import org.distorted.library.mesh.MeshRectangles;
40
import org.distorted.library.mesh.MeshQuad;
41 41
import org.distorted.library.main.DistortedTexture;
42 42
import org.distorted.library.type.Dynamic;
43 43
import org.distorted.library.type.Dynamic1D;
......
55 55

  
56 56
class ObjectTreeRenderer implements GLSurfaceView.Renderer
57 57
{
58
   private static final int NODE_FBO_SIZE = 300;
59

  
58 60
   private GLSurfaceView mView;
59
   private DistortedEffects mEffects;
61
   private DistortedEffects mEffectsNode, mEffectsGrid;
60 62
   private DistortedTexture mLisaTexture, mGridTexture;
61 63
   private DistortedScreen mScreen;
62 64
   private DistortedNode mRoot;
63
   private MeshRectangles mMeshRectangles;
65
   private MeshQuad mMeshQuad;
64 66
   private MeshCubes mMeshCubes;
65 67
   private boolean mDepth;
66 68
   private Static3D mScale;
69
   private float mLisaAspectRatio;
67 70

  
68 71
///////////////////////////////////////////////////////////////////////////////////////////////////
69 72

  
......
76 79
      chromaDyn.add(new Static1D(0.0f));
77 80
      chromaDyn.add(new Static1D(0.8f));
78 81

  
79
      mEffects= new DistortedEffects();
80
      mEffects.apply(new MatrixEffectScale(mScale));
81
      mEffects.apply(new FragmentEffectChroma(chromaDyn, new Static3D(0,0,1)));
82
      mEffectsNode= new DistortedEffects();
83
      mEffectsNode.apply(new MatrixEffectScale(mScale));
84
      mEffectsNode.apply(new FragmentEffectChroma(chromaDyn, new Static3D(0,0,1)));
85

  
86
      mEffectsGrid = new DistortedEffects();
87

  
88
      float factor = NODE_FBO_SIZE/2;
89
      MatrixEffectScale scale = new MatrixEffectScale( new Static3D(factor,factor,factor/10) );
90
      mEffectsGrid.apply(scale);
91

  
92
      Dynamic1D rotDyn = new Dynamic1D(12000,0.0f);
93
      rotDyn.add(new Static1D(  0));
94
      rotDyn.add(new Static1D(360));
95
      rotDyn.setMode(Dynamic.MODE_JUMP);
96
      MatrixEffectRotate rotate = new MatrixEffectRotate(rotDyn, new Static3D(1,0,0), new Static3D(0,0,0));
97
      mEffectsGrid.apply(rotate);
98

  
99
      Dynamic1D sinkDyn = new Dynamic1D(3000,0.0f);
100
      sinkDyn.add(new Static1D(1.0f));
101
      sinkDyn.add(new Static1D(0.3f));
102
      VertexEffectSink sink = new VertexEffectSink(sinkDyn, new Static3D(0,0,0) );
103
      mEffectsGrid.apply(sink);
82 104

  
83 105
      mScreen = new DistortedScreen();
84 106
      }
......
116 138
    
117 139
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
118 140
      {
119
      float horiRatio = (float)width / mMeshRectangles.getStretchX();
120
      float vertRatio = (float)height/ mMeshRectangles.getStretchY();
121
      float factor    = horiRatio > vertRatio ? vertRatio : horiRatio;
141
      float hor   = width /mLisaAspectRatio;
142
      float ver   = height;
143
      float factor= hor>ver ? ver : hor;
122 144

  
123 145
      mScale.set( factor,factor,factor );
124 146
      mScreen.resize(width, height);
......
128 150
    
129 151
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
130 152
      {
131
      // TODO
132
      // This appears to be needed in case we create the app anew with NO DEPTH
133
      // (i.e. we set 'no depth' and then rotate screen). Investigate.
134
      GLES31.glEnable(GLES31.GL_CULL_FACE);
135
      GLES31.glCullFace(GLES31.GL_BACK);
136
      GLES31.glFrontFace(GLES31.GL_CW);
137

  
138 153
      Resources res = mView.getContext().getResources();
139 154

  
140
      InputStream is1 = res.openRawResource(R.raw.monalisa);
141
      InputStream is2 = res.openRawResource(R.raw.grid);
155
      InputStream isLisa = res.openRawResource(R.raw.monalisa);
156
      InputStream isGrid = res.openRawResource(R.raw.grid);
142 157
      
143
      Bitmap bitmap1, bitmap2;
158
      Bitmap bitmapLisa, bitmapGrid;
144 159
       
145 160
      try 
146 161
        {
147
        bitmap1 = BitmapFactory.decodeStream(is1);
148
        bitmap2 = BitmapFactory.decodeStream(is2);
162
        bitmapLisa = BitmapFactory.decodeStream(isLisa);
163
        bitmapGrid = BitmapFactory.decodeStream(isGrid);
149 164
        } 
150 165
      finally 
151 166
        {
152 167
        try 
153 168
          {
154
          is1.close();
155
          is2.close();
169
          isLisa.close();
170
          isGrid.close();
156 171
          } 
157 172
        catch(IOException e) { }
158 173
        }  
159 174

  
160
      final int GRID = 20;
161
      final Static4D mapFB = new Static4D(0.0f,0.0f,1.0f     ,1.0f     );
162
      final Static4D mapLR = new Static4D(0.0f,0.0f,1.0f/GRID,1.0f     );
163
      final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f     ,1.0f/GRID);
164

  
165
      int lisaWidth = bitmap1.getWidth();
166
      int lisaHeight= bitmap1.getHeight();
167
      int gridWidth = bitmap2.getWidth();
168
      int gridHeight= bitmap2.getHeight();
169
      int gridDepth = gridWidth/GRID;
175
      mLisaAspectRatio = ((float)bitmapLisa.getWidth())/bitmapLisa.getHeight();
170 176

  
171 177
      if( mLisaTexture==null ) mLisaTexture = new DistortedTexture();
172 178
      if( mGridTexture==null ) mGridTexture = new DistortedTexture();
173
      mLisaTexture.setTexture(bitmap1);
174
      mGridTexture.setTexture(bitmap2);
175

  
176
      DistortedEffects gridEffects = new DistortedEffects();
179
      mLisaTexture.setTexture(bitmapLisa);
180
      mGridTexture.setTexture(bitmapGrid);
177 181

  
178
      if( mMeshRectangles ==null )
179
        {
180
        mMeshRectangles = new MeshRectangles(1,1);
181
        mMeshRectangles.setStretch(lisaWidth,lisaHeight,0);
182
        }
182
      final int GRID = 20;
183
      final Static4D mapFB = new Static4D(0.0f,0.0f,1.0f     ,1.0f     );
184
      final Static4D mapLR = new Static4D(0.0f,0.0f,1.0f/GRID,1.0f     );
185
      final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f     ,1.0f/GRID);
183 186

  
184
      if( mMeshCubes==null)
185
        {
186
        mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB);
187
        mMeshCubes.setStretch(gridWidth,gridHeight,gridDepth);
188
        }
187
      if( mMeshQuad ==null ) mMeshQuad = new MeshQuad();
188
      if( mMeshCubes==null ) mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB);
189 189

  
190
      mRoot = new DistortedNode(mLisaTexture, mEffects, mMeshRectangles);
191
      mRoot.attach(mGridTexture,gridEffects,mMeshCubes);
190
      mRoot = new DistortedNode(mLisaTexture, mEffectsNode, mMeshQuad);
191
      mRoot.resizeFBO(NODE_FBO_SIZE,NODE_FBO_SIZE);
192
      mRoot.attach(mGridTexture, mEffectsGrid, mMeshCubes);
192 193

  
193 194
      setDepthPriv();
194 195

  
195 196
      mScreen.detachAll();
196 197
      mScreen.attach(mRoot);
197 198

  
198
      float factor = lisaWidth/(2.0f*gridWidth);
199
      MatrixEffectScale scale = new MatrixEffectScale( new Static3D(factor,factor,factor) );
200
      gridEffects.apply(scale);
201

  
202
      Dynamic1D rotDyn = new Dynamic1D(12000,0.0f);
203
      rotDyn.add(new Static1D(  0));
204
      rotDyn.add(new Static1D(360));
205
      rotDyn.setMode(Dynamic.MODE_JUMP);
206
      MatrixEffectRotate rotate = new MatrixEffectRotate(rotDyn, new Static3D(1,0,0), new Static3D(0,0,0));
207
      gridEffects.apply(rotate);
208

  
209
      Dynamic1D sinkDyn = new Dynamic1D(3000,0.0f);
210
      sinkDyn.add(new Static1D(1.0f));
211
      sinkDyn.add(new Static1D(0.3f));
212
      VertexEffectSink sink = new VertexEffectSink(sinkDyn, new Static3D(0,0,0) );
213
      gridEffects.apply(sink);
214

  
215 199
      VertexEffectSink.enable();
216 200
      FragmentEffectChroma.enable();
217 201

  
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
58 58
   private DistortedTexture mLeaf;
59 59
   private DistortedScreen mScreen;
60 60
   private MeshQuad mLeafMesh;
61
   private int mScreenW, mScreenH;
62 61
   private int mPrevRendered, mCurrRendered;
63 62
   private Static3D mScale;
64 63

  
......
93 92
      mPrevRendered = -1;
94 93
      mCurrRendered = -1;
95 94

  
96
      mScreenW = 9*LEAF_SIZE;
97
      mScreenH = 9*LEAF_SIZE;
98

  
99 95
      mLeaf = new DistortedTexture();
100 96
      DistortedTexture surface = new DistortedTexture();
101 97

  
102 98
      mLeafMesh = new MeshQuad();
103
      mLeafMesh.setStretch(LEAF_SIZE,LEAF_SIZE,0);
104
      MeshQuad circleMesh = new MeshQuad();
105
      circleMesh.setStretch(3*LEAF_SIZE,3*LEAF_SIZE,0);
106
      MeshQuad rootMesh = new MeshQuad();
107
      rootMesh.setStretch(mScreenW,mScreenH,0);
99
      MeshQuad quad = new MeshQuad();
108 100

  
109 101
      mScale= new Static3D(1,1,1);
110 102

  
111 103
      DistortedEffects rootEffects = new DistortedEffects();
112 104
      rootEffects.apply(new MatrixEffectScale(mScale));
113 105

  
114
      mRoot = new DistortedNode(new DistortedTexture(), rootEffects, rootMesh);
115
     
106
      mRoot = new DistortedNode(new DistortedTexture(), rootEffects, quad);
107
      mRoot.resizeFBO(9*LEAF_SIZE,9*LEAF_SIZE);
108

  
116 109
      Dynamic1D rot = new Dynamic1D(5000,0.0f);
117 110
      rot.setMode(Dynamic1D.MODE_JUMP);
118 111
      rot.add(new Static1D(  0));
......
132 125
      for(int j=0; j<NUM_LEAVES; j++)
133 126
        {
134 127
        mEffects[j] = new DistortedEffects();
135
        mEffects[j].apply(new MatrixEffectMove(moveVector));
128
        mEffects[j].apply( new MatrixEffectScale(LEAF_SIZE) );
129
        mEffects[j].apply( new MatrixEffectMove(moveVector));
136 130
        mEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
137 131
        }
138 132

  
139 133
      for(int i=0; i<NUM_CIRCLES; i++)
140 134
        {
141 135
        DistortedEffects effects = new DistortedEffects();
136
        effects.apply( new MatrixEffectScale(3*LEAF_SIZE) );
142 137
        effects.apply( new MatrixEffectRotate(rot, axis, center) );
143 138
        effects.apply( new MatrixEffectMove(new Static3D(positions[2*i], positions[2*i+1], 0)) );
144 139
        effects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2])) );
145 140

  
146
        mCircleNode[i] = new DistortedNode( surface, effects, circleMesh);
141
        mCircleNode[i] = new DistortedNode( surface, effects, quad);
142
        mCircleNode[i].resizeFBO(3*LEAF_SIZE, 3*LEAF_SIZE);
147 143
        mRoot.attach(mCircleNode[i]);
148 144

  
149 145
        for(int j=0; j<NUM_LEAVES; j++) mCircleNode[i].attach(mLeaf, mEffects[j], mLeafMesh);
......
179 175
    
180 176
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
181 177
     {
182
     float horiRatio = (float)width / mScreenW;
183
     float vertRatio = (float)height/ mScreenH;
178
     float horiRatio = (float)width ;
179
     float vertRatio = (float)height;
184 180
     float factor    = horiRatio > vertRatio ? vertRatio : horiRatio;
185 181

  
186 182
     mScale.set(factor,factor,factor);
src/main/java/org/distorted/examples/postprocesstree/PostprocessTreeRenderer.java
55 55
   private GLSurfaceView mView;
56 56
   private DistortedTexture mLeaf;
57 57
   private DistortedScreen mScreen;
58
   private int mScreenW, mScreenH;
59 58
   private Static3D mScale;
60 59
   private Static1D mRadius;
61 60

  
......
68 67
      final int OUTER = 9;
69 68
      final int INNER = 4;
70 69

  
71
      mScreenW = OUTER*LEAF_SIZE;
72
      mScreenH = OUTER*LEAF_SIZE;
73

  
74 70
      mRadius = new Static1D(5);
75 71
      Dynamic1D radiusDyn = new Dynamic1D();
76 72
      radiusDyn.add(mRadius);
77 73
      PostprocessEffectBlur blurEffect = new PostprocessEffectBlur(radiusDyn);
78 74

  
79 75
      mLeaf = new DistortedTexture();
80

  
81
      MeshQuad rootMesh  = new MeshQuad();
82
      rootMesh.setStretch(mScreenW,mScreenH,0);
83
      MeshQuad innerMesh = new MeshQuad();
84
      innerMesh.setStretch(INNER*LEAF_SIZE,INNER*LEAF_SIZE,0);
85
      MeshQuad leafMesh  = new MeshQuad();
86
      leafMesh.setStretch(LEAF_SIZE,LEAF_SIZE,0);
87

  
88 76
      mScale= new Static3D(1,1,1);
77
      MeshQuad mesh = new MeshQuad();
89 78

  
90 79
      DistortedEffects rootEffects  = new DistortedEffects();
91 80
      DistortedEffects innerEffects = new DistortedEffects();
92 81
      DistortedEffects[] innerLeafEffects= new DistortedEffects[NUM_LEAVES];
93 82
      DistortedEffects[] outerLeafEffects= new DistortedEffects[NUM_LEAVES];
94 83

  
95
      DistortedNode root = new DistortedNode(new DistortedTexture(), rootEffects, rootMesh);
84
      DistortedNode root = new DistortedNode(new DistortedTexture(), rootEffects, mesh);
85
      root.resizeFBO(OUTER*LEAF_SIZE,OUTER*LEAF_SIZE);
96 86

  
97 87
      rootEffects.apply(new MatrixEffectScale(mScale));
98 88
      rootEffects.apply(blurEffect);
......
110 100
      for(int j=0; j<NUM_LEAVES; j++)
111 101
        {
112 102
        outerLeafEffects[j] = new DistortedEffects();
113
        outerLeafEffects[j].apply(new MatrixEffectMove(outerMoveVector));
103
        outerLeafEffects[j].apply( new MatrixEffectScale(LEAF_SIZE) );
104
        outerLeafEffects[j].apply( new MatrixEffectMove(outerMoveVector));
114 105
        outerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
115 106

  
116
        root.attach(mLeaf, outerLeafEffects[j], leafMesh);
107
        root.attach(mLeaf, outerLeafEffects[j], mesh);
117 108
        }
118 109

  
110
      innerEffects.apply( new MatrixEffectScale(INNER*LEAF_SIZE) );
119 111
      innerEffects.apply( new MatrixEffectRotate(rotate, axis, center) );
120 112
      innerEffects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0) ) );
121 113
      innerEffects.apply(blurEffect);
122 114

  
123
      DistortedNode innerNode = new DistortedNode( new DistortedTexture(), innerEffects, innerMesh);
115
      DistortedNode innerNode = new DistortedNode( new DistortedTexture(), innerEffects, mesh);
116
      innerNode.resizeFBO(INNER*LEAF_SIZE,INNER*LEAF_SIZE);
124 117
      root.attach(innerNode);
125 118

  
126 119
      for(int j=0; j<NUM_LEAVES; j++)
127 120
        {
128 121
        innerLeafEffects[j] = new DistortedEffects();
122
        innerLeafEffects[j].apply( new MatrixEffectScale(LEAF_SIZE) );
129 123
        innerLeafEffects[j].apply(new MatrixEffectMove(innerMoveVector));
130 124
        innerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
131 125

  
132
        innerNode.attach( mLeaf, innerLeafEffects[j], leafMesh );
126
        innerNode.attach( mLeaf, innerLeafEffects[j], mesh );
133 127
        }
134 128

  
135 129
      mScreen = new DistortedScreen();
......
156 150
    
157 151
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
158 152
     {
159
     float horiRatio = (float)width / mScreenW;
160
     float vertRatio = (float)height/ mScreenH;
153
     float horiRatio = (float)width ;
154
     float vertRatio = (float)height;
161 155
     float factor    = horiRatio > vertRatio ? vertRatio : horiRatio;
162 156

  
163 157
     mScale.set(factor,factor,factor);
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java
110 110
  private DistortedEffects[] mStarEffects;
111 111
  private DistortedNode mBackground;
112 112
  private DistortedScreen mScreen;
113
  private MeshQuad mGFFAQuad, mCrawlQuad, mCrawlBackgroundQuad, mLogoQuad, mStarQuad;
113
  private MeshQuad mQuad;
114 114

  
115 115
  private long alphaEffectID, scaleEffectID, moveEffectID;
116 116
  private Random mRnd = new Random(0);
117 117
  private int mWidth, mHeight;
118
  private float mLogoRatio;
119
  private int mCrawlBackgroundW, mCrawlBackgroundH;
118 120

  
119 121
///////////////////////////////////////////////////////////////////////////////////////////////////
120 122

  
......
122 124
    {
123 125
    mView = v;
124 126

  
125
    mGFFAQuad            = new MeshQuad();
126
    mStarQuad            = new MeshQuad();
127
    mCrawlQuad           = new MeshQuad();
128
    mCrawlBackgroundQuad = new MeshQuad();
129
    mLogoQuad            = new MeshQuad();
130

  
131
    mGFFAQuad.setStretch(GFFA_WIDTH,GFFA_HEIGHT,0);
132
    mCrawlQuad.setStretch(CRAWL_WIDTH,CRAWL_HEIGHT,0);
127
    mQuad = new MeshQuad();
133 128

  
134 129
    mGFFAEffects            = new DistortedEffects();
135 130
    mLogoEffects            = new DistortedEffects();
......
214 209
    if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion();
215 210
    mCrawlBackgroundTexture = new DistortedTexture();
216 211

  
217
    mCrawlBackgroundQuad.setStretch(scrW,(int)(scrH*Math.sin(angleA)/Math.sin(angleB)),0);
212
    mCrawlBackgroundW = scrW;
213
    mCrawlBackgroundH = (int)(scrH*Math.sin(angleA)/Math.sin(angleB));
218 214

  
219 215
    int randomA, randomX, randomY, randomTime;
220 216
    float randomS, randomAlpha1, randomAlpha2;
......
227 223
      {
228 224
      randomX = mRnd.nextInt(scrW) - scrW/2;
229 225
      randomY = mRnd.nextInt(scrH) - scrH/2;
230
      randomS = 0.2f+ 0.8f*mRnd.nextFloat();
226
      randomS = (0.2f+ 0.8f*mRnd.nextFloat())*20;
231 227
      randomA = (int)(180*mRnd.nextFloat());
232 228
      randomAlpha1 = 0.2f + 0.8f*mRnd.nextFloat();
233 229
      randomAlpha2 = 0.8f + 0.2f*mRnd.nextFloat();
......
244 240
      
245 241
      mStarEffects[i].apply( new FragmentEffectAlpha(di) );
246 242
      
247
      mScreen.attach(mStarTexture, mStarEffects[i], mStarQuad);
243
      mScreen.attach(mStarTexture, mStarEffects[i], mQuad);
248 244
      }
249
      
250
    float scale = (0.5f*scrW/mGFFAQuad.getStretchX());
251
    
245

  
252 246
    Dynamic1D di = new Dynamic1D(6000,0.5f);
253 247
    di.add(new Static1D(1.0f));
254 248
    di.add(new Static1D(1.0f));
......
258 252
    alpha.notifyWhenFinished(this);
259 253
    alphaEffectID = alpha.getID();
260 254

  
255
    Static3D scale = new Static3D(0.5f*scrW, 0.5f*scrW * GFFA_HEIGHT / GFFA_WIDTH, 1);
256

  
261 257
    mGFFAEffects.apply( new MatrixEffectScale(scale) );
262
    mGFFAEffects.apply( new MatrixEffectMove(new Static3D(-scrW/3 + mGFFAQuad.getStretchX()/2 ,scrH/6,0)) );
258
    mGFFAEffects.apply( new MatrixEffectMove(new Static3D(-scrW/3 + GFFA_WIDTH/2 ,scrH/6,0)) );
263 259
    mGFFAEffects.apply( alpha );
264 260
      
265
    mScreen.attach(mGFFATexture, mGFFAEffects, mGFFAQuad);
261
    mScreen.attach(mGFFATexture, mGFFAEffects, mQuad);
266 262
    }
267 263
    
268 264
///////////////////////////////////////////////////////////////////////////////////////////////////
......
312 308
    mGFFATexture.setTexture(bitmapGFFA);
313 309
      
314 310
    ///// create Logo ///////////////////
315
    mLogoQuad.setStretch(bitmapLogo.getWidth(),bitmapLogo.getHeight(),0);
316
    if( mLogoTexture==null ) mLogoTexture  = new DistortedTexture();
311
    if( mLogoTexture==null ) mLogoTexture = new DistortedTexture();
317 312
    mLogoTexture.setTexture(bitmapLogo);
313
    mLogoRatio = (float)bitmapLogo.getWidth()/bitmapLogo.getHeight();
318 314

  
319 315
    ///// create CRAWL //////////////////
320 316
    if( mCrawlTexture==null ) mCrawlTexture = new DistortedTexture();
......
331 327
    mCrawlTexture.setTexture(bitmapText);
332 328
      
333 329
    ///// create Stars ///////////////////
334
    mStarQuad.setStretch(bitmapStar.getWidth(),bitmapStar.getHeight(),0);
335 330
    if( mStarTexture==null ) mStarTexture = new DistortedTexture();
336 331
    mStarTexture.setTexture(bitmapStar);
337 332
    }
......
388 383
      mGFFATexture.markForDeletion();
389 384

  
390 385
      int screenW = mScreen.getWidth();
391
      float logoW = mLogoQuad.getStretchX();
392
      int initSize= (int)(3.0f*screenW/logoW);
393
      int finaSize= (int)(0.1f*screenW/logoW);
386
      int initSize= (int)(3.00f*screenW);
387
      int finaSize= (int)(0.01f*screenW);
394 388
      
395 389
      Dynamic3D di = new Dynamic3D(10000,0.5f);
396
      di.add(new Static3D(initSize,initSize,1));
397
      di.add(new Static3D(finaSize,finaSize,1));
390
      di.add(new Static3D(initSize,initSize/mLogoRatio,1));
391
      di.add(new Static3D(finaSize,finaSize/mLogoRatio,1));
398 392
      MatrixEffectScale scale = new MatrixEffectScale(di);
399 393
      scale.notifyWhenFinished(this);
400 394
      scaleEffectID = scale.getID();
401 395
      mLogoEffects.apply( scale );
402
      mScreen.attach(mLogoTexture, mLogoEffects, mLogoQuad);
396
      mScreen.attach(mLogoTexture, mLogoEffects, mQuad);
403 397
      }
404 398
    else if( effectID == scaleEffectID )
405 399
      {
406 400
      mScreen.detach(mLogoEffects);
407 401
      mLogoTexture.markForDeletion();
408
        
409
      float crawlW = mCrawlQuad.getStretchX();
410
      float crawlH = mCrawlQuad.getStretchY();
411
      float screenW= mScreen.getWidth();
412
      float screenH= mScreen.getHeight();
413
      float backW  = mCrawlBackgroundQuad.getStretchX();
414
      float backH  = mCrawlBackgroundQuad.getStretchY();
415
      float scale  = backW/crawlW;
416

  
417
      mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(0,-backH/2,0)) );
418
      mCrawlBackgroundEffects.apply( new MatrixEffectMove(new Static3D( 0, (backH-screenH)/2, 0)) );
419

  
420
      final int transpDist = 5;
421
      Static3D center = new Static3D( 0, (transpDist-0.5f)*backH , 0 );
422
      Static3D region = new Static3D( transpDist*backH , transpDist*backH , transpDist*backH );
402

  
403
      float scale = mCrawlBackgroundW/CRAWL_WIDTH;
404

  
405
      mCrawlBackgroundEffects.apply( new MatrixEffectScale( new Static3D(mCrawlBackgroundW, mCrawlBackgroundH, 1) ) );
406
      mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(0,-mCrawlBackgroundH/2,0)) );
407
      mCrawlBackgroundEffects.apply( new MatrixEffectMove(new Static3D( 0, (mCrawlBackgroundH-mHeight)/2, 0)) );
408

  
409
      final float transpDist = 5;
410
      Static3D center = new Static3D( 0, transpDist-0.5f, 0 );
411
      Static3D region = new Static3D( transpDist, transpDist, transpDist );
423 412
      mCrawlBackgroundEffects.apply( new FragmentEffectAlpha(new Static1D(1-transpDist*0.6f), center, region, true) );
424 413

  
425 414
      Dynamic3D di = new Dynamic3D(70000,0.5f);
426
      di.add(new Static3D(0, -(scale*crawlH+backH)/2, 0));
427
      di.add(new Static3D(0, +(scale*crawlH+backH)/2, 0));
415
      di.add(new Static3D(0, -(scale*CRAWL_HEIGHT+mCrawlBackgroundH)/2, 0));
416
      di.add(new Static3D(0, +(scale*CRAWL_HEIGHT+mCrawlBackgroundH)/2, 0));
428 417
      MatrixEffectMove move = new MatrixEffectMove(di);
429 418
      move.notifyWhenFinished(this);
430 419
      moveEffectID = move.getID();
431 420

  
432
      mCrawlEffects.apply( new MatrixEffectScale(new Static3D(scale,scale,scale)) );
421
      mCrawlEffects.apply( new MatrixEffectScale(new Static3D(scale*CRAWL_WIDTH,scale*CRAWL_HEIGHT,1)) );
433 422
      mCrawlEffects.apply( move );
434 423

  
435
      mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects, mCrawlBackgroundQuad);
436
      mBackground.attach(mCrawlTexture, mCrawlEffects, mCrawlQuad);
424
      mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects, mQuad);
425
      mBackground.resizeFBO(mCrawlBackgroundW,mCrawlBackgroundH);
426
      mBackground.attach(mCrawlTexture, mCrawlEffects, mQuad);
437 427
      mBackground.glDisable(GLES31.GL_DEPTH_TEST);
438 428
      mBackground.glDepthMask(false);
439 429
      }
src/main/java/org/distorted/examples/stencil/StencilRenderer.java
201 201
      mScale.set(scale,scale,scale);
202 202
      mFBOScale.set((float)width/bw, (float)height/bh, 1.0f );
203 203

  
204
      mFBONode.resize(width,height);
204
      mFBONode.resizeFBO(width,height);
205 205
      mScreen.resize( width,height);
206 206
      }
207 207

  

Also available in: Unified diff