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/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);

Also available in: Unified diff