Project

General

Profile

« Previous | Next » 

Revision 40eef4b9

Added by Leszek Koltunski over 7 years ago

Beginnings of split of DistortedObject into two separate classes: DistortedEffectQueues and DistortedTexture.

Still does not compile, but pushing already.

View differences:

src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
34 34
import org.distorted.library.type.Static1D;
35 35
import org.distorted.library.Distorted;
36 36
import org.distorted.library.GridFlat;
37
import org.distorted.library.DistortedObject;
37
import org.distorted.library.DistortedEffectQueues;
38
import org.distorted.library.DistortedTexture;
38 39

  
39 40
import android.graphics.Bitmap;
40 41
import android.graphics.BitmapFactory;
......
51 52
   
52 53
   private GLSurfaceView mView;
53 54
   private DistortedObjectTree mScreen;
54
   private DistortedObject mLeaf;
55
   private DistortedTexture mLeaf;
56

  
57
   private int mScreenW, mScreenH;
55 58

  
56 59
///////////////////////////////////////////////////////////////////////////////////////////////////
57 60

  
......
59 62
      {     
60 63
      mView = v;
61 64

  
62
      mLeaf = new DistortedObject(LEAF_SIZE,LEAF_SIZE,1);
65
      mLeaf = new DistortedTexture(LEAF_SIZE,LEAF_SIZE,1);
63 66
      GridFlat grid = new GridFlat(1,1);
67
      DistortedEffectQueues queue = new DistortedEffectQueues();
68

  
69
      mScreenW = 9*LEAF_SIZE;
70
      mScreenH = 9*LEAF_SIZE;
64 71

  
65
      mScreen = new DistortedObjectTree(new DistortedObject(9*LEAF_SIZE,9*LEAF_SIZE,1), grid);
72
      mScreen = new DistortedObjectTree(new DistortedTexture(mScreenW,mScreenH,0), queue, grid);
66 73
     
67 74
      Dynamic1D rot = new Dynamic1D(5000,0.0f);
68 75
      rot.setMode(Dynamic1D.MODE_JUMP);
......
72 79
      DistortedObjectTree[] mCircleNode = new DistortedObjectTree[NUM_CIRCLES];
73 80
    
74 81
      int[] colors    = new int[] {0,0,1,  0,0,0,  1,0,0,  1,1,0,  0,1,0}; // blue, black, red, yellow, green  
75
      int[] positions = new int[] {0*LEAF_SIZE,2*LEAF_SIZE,  3*LEAF_SIZE,2*LEAF_SIZE,  6*LEAF_SIZE,2*LEAF_SIZE,  3*LEAF_SIZE/2,9*LEAF_SIZE/2,  9*LEAF_SIZE/2,9*LEAF_SIZE/2};
82
      int[] positions = new int[] {0,2*LEAF_SIZE,  3*LEAF_SIZE,2*LEAF_SIZE,  6*LEAF_SIZE,2*LEAF_SIZE,  3*LEAF_SIZE/2,9*LEAF_SIZE/2,  9*LEAF_SIZE/2,9*LEAF_SIZE/2};
76 83
      
77
      DistortedObject tmp;
78 84
      Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0);
79 85
      Static3D axis   = new Static3D(0,0,1);
80 86
      Static3D moveVector = new Static3D(0,LEAF_SIZE,0);
......
83 89
        {
84 90
        if( i==0 )
85 91
          {
86
          mCircleNode[i] = new DistortedObjectTree(new DistortedObject(3*LEAF_SIZE,3*LEAF_SIZE,1), grid);
92
          queue = new DistortedEffectQueues();
93
          mCircleNode[i] = new DistortedObjectTree(new DistortedTexture(3*LEAF_SIZE,3*LEAF_SIZE,1), queue, grid);
87 94
        
88 95
          for(int j=0; j<NUM_LEAVES; j++)
89 96
            {
90
            tmp = new DistortedObject(mLeaf, Distorted.CLONE_BITMAP);
91
            mCircleNode[i].attach(tmp,grid);
92
            tmp.rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center );
93
            tmp.move(moveVector);
97
            queue = new DistortedEffectQueues();
98
            mCircleNode[i].attach(mLeaf, queue, grid);
99
            queue.rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center );
100
            queue.move(moveVector);
94 101
            }
95 102
          }
96 103
        else
......
99 106
          }
100 107
      
101 108
        mScreen.attach(mCircleNode[i]);
102
        tmp = mCircleNode[i].getObject();
103
        tmp.move( new Static3D(positions[2*i], positions[2*i+1], 0) );
104
        tmp.rotate( rot, axis, center );
105
        tmp.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) );
109
        queue = mCircleNode[i].getQueues();
110
        queue.move( new Static3D(positions[2*i], positions[2*i+1], 0) );
111
        queue.rotate( rot, axis, center );
112
        queue.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) );
106 113
        }
107 114
      }
108 115

  
......
118 125
    
119 126
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
120 127
      {
121
      DistortedObject bmp = mScreen.getObject();
122
      int bmpWidth  = bmp.getWidth();
123
      int bmpHeight = bmp.getHeight();
124
     
125
      bmp.abortEffects(EffectTypes.MATRIX);
128
      DistortedEffectQueues queues = mScreen.getQueues();
129

  
130
      queues.abortEffects(EffectTypes.MATRIX);
126 131
      
127
      if( (float)bmpHeight/bmpWidth > (float)height/width )
132
      if( (float)mScreenH/mScreenW > (float)height/width )
128 133
        {
129
        int w = (height*bmpWidth)/bmpHeight;
130
        float factor = (float)height/bmpHeight;
134
        int w = (height*mScreenW)/mScreenH;
135
        float factor = (float)height/mScreenH;
131 136

  
132
        bmp.move( new Static3D((width-w)/2 ,0, 0) );
133
        bmp.scale( factor );
137
        queues.move( new Static3D((width-w)/2 ,0, 0) );
138
        queues.scale( factor );
134 139
        }
135 140
      else
136 141
        {
137
        int h = (width*bmpHeight)/bmpWidth;
138
        float factor = (float)width/bmpWidth;
142
        int h = (width*mScreenH)/mScreenW;
143
        float factor = (float)width/mScreenW;
139 144

  
140
        bmp.move( new Static3D(0,(height-h)/2,0) );
141
        bmp.scale( factor );
145
        queues.move( new Static3D(0,(height-h)/2,0) );
146
        queues.scale( factor );
142 147
        }
143 148
      
144 149
      Distorted.onSurfaceChanged(width, height); 

Also available in: Unified diff