Project

General

Profile

« Previous | Next » 

Revision b62eb334

Added by Leszek Koltunski about 5 years ago

Many things.

1) make the Dynamic.setDuration() able to be called AFTER the Dynamic has already been run. (and rename it to 'makeRunNowFor()' )
2) remove the automatic removal of zero Effects from EffectQueues.
3) adjust several Apps to cope with 2)
4) add post-rotation to Rubik (still not finished)

View differences:

src/main/java/org/distorted/examples/rubik/RubikRenderer.java
24 24
import org.distorted.library.effect.VertexEffectSink;
25 25
import org.distorted.library.main.Distorted;
26 26
import org.distorted.library.main.DistortedScreen;
27
import org.distorted.library.message.EffectListener;
28
import org.distorted.library.message.EffectMessage;
27 29
import org.distorted.library.type.Static3D;
28 30
import org.distorted.library.type.Static4D;
29 31

  
......
32 34

  
33 35
///////////////////////////////////////////////////////////////////////////////////////////////////
34 36

  
35
class RubikRenderer implements GLSurfaceView.Renderer
37
class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
36 38
{
37 39
    private static final int NUM_CUBES = 4;
38 40
    private static final float CUBE_SCREEN_RATIO = 0.5f;
39
    private static final float CAMERA_DISTANCE = 0.5f;     // 0.5 of the length of max(scrHeight,scrWidth)
41
    private static final float CAMERA_DISTANCE   = 0.5f;  // 0.5 of the length of max(scrHeight,scrWidth)
40 42

  
41 43
    private RubikSurfaceView mView;
42 44
    private DistortedScreen mScreen;
......
44 46
    private Static4D mQuatCurrent, mQuatAccumulated;
45 47
    private Static4D mTempCurrent, mTempAccumulated;
46 48
    private float mCubeSizeInScreenSpace;
47
    private boolean mFinishRotation, mFinishDragCurrent, mFinishDragAccumulated;
49
    private boolean mFinishRotation, mRemoveRotation, mFinishDragCurrent, mFinishDragAccumulated;
48 50
    private RubikCube mCube;
49 51

  
50 52
///////////////////////////////////////////////////////////////////////////////////////////////////
......
64 66
      mScale = new Static3D(1,1,1);
65 67

  
66 68
      mFinishRotation        = false;
69
      mRemoveRotation        = false;
67 70
      mFinishDragCurrent     = false;
68 71
      mFinishDragAccumulated = false;
69 72

  
......
71 74
      }
72 75

  
73 76
///////////////////////////////////////////////////////////////////////////////////////////////////
74
   
77
// various things are done here delayed, 'after the next render' as not to be done mid-render and
78
// cause artifacts.
79

  
75 80
    public void onDrawFrame(GL10 glUnused) 
76 81
      {
77 82
      mScreen.render( System.currentTimeMillis() );
......
91 96
      if( mFinishRotation )
92 97
        {
93 98
        mFinishRotation=false;
94
        mCube.finishRotationCalledOnNextRender();
99
        mCube.finishRotationCalledOnNextRender(this);
100
        }
101

  
102
      if( mRemoveRotation )
103
        {
104
        mRemoveRotation=false;
105
        mCube.removeRotationCalledOnNextRender(this);
95 106
        }
96 107
      }
97 108

  
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
// EffectListener. The library sends a message to us when it's time to call 'removeRotation'
111

  
112
   public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
113
     {
114
     switch(em)
115
        {
116
        case EFFECT_FINISHED: mRemoveRotation = true; break;
117
        }
118
     }
119

  
98 120
///////////////////////////////////////////////////////////////////////////////////////////////////
99 121
    
100 122
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
......
141 163
    private float computeFOV(float cameraDistance, int screenHeight)
142 164
      {
143 165
      double halfFOVInRadians = Math.atan( screenHeight/(2*cameraDistance) );
144
      float fovInDegrees = (float)(2*halfFOVInRadians*(180/Math.PI));
145

  
146
      return fovInDegrees;
166
      return (float)(2*halfFOVInRadians*(180/Math.PI));
147 167
      }
148 168

  
149 169
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff