Project

General

Profile

« Previous | Next » 

Revision 9cbe58b0

Added by Leszek Koltunski over 4 years ago

Library: make setEffectAssociation a deferred job (because we do copy the uniforms during join!)
SingleMesh App: almost finished.

View differences:

src/main/java/org/distorted/examples/deferredjob/DeferredJobRenderer.java
75 75
      sink.add( new Static1D(0.5f) );
76 76
      sink.add( new Static1D(2.0f) );
77 77

  
78
      mQuat1 = new Static4D(0,0,0,1);  // unity
79
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
78
      mQuat1 = new Static4D(0,0,0,1);
79
      mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
80 80

  
81 81
      DynamicQuat quatInt1 = new DynamicQuat(0,0.5f);
82 82
      DynamicQuat quatInt2 = new DynamicQuat(0,0.5f);
src/main/java/org/distorted/examples/singlemesh/SingleMeshActivity.java
79 79

  
80 80
      switch(id)
81 81
        {
82
        case R.id.singlemeshButton0 : sView.getRenderer().apply(0); break;
83
        case R.id.singlemeshButton1 : sView.getRenderer().apply(1); break;
82
        case R.id.singlemeshButtonLX : sView.getRenderer().apply( (1<<4) + (0<<2) + 0, 0 ); break;
83
        case R.id.singlemeshButtonRX : sView.getRenderer().apply( (2<<4) + (0<<2) + 0, 0 ); break;
84
        case R.id.singlemeshButtonLY : sView.getRenderer().apply( (0<<4) + (1<<2) + 0, 1 ); break;
85
        case R.id.singlemeshButtonRY : sView.getRenderer().apply( (0<<4) + (2<<2) + 0, 1 ); break;
86
        case R.id.singlemeshButtonLZ : sView.getRenderer().apply( (0<<4) + (0<<2) + 1, 2 ); break;
87
        case R.id.singlemeshButtonRZ : sView.getRenderer().apply( (0<<4) + (0<<2) + 2, 2 ); break;
84 88
        }
85 89
      }
86 90
}
src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java
54 54
{
55 55
    private static final float DIST = 0.5f;
56 56

  
57
    private static Static3D[] AXIS = new Static3D[]
58
         {
59
           new Static3D(1,0,0),
60
           new Static3D(0,1,0),
61
           new Static3D(0,0,1)
62
         };
63

  
57 64
    private static final int[] FACE_COLORS = new int[]
58 65
         {
59 66
           0xffffff00, 0xffffffff,   // (right-YELLOW) (left  -WHITE)
......
104 111
    private VertexEffectRotate mRotate;
105 112
    private Dynamic1D mAngleDyn;
106 113
    private Static1D mAngle;
114
    private Static3D mAxis;
107 115

  
108 116
    Static4D mQuat1, mQuat2;
109 117
    int mScreenMin;
......
121 129
      sink.add( new Static1D(0.5f) );
122 130
      sink.add( new Static1D(2.0f) );
123 131

  
124
      mQuat1 = new Static4D(0,0,0,1);  // unity
125
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
132
      mQuat1 = new Static4D(0,0,0,1);
133
      mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
126 134

  
127 135
      DynamicQuat quatInt1 = new DynamicQuat(0,0.5f);
128 136
      DynamicQuat quatInt2 = new DynamicQuat(0,0.5f);
......
131 139
      quatInt2.add(mQuat2);
132 140

  
133 141
      mAngle = new Static1D(0);
142
      mAxis  = new Static3D(1,0,0);
134 143

  
135 144
      mAngleDyn = new Dynamic1D(2000,0.5f);
136 145
      mAngleDyn.add(new Static1D(0));
137 146
      mAngleDyn.add( mAngle );
138 147

  
139
      mRotate = new VertexEffectRotate( mAngleDyn, new Static3D(1,0,0), new Static3D(0,0,0) );
148
      mRotate = new VertexEffectRotate( mAngleDyn, mAxis, new Static3D(0,0,0) );
140 149

  
141 150
      mEffects = new DistortedEffects();
142 151
      mEffects.apply( mRotate );
......
192 201

  
193 202
///////////////////////////////////////////////////////////////////////////////////////////////////
194 203

  
195
    void apply(int number)
204
    void apply(int andAssoc, int axisIndex)
196 205
      {
197
      mRotate.setMeshAssociation(0,number);
206
      mRotate.setMeshAssociation(andAssoc,-1);
207

  
198 208
      mAngle.set(360);
209

  
210
      mAxis.set0(AXIS[axisIndex].get0());
211
      mAxis.set1(AXIS[axisIndex].get1());
212
      mAxis.set2(AXIS[axisIndex].get2());
213

  
199 214
      mAngleDyn.resetToBeginning();
200 215
      }
201 216

  
......
348 363

  
349 364
      MeshBase result = new MeshJoined(cubits);
350 365

  
366
      result.setEffectAssociation( 0, (1<<4) + (1<<2) + 1, 0);
367
      result.setEffectAssociation( 1, (1<<4) + (1<<2) + 2, 0);
368
      result.setEffectAssociation( 2, (1<<4) + (2<<2) + 1, 0);
369
      result.setEffectAssociation( 3, (1<<4) + (2<<2) + 2, 0);
370
      result.setEffectAssociation( 4, (2<<4) + (1<<2) + 1, 0);
371
      result.setEffectAssociation( 5, (2<<4) + (1<<2) + 2, 0);
372
      result.setEffectAssociation( 6, (2<<4) + (2<<2) + 1, 0);
373
      result.setEffectAssociation( 7, (2<<4) + (2<<2) + 2, 0);
374

  
351 375
      return result;
352 376
      }
353 377
}
src/main/res/layout/singlemeshlayout.xml
18 18
        <Button
19 19
            android:layout_width="wrap_content"
20 20
            android:layout_height="match_parent"
21
            android:id="@+id/singlemeshButton0"
22
            android:text="@string/color_red"
21
            android:id="@+id/singlemeshButtonLX"
22
            android:text="LX"
23 23
            android:onClick="onClick"
24 24
            android:layout_weight="1"/>
25 25
        <Button
26 26
            android:layout_width="wrap_content"
27 27
            android:layout_height="match_parent"
28
            android:id="@+id/singlemeshButton1"
29
            android:text="@string/color_green"
28
            android:id="@+id/singlemeshButtonRX"
29
            android:text="RX"
30
            android:onClick="onClick"
31
            android:layout_weight="1"/>
32
        <Button
33
            android:layout_width="wrap_content"
34
            android:layout_height="match_parent"
35
            android:id="@+id/singlemeshButtonLY"
36
            android:text="LY"
37
            android:onClick="onClick"
38
            android:layout_weight="1"/>
39
        <Button
40
            android:layout_width="wrap_content"
41
            android:layout_height="match_parent"
42
            android:id="@+id/singlemeshButtonRY"
43
            android:text="RY"
44
            android:onClick="onClick"
45
            android:layout_weight="1"/>
46
        <Button
47
            android:layout_width="wrap_content"
48
            android:layout_height="match_parent"
49
            android:id="@+id/singlemeshButtonLZ"
50
            android:text="LZ"
51
            android:onClick="onClick"
52
            android:layout_weight="1"/>
53
        <Button
54
            android:layout_width="wrap_content"
55
            android:layout_height="match_parent"
56
            android:id="@+id/singlemeshButtonRZ"
57
            android:text="RZ"
30 58
            android:onClick="onClick"
31 59
            android:layout_weight="1"/>
32 60

  

Also available in: Unified diff