Project

General

Profile

« Previous | Next » 

Revision c279ea6d

Added by Leszek Koltunski over 2 years ago

Progress with BandagedCreator.

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java
38 38
   private final GLSurfaceView mView;
39 39
   private final DistortedScreen mScreen;
40 40
   private final Static3D mScale;
41
   private final Static3D mMoveWhole;
41 42
   private final Static3D[] mMove;
43
   private final Static3D[] mMoveUnscaled;
44
   private final BandagedCubit[] mCubits;
45

  
46
   private final int COLOR_DEFAULT = 0xffffff55;
42 47

  
43 48
   private final float[][] POSITIONS = new float[][]
44 49
        {
......
80 85
     final float BRIGHTNESS = 0.333f;
81 86

  
82 87
     mQuat1 = new Static4D(0,0,0,1);
83
     mQuat2 = new Static4D(0,0,0,1);
88
     mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
84 89

  
85 90
     mView = v;
86 91

  
87 92
     mScreen = new DistortedScreen();
88 93
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
89 94
     mScale= new Static3D(1,1,1);
95
     mMoveWhole = new Static3D(0,0,0);
90 96

  
91 97
     int len = POSITIONS.length;
92
     mMove = new Static3D[len];
98
     mMove         = new Static3D[len];
99
     mMoveUnscaled = new Static3D[len];
93 100

  
94
     for(int i=0; i<len; i++) mMove[i] = new Static3D(0,0,0);
101
     for(int i=0; i<len; i++)
102
       {
103
       mMove[i] = new Static3D(0,0,0);
104
       mMoveUnscaled[i] = new Static3D(0,0,0);
105
       }
95 106

  
96
     BandagedCubit[] cubits = createCubits();
107
     mCubits = createCubits();
97 108
     }
98 109

  
99 110
///////////////////////////////////////////////////////////////////////////////////////////////////
......
105 116

  
106 117
     for(int c=0; c<len; c++)
107 118
       {
108
       computeMove(mMove[c],POSITIONS[c]);
109
       cubits[c] = new BandagedCubit(POSITIONS[c],mQuat1,mQuat2,mMove[c],mScale);
110
       DistortedNode node = cubits[c].getNode();
111
       mScreen.attach(node);
119
       computeMove(mMoveUnscaled[c],POSITIONS[c]);
120
       cubits[c] = new BandagedCubit(POSITIONS[c],mQuat1,mQuat2,mMove[c],mMoveWhole,mScale, COLOR_DEFAULT);
112 121
       }
113 122

  
114 123
     return cubits;
......
152 161
      final float Q = 0.15f;
153 162
      float scale = width<height ? Q*width : Q*height;
154 163

  
164
      mScreen.detachAll();
155 165
      int len = POSITIONS.length;
156 166

  
157 167
      for(int i=0; i<len; i++)
158 168
        {
159
        float x = mMove[i].get0();
160
        float y = mMove[i].get1();
161
        float z = mMove[i].get2();
169
        float x = mMoveUnscaled[i].get0();
170
        float y = mMoveUnscaled[i].get1();
171
        float z = mMoveUnscaled[i].get2();
162 172

  
163 173
        mMove[i].set(x*scale,y*scale,z*scale);
174

  
175
        mCubits[i].setTexture(COLOR_DEFAULT);
176
        DistortedNode node = mCubits[i].getNode();
177
        mScreen.attach(node);
164 178
        }
165 179

  
180
      float RB = BandagedCreatorActivity.RATIO_BAR;
181
      float RS = BandagedCreatorActivity.RATIO_SCROLL;
182
      float yOffset = (0.5f*RB/(1-RS))*height;
183
      mMoveWhole.set1(yOffset);
184

  
166 185
      mScale.set( scale,scale,scale );
167 186
      mScreenMin = Math.min(width, height);
168 187
      mScreen.resize(width,height);

Also available in: Unified diff