Project

General

Profile

« Previous | Next » 

Revision 37a25788

Added by Leszek Koltunski about 4 years ago

Progress with object Movement.

View differences:

src/main/java/org/distorted/object/RubikCubeMovement.java
25 25
{
26 26
  RubikCubeMovement()
27 27
    {
28
    super(3,2);
28
    super(RubikCube.AXIS,2,0.5f);
29 29
    }
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
......
35 35
    return (y>x) ? (y>=-x) : (y< -x);
36 36
    }
37 37

  
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

  
40
  boolean faceIsVisible(int axis, int lr)
41
    {
42
    return (2*lr-1)*mCamera[axis] > 0.5f;
43
    }
44

  
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
// given precomputed mCamera and mPoint, respectively camera and touch point positions in ScreenSpace,
47
// cast this touch point onto the surface defined by the 'face' and write the cast coords to 'output'.
48
// Center of the 'face' = (0,0), third coord always +- cubeHalfSize.
49

  
50
  void castTouchPointOntoFace(int axis, int lr, float[] output)
51
    {
52
    float diff = mPoint[axis]-mCamera[axis];
53
    float ratio= diff!=0.0f ? ((lr-0.5f)-mCamera[axis])/diff : 0.0f;
54

  
55
    output[0] = (mPoint[0]-mCamera[0])*ratio + mCamera[0];
56
    output[1] = (mPoint[1]-mCamera[1])*ratio + mCamera[1];
57
    output[2] = (mPoint[2]-mCamera[2])*ratio + mCamera[2];
58
    }
59

  
60 38
///////////////////////////////////////////////////////////////////////////////////////////////////
61 39

  
62 40
  void fillPossibleRotations(int axis, int[] output)

Also available in: Unified diff