Project

General

Profile

« Previous | Next » 

Revision 123d6172

Added by Leszek Koltunski over 4 years ago

Further simplifications for object movement.

View differences:

src/main/java/org/distorted/magic/RubikRenderer.java
38 38

  
39 39
public class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
40 40
{
41
    private static final float CAMERA_DISTANCE   = 0.6f;  // 0.6 of the length of max(scrHeight,scrWidth)
42
    public  static final int TEXTURE_SIZE = 600;
41
    public static final float CAMERA_DISTANCE   = 0.6f;  // 0.6 of the length of max(scrHeight,scrWidth)
42
    public static final int TEXTURE_SIZE = 600;
43 43

  
44 44
    private RubikSurfaceView mView;
45 45
    private DistortedScreen mScreen;
......
85 85
      mNextCubeSize = RubikSize.getSize(mView.getRedButton()).getCubeSize();
86 86
      }
87 87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

  
90
   private float computeFOV(float cameraDistance, int screenHeight)
91
     {
92
     double halfFOVInRadians = Math.atan( screenHeight/(2*cameraDistance) );
93
     return (float)(2*halfFOVInRadians*(180/Math.PI));
94
     }
95

  
96 88
///////////////////////////////////////////////////////////////////////////////////////////////////
97 89

  
98 90
   private void createCubeNow(int newSize)
......
297 289
      {
298 290
      if( mNewCube!=null ) mNewCube.createTexture();
299 291

  
300
      float cameraDistance = CAMERA_DISTANCE*(width>height ? width:height);
301
      float fovInDegrees   = computeFOV(cameraDistance,height);
302

  
303
      mView.setScreenSize(width,height);
304
      mView.setCameraDist(cameraDistance);
292
      double halfFOVInRadians = Math.atan( 1.0f/(2*CAMERA_DISTANCE) );
293
      float fovInDegrees = (float)(2*halfFOVInRadians*(180/Math.PI));
305 294

  
306 295
      mScreen.setProjection( fovInDegrees, 0.1f);
307 296
      mScreen.resize(width, height);
297
      mView.setScreenSize(width,height);
308 298

  
309 299
      if( mNewCube!=null )
310 300
        {
311
        mNewCube.recomputeScaleFactor(width, height);
301
        mNewCube.recomputeScaleFactor(width,height);
312 302
        }
313 303

  
314 304
      mScreenHeight = height;

Also available in: Unified diff