Project

General

Profile

« Previous | Next » 

Revision ba740a0c

Added by Leszek Koltunski about 4 years ago

Correct the Rubik app for the recent changes to the library's Node.

View differences:

src/main/java/org/distorted/effect/scramble/ScrambleEffectRotations.java
30 30

  
31 31
import java.util.Random;
32 32

  
33
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
33
import static org.distorted.magic.RubikRenderer.NODE_FBO_SIZE;
34 34

  
35 35
///////////////////////////////////////////////////////////////////////////////////////////////////
36 36

  
......
78 78

  
79 79
    mCubeEffects[0] = new MatrixEffectQuaternion(dq, new Static3D(0,0,0));
80 80

  
81
    float Z = NODE_MESH_SIZE /3;
81
    float Z = NODE_FBO_SIZE /3;
82 82

  
83 83
    Dynamic3D d0 = new Dynamic3D(duration, 0.5f);
84 84
    d0.setMode(Dynamic.MODE_PATH);
src/main/java/org/distorted/effect/sizechange/SizeChangeEffectRound.java
26 26
import org.distorted.library.type.Dynamic3D;
27 27
import org.distorted.library.type.Static3D;
28 28

  
29
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
29
import static org.distorted.magic.RubikRenderer.NODE_FBO_SIZE;
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
32 32

  
......
34 34
  {
35 35
  public int createEffectsPhase0(int duration)
36 36
    {
37
    float X = NODE_MESH_SIZE /3;
37
    float X = NODE_FBO_SIZE /3;
38 38

  
39 39
    mCubeEffectPosition[0] = new int[] {6,7};
40 40
    mCubeEffects[0]        = new Effect[mCubeEffectPosition[0].length];
......
58 58

  
59 59
  public int createEffectsPhase1(int duration)
60 60
    {
61
    float X = NODE_MESH_SIZE /3;
61
    float X = NODE_FBO_SIZE /3;
62 62

  
63 63
    mCubeEffectPosition[1] = new int[] {6,7};
64 64
    mCubeEffects[1]        = new Effect[mCubeEffectPosition[1].length];
src/main/java/org/distorted/effect/sizechange/SizeChangeEffectTransparency.java
45 45
    mNodeEffectPosition[0] = new int[] {-1};
46 46
    mNodeEffects[0]        = new Effect[mNodeEffectPosition[0].length];
47 47

  
48
    int w = mScreen.getWidth();
49
    int h = mScreen.getHeight();
50
    int min = w<h ? w:h;
51

  
52 48
    float init_amplitude = 0.0f;
53
    float end_amplitude  = min/15.0f;
54
    float length         = min/15.0f;
49
    float end_amplitude  = 1/15.0f;
50
    float length         = 1/15.0f;
55 51
    float init_phase     = 360.0f;
56 52
    float end_phase      = 0.0f;
57 53
    float alpha          = 30.0f;
......
81 77
    mNodeEffectPosition[1] = new int[] {-1};
82 78
    mNodeEffects[1]        = new Effect[mNodeEffectPosition[1].length];
83 79

  
84
    int w = mScreen.getWidth();
85
    int h = mScreen.getHeight();
86
    int min = w<h ? w:h;
87

  
88
    float init_amplitude = min/15.0f;
80
    float init_amplitude = 1/15.0f;
89 81
    float end_amplitude  = 0.0f;
90
    float length         = min/15.0f;
82
    float length         = 1/15.0f;
91 83
    float init_phase     = 0.0f;
92 84
    float end_phase      = 360.0f;
93 85
    float alpha          = 30.0f;
src/main/java/org/distorted/effect/win/WinEffectGlow.java
28 28
import org.distorted.library.type.Static3D;
29 29
import org.distorted.library.type.Static4D;
30 30

  
31
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
32

  
33 31
///////////////////////////////////////////////////////////////////////////////////////////////////
34 32

  
35 33
public class WinEffectGlow extends WinEffect
......
60 58

  
61 59
    Dynamic1D degreeDyn= new Dynamic1D(duration,1.0f);
62 60
    degreeDyn.add(new Static1D(1.0f));
63
    degreeDyn.add(new Static1D(2.5f));
61
    degreeDyn.add(new Static1D(1.2f));
64 62
    degreeDyn.add(new Static1D(1.0f));
65 63

  
66
    Static3D center = new Static3D(0,0,NODE_MESH_SIZE *0.5f);
67
    mNodeEffects[1] = new VertexEffectSink(degreeDyn,center);
64
    mNodeEffects[1] = new VertexEffectSink(degreeDyn,new Static3D(0,0,0));
68 65
    }
69 66

  
70 67
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/magic/RubikRenderer.java
40 40
public class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
41 41
{
42 42
    static final float CAMERA_DISTANCE = 0.6f;  // 0.6 of the length of min(scrHeight,scrWidth)
43
    public static final int NODE_MESH_SIZE = 600;
43
    public static final int NODE_FBO_SIZE = 600;
44 44

  
45 45
    private RubikSurfaceView mView;
46 46
    private DistortedScreen mScreen;
src/main/java/org/distorted/object/RubikObject.java
36 36
import org.distorted.library.type.Static3D;
37 37
import org.distorted.library.type.Static4D;
38 38

  
39
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
39
import static org.distorted.magic.RubikRenderer.NODE_FBO_SIZE;
40 40

  
41 41
///////////////////////////////////////////////////////////////////////////////////////////////////
42 42

  
......
69 69
    {
70 70
    super(texture,effects,mesh);
71 71

  
72
    resizeFBO(NODE_MESH_SIZE,NODE_MESH_SIZE);
72
    resizeFBO(NODE_FBO_SIZE, NODE_FBO_SIZE);
73 73

  
74 74
    LEGAL_QUATS = getLegalQuats();
75 75
    NUM_CUBITS  = getNumCubits(size);
......
94 94
    mQuatAEffect = new MatrixEffectQuaternion(quatAcc, center);
95 95

  
96 96
    MatrixEffectScale nodeScaleEffect = new MatrixEffectScale(mNodeScale);
97

  
98 97
    effects.apply(nodeScaleEffect);
99 98

  
100 99
    mCubits = new Cubit[NUM_CUBITS];
......
165 164

  
166 165
  public void recomputeScaleFactor(int scrWidth, int scrHeight)
167 166
    {
168
    float mx = getMesh().getStretchX();
169
    float my = getMesh().getStretchY();
170
    float factor = (my/mx > (float)scrHeight/scrWidth) ? (float)scrHeight/my : (float)scrWidth/mx;
171
    float scaleFactor = (OBJECT_SCREEN_RATIO*mx/mSize);
167
    float factor = scrWidth>scrHeight ? scrHeight : scrWidth;
168
    float scaleFactor = OBJECT_SCREEN_RATIO*NODE_FBO_SIZE/mSize;
172 169

  
173 170
    mNodeScale.set(factor,factor,factor);
174 171
    mScale.set(scaleFactor,scaleFactor,scaleFactor);
src/main/java/org/distorted/object/RubikObjectList.java
25 25
import org.distorted.library.type.Static4D;
26 26
import org.distorted.magic.R;
27 27

  
28
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
29

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

  
32 30
public enum RubikObjectList
......
88 86
    DistortedEffects effects = new DistortedEffects();
89 87
    MeshRectangles mesh      = new MeshRectangles(20,20);   // mesh of the node, not of the cubits
90 88

  
91
    mesh.setStretch(NODE_MESH_SIZE,NODE_MESH_SIZE,0);
92

  
93 89
    return new RubikCube(mObjectSize, quatCur, quatAcc, texture, mesh, effects);
94 90
    }
95 91

  

Also available in: Unified diff