Project

General

Profile

« Previous | Next » 

Revision 6a224bdc

Added by Leszek Koltunski about 4 years ago

1) Progress with the Ivy
2) further refine defense against failing to restore preferences.

View differences:

src/main/java/org/distorted/objects/Cubit.java
187 187
      modifyCurrentPosition(mParent.QUATS[mQuatIndex]);
188 188
      return mQuatIndex;
189 189
      }
190
    else
191
      {
192
      int q = mQuatIndex;
193
      mQuatIndex = 0;
194
      return -q;
195
      }
190

  
191
    return -mQuatIndex;
196 192
    }
197 193

  
198 194
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/FactoryCubit.java
35 35

  
36 36
class FactoryCubit
37 37
  {
38
  static final float IVY_D = 0.02f;
39

  
38 40
  private static final float SQ2 = (float)Math.sqrt(2);
39 41
  private static final float SQ3 = (float)Math.sqrt(3);
40 42
  private static final float SQ6 = (float)Math.sqrt(6);
41 43

  
42
  private static final float IVY_D = 0.02f;
43
  private static final int   IVY_N = 8;
44

  
44
  private static final int IVY_N = 8;
45 45
  private static final Static1D RADIUS = new Static1D(1);
46

  
47 46
  private static FactoryCubit mThis;
48 47

  
49 48
///////////////////////////////////////////////////////////////////////////////////////////////////
......
505 504
    MeshBase[] meshes = new MeshBase[6];
506 505

  
507 506
    final float angle = (float)Math.PI/(2*IVY_N);
508
    final float CORR  = 1.0f - IVY_D*SQ2;
507
    final float CORR  = 1.0f - 2*IVY_D;
509 508
    final float DIST  = 0.4f;
510 509
    final float DIST2 = -0.5f*CORR;
511 510
    final float CORR2 = 0.5f;
......
554 553
    MeshBase[] meshes = new MeshBase[2];
555 554

  
556 555
    final float angle = (float)Math.PI/(2*IVY_N);
557
    final float CORR  = 1.0f - IVY_D*SQ2;
556
    final float CORR  = 0.25f - 0.5f*IVY_D;
558 557
    float[] vertices = new float[4*IVY_N];
559 558

  
560 559
    for(int i=0; i<IVY_N; i++)
......
568 567
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
569 568
      }
570 569

  
571
    float[] bands0 = computeBands(+0.05f,35,0.5f,0.5f,5);
572
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
570
    float[] bands0 = computeBands(+0.0125f,35,0.125f,0.5f,5);
571
    float[] bands1 = computeBands(-0.0250f,45,0.125f,0.0f,2);
573 572

  
574 573
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
575 574
    meshes[0].setEffectAssociation(0,1,0);
......
1008 1007
    return effect;
1009 1008
    }
1010 1009

  
1010
///////////////////////////////////////////////////////////////////////////////////////////////////
1011

  
1012
  VertexEffect[] createVertexEffectsIvyFace()
1013
    {
1014
    VertexEffect[] effect = new VertexEffect[1];
1015
    effect[0] = new VertexEffectScale(4.0f);
1016
    return effect;
1017
    }
1018

  
1011 1019
///////////////////////////////////////////////////////////////////////////////////////////////////
1012 1020
// OBJECTS
1013 1021
///////////////////////////////////////////////////////////////////////////////////////////////////
......
1269 1277
    for( VertexEffect effect : effects ) mesh.apply(effect);
1270 1278

  
1271 1279
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1272
    Static3D[] vertices1 = new Static3D[1];
1273
    vertices1[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1274

  
1275
    Static3D[] vertices2 = new Static3D[3];
1276
    float DIST = IVY_D-1.0f;
1277
    vertices2[0] = new Static3D( DIST,+0.0f,+0.0f);
1278
    vertices2[1] = new Static3D(+0.0f, DIST,+0.0f);
1279
    vertices2[2] = new Static3D(+0.0f,+0.0f, DIST);
1280

  
1281
    roundCorners(mesh,center,vertices1,0.04f,0.20f);
1282
  //  roundCorners(mesh,center,vertices2,0.02f,0.20f);
1280
    Static3D[] vertices = new Static3D[1];
1281
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1282
    roundCorners(mesh,center,vertices,0.04f,0.20f);
1283 1283

  
1284 1284
    mesh.mergeEffComponents();
1285 1285

  
......
1291 1291
  MeshBase createIvyFaceMesh()
1292 1292
    {
1293 1293
    MeshBase mesh = createFacesIvyFace();
1294

  
1295
    float DIST = SQ2*(0.5f-IVY_D);
1296
    Static3D center = new Static3D(0.0f,0.0f,-0.0f);
1297
    Static3D[] vertices = new Static3D[2];
1298
    vertices[0] = new Static3D(+DIST,-DIST,+0.0f);
1299
    vertices[1] = new Static3D(-DIST,+DIST,+0.0f);
1300

  
1301
    roundCorners(mesh,center,vertices,0.05f,0.30f);
1294
    VertexEffect[] effects = createVertexEffectsIvyFace();
1295
    for( VertexEffect effect : effects ) mesh.apply(effect);
1302 1296

  
1303 1297
    mesh.mergeEffComponents();
1304 1298
    mesh.addEmptyTexComponent();
src/main/java/org/distorted/objects/FactorySticker.java
24 24

  
25 25
import static org.distorted.objects.TwistyObject.TEXTURE_HEIGHT;
26 26
import static org.distorted.objects.TwistyObject.COLOR_BLACK;
27
import static org.distorted.objects.FactoryCubit.IVY_D;
27 28

  
28 29
///////////////////////////////////////////////////////////////////////////////////////////////////
29 30

  
......
161 162
///////////////////////////////////////////////////////////////////////////////////////////////////
162 163
// TODO
163 164

  
164
  void drawIvyCornerSticker(Canvas canvas, Paint paint, int left, int top, int color, float R)
165
  void drawIvyCornerSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke)
165 166
    {
166 167
    paint.setColor(color);
167 168
    paint.setStyle(Paint.Style.FILL);
168

  
169 169
    canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint);
170 170

  
171
    paint.setColor(COLOR_BLACK);
172
    paint.setStyle(Paint.Style.STROKE);
173
    paint.setStrokeWidth(stroke);
171 174
    }
172 175

  
173 176
///////////////////////////////////////////////////////////////////////////////////////////////////
174 177
// TODO
175 178

  
176
  void drawIvyCenterSticker(Canvas canvas, Paint paint, int left, int top, int color, float R)
179
  void drawIvyCenterSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke)
177 180
    {
178 181
    paint.setColor(color);
179 182
    paint.setStyle(Paint.Style.FILL);
180

  
181 183
    canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint);
184

  
185
    paint.setColor(COLOR_BLACK);
186
    paint.setStyle(Paint.Style.STROKE);
187
    paint.setStrokeWidth(stroke*TEXTURE_HEIGHT);
188

  
189
    float cx = 0.075f*TEXTURE_HEIGHT;
190
    float cy = 0.075f*TEXTURE_HEIGHT;
191

  
192
    float c2 = TEXTURE_HEIGHT*(1.0f-0.0f*IVY_D);
193
    float halfL = TEXTURE_HEIGHT*(0.7f - 0.5f*IVY_D);
194

  
195
android.util.Log.e("sitck", "left="+left+" top="+top);
196

  
197
    canvas.drawArc( left+cx-halfL, top+cy-halfL, left+cx+halfL, top+cy+halfL, 280, 80, false, paint);
198
   // canvas.drawArc( left+c2-halfL, top+c2-halfL, left+c2+halfL, top+c2+halfL,  90, 90, false, paint);
199

  
200

  
182 201
    }
183 202
  }
src/main/java/org/distorted/objects/TwistyIvy.java
234 234
    {
235 235
    int COLORS = FACE_COLORS.length;
236 236
    FactorySticker factory = FactorySticker.getInstance();
237
    float R = 0.05f;
237
    float R = 0.01f;
238 238

  
239 239
    if( face<COLORS )
240 240
      {
src/main/java/org/distorted/objects/TwistyObject.java
466 466
        {
467 467
        for(int j=0; j<NUM_CUBITS; j++)
468 468
          {
469
          CUBITS[j].mQuatIndex = 0;
469 470
          CUBITS[j].modifyCurrentPosition(QUATS[0]);
470 471
          mMesh.setEffectAssociation(j, CUBITS[j].computeAssociation(),0);
471 472
          }

Also available in: Unified diff