Project

General

Profile

« Previous | Next » 

Revision 14bd7976

Added by Leszek Koltunski almost 4 years ago

1) Cube: convert it to the latest library. Main difference: objects are rendered better, individual cubits have rounded corners.
2) Examples: some adjustments to MeshJoin & Predeform
3) Library: fix a bug in main_vertex_shader's 'degree' function, which didn't work proprely in case of a vertex which was exactly at the center (i.e. vector PS was zero)

View differences:

src/main/java/org/distorted/objects/RubikPyraminx.java
205 205

  
206 206
///////////////////////////////////////////////////////////////////////////////////////////////////
207 207

  
208
  VertexEffectSink getSink(int size)
209
    {
210
    Static3D center = new Static3D(0,0,0);
211
    Static4D region = new Static4D(0,0,0,0.6f);
212
    return new VertexEffectSink( new Static1D(1.3f), center, region );
213
    }
214

  
215
///////////////////////////////////////////////////////////////////////////////////////////////////
216

  
217
  private MeshBase createStaticMesh(int cubit, int vertices)
208
  private MeshBase createStaticMesh(int cubit)
218 209
    {
219 210
    final float SQ2 = (float)Math.sqrt(2);
220 211
    final float SQ3 = (float)Math.sqrt(3);
......
269 260
    Static3D center1= new Static3D(0,-SQ3*SQ2/12,-SQ3/6);
270 261
    Static3D center2= new Static3D(0,-SQ3*SQ2/12,+SQ3/3);
271 262

  
263
    Static3D center = new Static3D(0,0,0);
264
    Static4D region = new Static4D(0,0,0,0.6f);
265

  
272 266
    VertexEffectScale effect1 = new VertexEffectScale ( new Static3D(1,SQ3/2,1) );
273 267
    VertexEffectRotate  effect2 = new VertexEffectRotate( new Static1D(90), new Static3D(1,0,0), new Static3D(0,0,0) );
274 268
    VertexEffectMove effect3 = new VertexEffectMove  ( new Static3D(0,-SQ3*SQ2/12,SQ3/12) );
......
282 276
    VertexEffectDeform effect10= new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
283 277
    VertexEffectDeform effect11= new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
284 278

  
285
    effect1.setMeshAssociation(15);  // apply to all 4 meshes
286
    effect2.setMeshAssociation(15);  // apply to all 4 meshes
287
    effect3.setMeshAssociation(15);  // apply to all 4 meshes
279
    VertexEffectSink   effect12= new VertexEffectSink( new Static1D(1.3f), center, region );
280

  
288 281
    effect4.setMeshAssociation(14);  // apply to mesh[1], [2] and [3]
289 282
    effect5.setMeshAssociation( 2);  // apply only to mesh[1]
290 283
    effect6.setMeshAssociation( 4);  // apply only to mesh[2]
291 284
    effect7.setMeshAssociation( 8);  // apply only to mesh[3]
292
    effect8.setMeshAssociation(15);  // apply to all 4 meshes
293
    effect9.setMeshAssociation(15);  // apply to all 4 meshes
294
    effect10.setMeshAssociation(15); // apply to all 4 meshes
295
    effect11.setMeshAssociation(15); // apply to all 4 meshes
296 285

  
297 286
    result.apply(effect1);
298 287
    result.apply(effect2);
......
305 294
    result.apply(effect9);
306 295
    result.apply(effect10);
307 296
    result.apply(effect11);
297
    result.apply(effect12);
308 298

  
309 299
    if( mRotArray[cubit]>=0 )
310 300
      {
......
316 306

  
317 307
///////////////////////////////////////////////////////////////////////////////////////////////////
318 308

  
319
  MeshBase createCubitMesh(int cubit, int vertices)
309
  MeshBase createCubitMesh(int cubit)
320 310
    {
321 311
    int kind = mRotArray[cubit];
322 312

  
323 313
    if( kind>=0 )
324 314
      {
325
      if( mMeshRotated[kind]==null ) mMeshRotated[kind] = createStaticMesh(cubit,vertices);
315
      if( mMeshRotated[kind]==null ) mMeshRotated[kind] = createStaticMesh(cubit);
326 316
      return mMeshRotated[kind].copy(false);
327 317
      }
328 318
    else
329 319
      {
330
      if( mMesh==null ) mMesh = createStaticMesh(cubit,vertices);
320
      if( mMesh==null ) mMesh = createStaticMesh(cubit);
331 321
      return mMesh.copy(false);
332 322
      }
333 323
    }
......
354 344

  
355 345
    canvas.drawRect(left,top,left+side,top+side,paint);
356 346

  
357
    paint.setColor(0xff000000);
347
    paint.setColor(INTERIOR_COLOR);
358 348
    paint.setStyle(Paint.Style.STROKE);
359 349

  
360 350
    canvas.drawLine(           left, HEIGHT,  side       +left, HEIGHT, paint);

Also available in: Unified diff