Project

General

Profile

« Previous | Next » 

Revision 9a7e8b98

Added by Leszek Koltunski about 1 year ago

new SPLIT type: type EDGE_COIN (will be used in Coin Tetrahedron).
Only supported in Tetrahedrons for now.

View differences:

src/main/java/org/distorted/objectlib/touchcontrol/TouchControl.java
16 16
public abstract class TouchControl
17 17
  {
18 18
  // it doesn't matter where we touch a face - the list of enabled rotAxis will always be the same
19
  public static final int TYPE_NOT_SPLIT    = 0;
19
  public static final int TYPE_NOT_SPLIT      = 0;
20 20
  // each face is split into several parts by lines coming from its center to the midpoints of each edge
21
  public static final int TYPE_SPLIT_EDGE   = 1;
21
  public static final int TYPE_SPLIT_EDGE     = 1;
22 22
  // each face is split into several parts by lines coming from its center to the vertices
23
  public static final int TYPE_SPLIT_CORNER = 2;
23
  public static final int TYPE_SPLIT_CORNER   = 2;
24
  // each face is split into several parts by lines coming from its center to the midpoints of each edge,
25
  // and also it has an inscribed circle [ see coin tetrahedron!)
26
  public static final int TYPE_SPLIT_EDGE_COIN= 3;
24 27

  
25 28
  public static final int TC_HEXAHEDRON        =   6;
26 29
  public static final int TC_TETRAHEDRON       =   4;
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlDodecahedron.java
110 110
    {
111 111
    switch(type)
112 112
      {
113
      case TYPE_SPLIT_EDGE  : return partEdge(point,face);
114
      case TYPE_SPLIT_CORNER: return partCorner(point,face);
115
      default               : return 0;
113
      case TYPE_NOT_SPLIT      : return 0;
114
      case TYPE_SPLIT_EDGE     : return partEdge(point,face);
115
      case TYPE_SPLIT_CORNER   : // not supported
116
      case TYPE_SPLIT_EDGE_COIN: // not supported
116 117
      }
118

  
119
    return 0;
117 120
    }
118 121

  
119 122
///////////////////////////////////////////////////////////////////////////////////////////////////
......
155 158
      }
156 159
    }
157 160

  
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159
// TODO - no such object yet
160

  
161
  int partCorner(float[] point, int face)
162
    {
163
    return 0;
164
    }
165

  
166 161
///////////////////////////////////////////////////////////////////////////////////////////////////
167 162

  
168 163
  boolean isInsideFace(int face, float[] p)
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlHexahedron.java
47 47
    {
48 48
    switch(type)
49 49
      {
50
      case TYPE_NOT_SPLIT   : return 0;
51
      case TYPE_SPLIT_EDGE  : boolean e0 = touchPoint[0] > 0;
52
                              boolean e1 = touchPoint[1] > 0;
53
                              return e0 ? (e1 ? 0:1) : (e1 ? 3:2);
54
      case TYPE_SPLIT_CORNER: boolean c0 = touchPoint[1] >= touchPoint[0];
55
                              boolean c1 = touchPoint[1] >=-touchPoint[0];
56
                              return c0 ? (c1 ? 0:3) : (c1 ? 1:2);
50
      case TYPE_NOT_SPLIT     : return 0;
51
      case TYPE_SPLIT_EDGE    : boolean e0 = touchPoint[0] > 0;
52
                                boolean e1 = touchPoint[1] > 0;
53
                                return e0 ? (e1 ? 0:1) : (e1 ? 3:2);
54
      case TYPE_SPLIT_CORNER  : boolean c0 = touchPoint[1] >= touchPoint[0];
55
                                boolean c1 = touchPoint[1] >=-touchPoint[0];
56
                                return c0 ? (c1 ? 0:3) : (c1 ? 1:2);
57
      case TYPE_SPLIT_EDGE_COIN: // not supported
57 58
      }
58 59

  
59 60
    return 0;
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlIcosahedron.java
160 160
                              if(  e1 && e2 ) return 0;
161 161
                              if( !e1 && e0 ) return 1;
162 162
                              if( !e0 &&!e2 ) return 2;
163
                              return 0;
163 164

  
164 165
      case TYPE_SPLIT_CORNER: float y2 = (isFaceInverted(face) ? touchPoint[1] : -touchPoint[1]);
165 166
                              float x2 = touchPoint[0];
......
171 172
                              if(  c0 && c2 ) return 0;
172 173
                              if( !c1 &&!c2 ) return 1;
173 174
                              if( !c0 && c1 ) return 2;
175
                              return 0;
176

  
177
      case TYPE_SPLIT_EDGE_COIN: //  not supported
174 178
      }
175 179

  
176 180
    return 0;
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlOctahedron.java
24 24

  
25 25
  public static final Static3D[] FACE_AXIS = new Static3D[]
26 26
         {
27
           new Static3D(+SQ6/3,+SQ3/3,     0), new Static3D(-SQ6/3,-SQ3/3,     0),
28
           new Static3D(-SQ6/3,+SQ3/3,     0), new Static3D(+SQ6/3,-SQ3/3,     0),
29
           new Static3D(     0,+SQ3/3,+SQ6/3), new Static3D(     0,-SQ3/3,-SQ6/3),
30
           new Static3D(     0,+SQ3/3,-SQ6/3), new Static3D(     0,-SQ3/3,+SQ6/3)
27
           new Static3D( SQ6/3, SQ3/3,     0), new Static3D(-SQ6/3,-SQ3/3,     0),
28
           new Static3D(-SQ6/3, SQ3/3,     0), new Static3D( SQ6/3,-SQ3/3,     0),
29
           new Static3D(     0, SQ3/3, SQ6/3), new Static3D(     0,-SQ3/3,-SQ6/3),
30
           new Static3D(     0, SQ3/3,-SQ6/3), new Static3D(     0,-SQ3/3, SQ6/3)
31 31
         };
32 32

  
33 33
///////////////////////////////////////////////////////////////////////////////////////////////////
......
54 54
                              float x1 = touchPoint[0];
55 55

  
56 56
                              boolean e0 = x1>0;
57
                              boolean e1 = y1>(+SQ3/3)*x1;
57
                              boolean e1 = y1>( SQ3/3)*x1;
58 58
                              boolean e2 = y1>(-SQ3/3)*x1;
59 59

  
60 60
                              if(  e1 && e2 ) return 0;
61 61
                              if( !e1 && e0 ) return 1;
62 62
                              if( !e0 &&!e2 ) return 2;
63
                              return 0;
63 64

  
64 65
      case TYPE_SPLIT_CORNER: float y2 = (face%2 == 0 ? touchPoint[1] : -touchPoint[1]);
65 66
                              float x2 = touchPoint[0];
66 67

  
67 68
                              boolean c0 = x2>0;
68
                              boolean c1 = y2>(+SQ3/3)*x2;
69
                              boolean c1 = y2>( SQ3/3)*x2;
69 70
                              boolean c2 = y2>(-SQ3/3)*x2;
70 71

  
71 72
                              if(  c0 && c2 ) return 0;
72 73
                              if( !c1 &&!c2 ) return 1;
73 74
                              if( !c0 && c1 ) return 2;
75
                              return 0;
76

  
77
      case TYPE_SPLIT_EDGE_COIN: //  not supported
74 78
      }
75 79

  
76 80
    return 0;
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlTetrahedron.java
24 24

  
25 25
  public static final Static3D[] FACE_AXIS = new Static3D[]
26 26
         {
27
           new Static3D(     0,+SQ3/3,+SQ6/3),
28
           new Static3D(     0,+SQ3/3,-SQ6/3),
27
           new Static3D(     0, SQ3/3, SQ6/3),
28
           new Static3D(     0, SQ3/3,-SQ6/3),
29 29
           new Static3D(-SQ6/3,-SQ3/3,     0),
30
           new Static3D(+SQ6/3,-SQ3/3,     0),
30
           new Static3D( SQ6/3,-SQ3/3,     0),
31 31
         };
32 32

  
33 33
///////////////////////////////////////////////////////////////////////////////////////////////////
......
43 43
// 2 | 0      \ /
44 44
//  / \      2 | 1
45 45
// / 1 \       |
46
//
47
// COIN: pieces inside the coin just like in EDGE; outside +=3.
46 48

  
47 49
  int returnPart(int type, int face, float[] touchPoint)
48 50
    {
49 51
    switch(type)
50 52
      {
51
      case TYPE_NOT_SPLIT   : return 0;
53
      case TYPE_NOT_SPLIT      : return 0;
52 54

  
53
      case TYPE_SPLIT_EDGE  : float y1 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
54
                              float x1 = touchPoint[0];
55
      case TYPE_SPLIT_EDGE     : float y1 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
56
                                 float x1 = touchPoint[0];
55 57

  
56
                              boolean e0 = x1>0;
57
                              boolean e1 = y1>(+SQ3/3)*x1;
58
                              boolean e2 = y1>(-SQ3/3)*x1;
58
                                 boolean e0 = x1>0;
59
                                 boolean e1 = y1>( SQ3/3)*x1;
60
                                 boolean e2 = y1>(-SQ3/3)*x1;
59 61

  
60
                              if(  e1 && e2 ) return 0;
61
                              if( !e1 && e0 ) return 1;
62
                              if( !e0 &&!e2 ) return 2;
62
                                 if(  e1 && e2 ) return 0;
63
                                 if( !e1 && e0 ) return 1;
64
                                 if( !e0 &&!e2 ) return 2;
65
                                 return 0;
63 66

  
64
      case TYPE_SPLIT_CORNER: float y2 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
65
                              float x2 = touchPoint[0];
67
      case TYPE_SPLIT_CORNER:    float y2 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
68
                                 float x2 = touchPoint[0];
66 69

  
67
                              boolean c0 = x2>0;
68
                              boolean c1 = y2>(+SQ3/3)*x2;
69
                              boolean c2 = y2>(-SQ3/3)*x2;
70
                                 boolean c0 = x2>0;
71
                                 boolean c1 = y2>( SQ3/3)*x2;
72
                                 boolean c2 = y2>(-SQ3/3)*x2;
70 73

  
71
                              if(  c0 && c2 ) return 0;
72
                              if( !c1 &&!c2 ) return 1;
73
                              if( !c0 && c1 ) return 2;
74
                                 if(  c0 && c2 ) return 0;
75
                                 if( !c1 &&!c2 ) return 1;
76
                                 if( !c0 && c1 ) return 2;
77
                                 return 0;
78
      case TYPE_SPLIT_EDGE_COIN: float y3 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
79
                                 float x3 = touchPoint[0];
80

  
81
                                 boolean s0 = x3>0;
82
                                 boolean s1 = y3>( SQ3/3)*x3;
83
                                 boolean s2 = y3>(-SQ3/3)*x3;
84

  
85
                                 int add = (x3*x3+y3*y3<DIST2D*DIST2D ? 0:3 );
86

  
87
                                 if(  s1 && s2 ) return add;
88
                                 if( !s1 && s0 ) return add+1;
89
                                 if( !s0 &&!s2 ) return add+2;
90
                                 return 0;
74 91
      }
75 92

  
76 93
    return 0;

Also available in: Unified diff