Project

General

Profile

« Previous | Next » 

Revision 6074bff6

Added by Leszek Koltunski about 2 years ago

Starminx I: progress

View differences:

src/main/java/org/distorted/objectlib/main/ObjectType.java
163 163

  
164 164
  public static TwistyObject create(int ordinal, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream meshStream)
165 165
    {
166
    if( ordinal== STAR_3.ordinal() )
167
      {
168
      int[] numL = new int[] {3,3,3,3,3,3};
169
      return new TwistyStarminx( numL,meshState,iconMode,quat,move,scale,meshStream );
170
      }
171

  
166 172
    int[] numL= objects[ordinal].mNumLayers;
167 173
    Class<? extends TwistyObject> clazz = objects[ordinal].mClass;
168 174

  
src/main/java/org/distorted/objectlib/objects/TwistyStarminx.java
28 28
import java.io.InputStream;
29 29

  
30 30
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.C2;
31
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.COS54;
32
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.SIN54;
31 33

  
32 34
///////////////////////////////////////////////////////////////////////////////////////////////////
33 35

  
......
53 55
      if( mEdgeMap==null ) initializeEdgeMap();
54 56
      if( mCenterCoords==null ) initializeCenterCoords();
55 57

  
56
      mPosition = new float[NUM_EDGES][3];
58
      mPosition = new float[NUM_EDGES+NUM_CENTERS+3*NUM_CORNERS][3];
57 59

  
58 60
      for(int edge=0; edge<NUM_EDGES; edge++)
59 61
        {
......
64 66
        mPosition[edge][1] = (c1[1]+c2[1])/2;
65 67
        mPosition[edge][2] = (c1[2]+c2[2])/2;
66 68
        }
69

  
70
      for(int center=0; center<NUM_CENTERS; center++)
71
        {
72
        int index = center+NUM_EDGES;
73
        mPosition[index][0] = mCenterCoords[center][0];
74
        mPosition[index][1] = mCenterCoords[center][1];
75
        mPosition[index][2] = mCenterCoords[center][2];
76
        }
77

  
78
      for(int petal=0; petal<3*NUM_CORNERS; petal++)
79
        {
80
        int index  = petal+NUM_EDGES+NUM_CENTERS;
81
        int corner = petal/3;
82
        mPosition[index][0] = mCorners[corner][0];
83
        mPosition[index][1] = mCorners[corner][1];
84
        mPosition[index][2] = mCorners[corner][2];
85
        }
67 86
      }
68 87

  
69 88
    return mPosition;
......
73 92

  
74 93
  public Static4D getCubitQuats(int cubit, int[] numLayers)
75 94
    {
76
    if( mQuatIndex==null ) mQuatIndex = new int[] { //35,55,38,48,41,42,58,57, 0,46,29,59,
77

  
78
                                                    17,12,13,20, 0, 4,25, 5,24,16,
95
    if( mQuatIndex==null ) mQuatIndex = new int[] { 17,12,13,20, 0, 4,25, 5,24,16,
79 96
                                                     9,21, 1,34, 8,11,30,43,26,14,
80 97
                                                    15,45,33,28,10, 2,29, 6, 7, 3,
81 98

  
82
                                                     //0, 2,20,42,13,41,16,33, 8,51,
83
                                                     //1,25,12,27, 4, 3,21,28, 5, 6
99
                                                    35,55,38,48,41,42,58,57, 0,46,29,59,
100

  
101
                                                     0, 0, 0, 29,29,29, 59,59,59, 48,48,48,
102
                                                    18,18,18, 53,53,53, 22,22,22, 49,49,49,
103
                                                    11,11,11, 54,54,54, 10,10,10, 52,52,52,
104
                                                    17,17,17, 27,27,27, 19,19,19, 26,26,26,
105
                                                     9, 9, 9, 28,28,28, 23,23,23, 45,45,45
84 106
                                                     };
85 107
    return mObjectQuats[mQuatIndex[cubit]];
86 108
    }
......
99 121
    {
100 122
    if( variant==0 ) // edge
101 123
      {
102
      float X = 0.8f;
103
      float Z1= 0.4f;
104
      float Z2= 3*C2-1.5f;
124
      float A = 1.5f;
125
      float B = 3*C2;
126
      float C = 3*SIN54;
127
      float X = (A*C)/(A+C);
128
      float Z1= A*(B-C)/(A+C);
129
      float Z2= B-A;
105 130

  
106 131
      float[][] vertices =
107 132
         {
108
             { 0.0f, 1.5f, 0,0f },
109
             { 0.0f,-1.5f, 0,0f },
110
             {   -X, 0.0f,  -Z1 },
111
             {   +X, 0.0f,  -Z1 },
112
             {   -X, 0.0f,  -Z2 },
113
             {   +X, 0.0f,  -Z2 },
133
             { 0, A,  0 },
134
             { 0,-A,  0 },
135
             {-X, 0,-Z1 },
136
             {+X, 0,-Z1 },
137
             {-X, 0,-Z2 },
138
             {+X, 0,-Z2 },
114 139
         };
115 140
      int[][] indices =
116 141
         {
117 142
             {2,1,0},
118 143
             {3,0,1},
119

  
120 144
             {2,4,1},
121 145
             {2,0,4},
122 146
             {3,1,5},
......
127 151

  
128 152
      return new ObjectShape(vertices, indices);
129 153
      }
154
    if( variant==1 ) // center
155
      {
156
      final double ANGLE = 0.825f*Math.PI;
157
      final float cosA  = (float)Math.cos(ANGLE);
158
      final float sinA  = (float)Math.sin(ANGLE);
159

  
160
      float TAN54 = SIN54/COS54;
161
      float R  = 1.5f*(TAN54-(1/TAN54));
162
      float X1 = R*COS54;
163
      float Y1 = R*SIN54;
164
      float X2 = R*COS18;
165
      float Y2 = R*SIN18;
166
      float Z  = 1.6f*R;  // TODO: about
130 167

  
131
    return null;
168
      float[][] vertices =
169
        {
170
          {-X1,-Y1*sinA,-Y1*cosA},
171
          {-X2,+Y2*sinA,+Y2*cosA},
172
          { 0 ,+R*sinA ,+R*cosA },
173
          {+X2,+Y2*sinA,+Y2*cosA},
174
          {+X1,-Y1*sinA,-Y1*cosA},
175
          { 0 , Z*cosA ,-Z*sinA }
176
        };
177

  
178
      int[][] indices =
179
        {
180
          {0,1,2,3,4},
181
          {5,1,0},
182
          {5,2,1},
183
          {5,3,2},
184
          {5,4,3},
185
          {5,0,4}
186
        };
187

  
188
      return new ObjectShape(vertices, indices);
189
      }
190
    else
191
      {
192
      float A = 1.5f;
193
      float B = 3*C2;
194
      float K = 1/(4*SIN54*SIN54);
195
      float X = A*K;
196
      float Y = (B-A)*K;
197
      float Z = B*K;
198

  
199
      float[][] vertices =
200
         {
201
             { 0, 0,   0 },
202
             {-X, Y,  -Z },
203
             {+X, Y,  -Z },
204
             { 0, 0,-2*Z },
205
         };
206
      int[][] indices =
207
         {
208
             {2,1,0},
209
             {1,2,3},
210
             {2,0,3},
211
             {1,3,0}
212
         };
213

  
214
      return new ObjectShape(vertices, indices);
215
      }
132 216
    }
133 217

  
134 218
///////////////////////////////////////////////////////////////////////////////////////////////////
......
146 230
      int[] centerIndices = { 0,0,0,0,-1,-1 };
147 231
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
148 232
      }
149

  
150
    return null;
233
    else if( variant==1 )
234
      {
235
      float h1 = isInIconMode() ? 0.001f : 0.02f;
236
      float[][] bands     = { {h1,10,0.5f,0.2f,5,1,0}, {0.001f, 1,0.5f,0.2f,5,1,0} };
237
      int[] bandIndices   = { 0,1,1,1,1,1 };
238
      float[][] corners   = { { 0.015f, 0.20f } };
239
      int[] cornerIndices = { 0,0,0,0,0,-1 };
240
      float[][] centers   = { { 0.0f,0.0f,-1.0f } };
241
      int[] centerIndices = { 0,0,0,0,0,-1 };
242
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
243
      }
244
    else
245
      {
246
      float Z = 3*C2/(4*SIN54*SIN54);
247
      float h1 = isInIconMode() ? 0.001f : 0.02f;
248
      float[][] bands     = { {h1,6,0.5f,0.2f,5,1,0}, {0.001f, 1,0.5f,0.2f,5,1,0} };
249
      int[] bandIndices   = { 0,1,1,1 };
250
      float[][] corners   = { { 0.015f, 0.20f } };
251
      int[] cornerIndices = { 0,0,0,-1 };
252
      float[][] centers   = { { 0.0f,0.0f,-Z } };
253
      int[] centerIndices = { 0,0,0,-1 };
254
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
255
      }
151 256
    }
152 257

  
153 258
///////////////////////////////////////////////////////////////////////////////////////////////////
154 259

  
155 260
  public int getNumCubitVariants(int[] numLayers)
156 261
    {
157
    return 1;
262
    return 3;
158 263
    }
159 264

  
160 265
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff