Project

General

Profile

« Previous | Next » 

Revision 84ddf691

Added by Leszek Koltunski about 4 years ago

Fixes for the Projection matrix, FOV.

There was a confusion between the Projection of the Node onto the Screen, and the Projection of the Cubits on the Node.

View differences:

src/main/java/org/distorted/magic/RubikSurfaceView.java
45 45
    // Every 1/12 the distance of min(scrWidth,scrHeight) the direction of cube rotation will reset.
46 46
    private final static int DIRECTION_SENSITIVITY=  12;
47 47

  
48
    private final Static4D CAMERA_POINT = new Static4D(0, 0, RubikRenderer.CAMERA_DISTANCE, 0);
48
    // Where did we get this sqrt(3)/2 ? From the (default, i.e. 60 degrees - see InternalOutputSurface!)
49
    // FOV of the projection matrix of the Node onto the Screen.
50
    // Take a look how the CAMERA_POINT is used in onTouchEvent - (x,y) there are expressed in sort of
51
    // 'half-NDC' coordinates i.e. they range from +0.5 to -0.5; thus CAMERA_POINT also needs to be
52
    // in 'half-NDC'. Since in this coordinate system the height of the screen is equal to 1, then the
53
    // Z-distance from the center of the object to the camera is equal to (scrHeight/2)/tan(FOV/2) =
54
    // 0.5/tan(30) = sqrt(3)/2.
55
    // Why is the Z-distance between the camera and the object equal to (scrHeight/2)/tan(FOV/2)?
56
    // Because of the way the View part of the ModelView matrix is constructed in EffectQueueMatrix.send().
57
    private final Static4D CAMERA_POINT = new Static4D(0, 0, (float)Math.sqrt(3)*0.5f, 0);
49 58

  
50 59
    private RubikRenderer mRenderer;
51 60
    private RubikObjectMovement mMovement;

Also available in: Unified diff