Project

General

Profile

« Previous | Next » 

Revision 55908771

Added by Leszek Koltunski over 4 years ago

Convert Rubik app to stretchless API.

View differences:

src/main/java/org/distorted/examples/rubik/RubikCube.java
50 50
    private static final int VECTZ = 2;
51 51

  
52 52
    private static final int ROTATION_MILLISEC = 1500;
53
    private static final int STRETCH_SIZE = 100;
54 53

  
55 54
    private static final Static3D VectX = new Static3D(1,0,0);
56 55
    private static final Static3D VectY = new Static3D(0,1,0);
......
85 84
      Static3D[][][] cubeVectors = new Static3D[mSize][mSize][mSize];
86 85

  
87 86
      Static3D center = new Static3D(0,0,0);
88
      Static4D region = new Static4D(0,0,0, STRETCH_SIZE*0.72f);
87
      Static4D region = new Static4D(0,0,0, 0.72f);
89 88

  
90 89
      VertexEffectSink        sinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), center, region );
91 90
      MatrixEffectScale      scaleEffect = new MatrixEffectScale(scale);
......
129 128
              tmpBottom= (y==       0 ? mapBottom:mapBlack);
130 129

  
131 130
              mCubes[x][y][z]           = new MeshCubes(vertices,vertices,vertices, tmpFront, tmpBack, tmpLeft, tmpRight, tmpTop, tmpBottom);
132
              mCubes[x][y][z].setStretch(STRETCH_SIZE,STRETCH_SIZE,STRETCH_SIZE);
133 131

  
134
              cubeVectors[x][y][z]      = new Static3D( STRETCH_SIZE*(x-nc), STRETCH_SIZE*(y-nc), STRETCH_SIZE*(z-nc) );
132
              cubeVectors[x][y][z]      = new Static3D( x-nc, y-nc, z-nc );
135 133
              mRotationAngle[x][y][z]   = new Dynamic1D();
136 134
              mRotationAxis[x][y][z]    = new Static3D(1,0,0);
137 135

  
......
306 304
     mTexture.setTexture(bitmap);
307 305
     }
308 306

  
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

  
311
   float getStretchSize()
312
     {
313
     return STRETCH_SIZE;
314
     }
315

  
316 307
///////////////////////////////////////////////////////////////////////////////////////////////////
317 308

  
318 309
   int getSize()
src/main/java/org/distorted/examples/rubik/RubikRenderer.java
153 153

  
154 154
   private void recomputeScaleFactor(int screenWidth, int screenHeight)
155 155
     {
156
     float cubeSizeInScreenSpace = CUBE_SCREEN_RATIO*(screenWidth>screenHeight ? screenHeight:screenWidth);
157
     float texSize = mCube.getStretchSize();
158
     float scaleFactor = cubeSizeInScreenSpace/(texSize*mCube.getSize());
159

  
156
     float scaleFactor = CUBE_SCREEN_RATIO * Math.min(screenWidth,screenHeight) / mCube.getSize();
160 157
     mScale.set(scaleFactor,scaleFactor,scaleFactor);
161 158
     }
162 159
}

Also available in: Unified diff