Project

General

Profile

« Previous | Next » 

Revision be7c9190

Added by Leszek Koltunski over 2 years ago

Abstract out some methods from the Movement classes. only two remain now: rowFromOffset and enabledAxis.

View differences:

src/main/java/org/distorted/objects/MovementDiamond.java
19 19

  
20 20
package org.distorted.objects;
21 21

  
22
import org.distorted.library.type.Static3D;
23

  
24 22
///////////////////////////////////////////////////////////////////////////////////////////////////
25 23

  
26
class MovementDiamond extends Movement
24
class MovementDiamond extends Movement8
27 25
{
28
  static final float DIST3D = SQ6/6;
29
  static final float DIST2D = SQ3/6;
30

  
31
  static final Static3D[] FACE_AXIS = new Static3D[]
32
         {
33
           new Static3D(+SQ6/3,+SQ3/3,     0), new Static3D(-SQ6/3,-SQ3/3,     0),
34
           new Static3D(-SQ6/3,+SQ3/3,     0), new Static3D(+SQ6/3,-SQ3/3,     0),
35
           new Static3D(     0,+SQ3/3,+SQ6/3), new Static3D(     0,-SQ3/3,-SQ6/3),
36
           new Static3D(     0,+SQ3/3,-SQ6/3), new Static3D(     0,-SQ3/3,+SQ6/3)
37
         };
38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41 26
  MovementDiamond()
42 27
    {
43
    super(TwistyDiamond.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
28
    super(TwistyDiamond.ROT_AXIS);
44 29
    }
45 30

  
46 31
///////////////////////////////////////////////////////////////////////////////////////////////////
......
55 40
    return (int)(2*numLayers*off);
56 41
    }
57 42

  
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

  
60
  public float returnRotationFactor(int numLayers, int row)
61
    {
62
    return 1.0f;
63
    }
64

  
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

  
67
  boolean isInsideFace(int face, float[] p)
68
    {
69
    float y = (face%2 == 0 ? p[1] : -p[1]);
70
    float x = p[0];
71

  
72
    return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
73
    }
74

  
75 43
///////////////////////////////////////////////////////////////////////////////////////////////////
76 44

  
77 45
  void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)

Also available in: Unified diff