Project

General

Profile

« Previous | Next » 

Revision 251e574e

Added by Leszek Koltunski about 8 years ago

Some fixes for the recent API change

View differences:

src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java
47 47
class QuaternionRenderer implements GLSurfaceView.Renderer 
48 48
  {
49 49
  private static final int NUM_QUATERNIONS = 5;
50
  private static final int SIZE = 100;
51
	
50

  
52 51
  private GLSurfaceView mView;
53 52
  private DistortedObject mCube;
54 53
  private DistortedCubesGrid mGrid;
......
60 59
  QuaternionRenderer(GLSurfaceView v)
61 60
    {
62 61
    mView = v;
63
    mGrid = new DistortedCubesGrid( 3, "000010000", false);
62
    mGrid = new DistortedCubesGrid(1,1,false);
64 63
    mCube = new DistortedObject(1,1,1);
65 64

  
66 65
    mRot = new DynamicQuat();
......
97 96
    
98 97
  public void onSurfaceChanged(GL10 glUnused, int width, int height) 
99 98
    {
100
    mCube.abortEffects(EffectTypes.MATRIX);
99
    float scaleFactor = width>height ? height/3:width/3;
101 100

  
102
    if( width > height )
103
      {
104
      mCube.move( new Static3D((width-height)/2,0,0) );
105
      mCube.scale(height/(3.0f*SIZE));
106
      }  
107
    else
108
      {
109
      mCube.move( new Static3D(0,(height-width)/2,0) );
110
      mCube.scale(width/(3.0f*SIZE));
111
      }
112
     
113
    mCube.quaternion( mRot, new Static3D(3*SIZE/2,3*SIZE/2,0) );
101
    mCube.abortEffects(EffectTypes.MATRIX);
102
    mCube.move( new Static3D( (width-scaleFactor)/2 , (height-scaleFactor)/2 , 0) );
103
    mCube.scale(scaleFactor);
104
    mCube.quaternion( mRot, new Static3D(0.5f,0.5f,0) );
114 105
       
115 106
    Distorted.onSurfaceChanged(width, height); 
116 107
    }

Also available in: Unified diff