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/RubikObject.java
27 27
import org.distorted.library.effect.Effect;
28 28
import org.distorted.library.effect.MatrixEffectQuaternion;
29 29
import org.distorted.library.effect.MatrixEffectScale;
30
import org.distorted.library.effect.VertexEffectSink;
31 30
import org.distorted.library.main.DistortedEffects;
32 31
import org.distorted.library.main.DistortedNode;
33 32
import org.distorted.library.main.DistortedTexture;
......
42 41

  
43 42
public abstract class RubikObject extends DistortedNode
44 43
  {
44
  static final int INTERIOR_COLOR = 0xff000000;
45 45
  public static final int NODE_FBO_SIZE = 600;
46 46

  
47 47
  private static final int TEXTURE_HEIGHT = 128;
......
65 65
  Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal;
66 66
  DistortedTexture mTexture;
67 67

  
68
  VertexEffectSink mSinkEffect;
69 68
  MatrixEffectScale mScaleEffect;
70 69
  MatrixEffectQuaternion mQuatCEffect;
71 70
  MatrixEffectQuaternion mQuatAEffect;
......
91 90
    computeStartAndStep(mOrigPos);
92 91
    mNodeScale= new Static3D(1,1,1);
93 92
    mQuatAccumulated = quatAcc;
94
    mSinkEffect  = getSink(mSize);
95 93

  
96 94
    mRotationAngleStatic = new Static1D(0);
97 95
    mRotationAngleMiddle = new Static1D(0);
......
109 107
    mCubits = new Cubit[NUM_CUBITS];
110 108
    mTexture = new DistortedTexture();
111 109

  
112
    int vertices = (int)(24.0f/mSize + 2.0f);
113

  
114 110
    for(int i=0; i<NUM_CUBITS; i++)
115 111
      {
116
      MeshBase cubitMesh = createCubitMesh(i,vertices);
112
      MeshBase cubitMesh = createCubitMesh(i);
117 113
      mCubits[i] = new Cubit(this,cubitMesh,mOrigPos[i]);
118 114
      textureCubitMesh(cubitMesh,i);
119 115

  
......
300 296
    paint.setTextAlign(Paint.Align.CENTER);
301 297
    paint.setStyle(Paint.Style.FILL);
302 298

  
303
    paint.setColor(0xff000000);
299
    paint.setColor(INTERIOR_COLOR);
304 300
    canvas.drawRect(0, 0, (numColors+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, paint);
305 301

  
306 302
    for(int i=0; i<numColors; i++)
......
596 592
///////////////////////////////////////////////////////////////////////////////////////////////////
597 593

  
598 594
  abstract float getScreenRatio();
599
  abstract VertexEffectSink getSink(int size);
600 595
  abstract Static3D[] getCubitPositions(int size);
601 596
  abstract float[] getLegalQuats();
602 597
  abstract int getNumFaces();
603
  abstract MeshBase createCubitMesh(int cubit, int vertices);
598
  abstract MeshBase createCubitMesh(int cubit);
604 599
  abstract void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side);
605 600
  public abstract Static3D[] getRotationAxis();
606 601
  public abstract int getBasicAngle();

Also available in: Unified diff