Revision 7589635e
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
---|---|---|
29 | 29 |
import org.distorted.examples.R; |
30 | 30 |
|
31 | 31 |
import org.distorted.library.EffectTypes; |
32 |
import org.distorted.library.type.Interpolator;
|
|
33 |
import org.distorted.library.type.InterpolatorQuat;
|
|
32 |
import org.distorted.library.type.Dynamic;
|
|
33 |
import org.distorted.library.type.DynamicQuat;
|
|
34 | 34 |
import org.distorted.library.DistortedCubes; |
35 |
import org.distorted.library.type.Float4D;
|
|
36 |
import org.distorted.library.type.Float3D;
|
|
35 |
import org.distorted.library.type.Static4D;
|
|
36 |
import org.distorted.library.type.Static3D;
|
|
37 | 37 |
import org.distorted.library.Distorted; |
38 | 38 |
|
39 | 39 |
import android.graphics.Bitmap; |
... | ... | |
51 | 51 |
private GLSurfaceView mView; |
52 | 52 |
private DistortedCubes mCube; |
53 | 53 |
private Random mRnd = new Random(System.currentTimeMillis()); |
54 |
private InterpolatorQuat mRot;
|
|
54 |
private DynamicQuat mRot;
|
|
55 | 55 |
|
56 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 57 |
|
... | ... | |
60 | 60 |
mView = v; |
61 | 61 |
mCube = new DistortedCubes( 3, "000010000", SIZE); |
62 | 62 |
|
63 |
mRot = new InterpolatorQuat();
|
|
63 |
mRot = new DynamicQuat();
|
|
64 | 64 |
|
65 | 65 |
float x,y,z,w, len; |
66 | 66 |
|
... | ... | |
73 | 73 |
|
74 | 74 |
len = (float)Math.sqrt( x*x+y*y+z*z+w*w ); |
75 | 75 |
|
76 |
mRot.add(new Float4D(x/len,y/len,z/len,w/len));
|
|
76 |
mRot.add(new Static4D(x/len,y/len,z/len,w/len));
|
|
77 | 77 |
} |
78 | 78 |
|
79 | 79 |
mRot.setCount(0); |
80 | 80 |
mRot.setDuration(8000); |
81 |
mRot.setMode(Interpolator.MODE_LOOP);
|
|
81 |
mRot.setMode(Dynamic.MODE_LOOP);
|
|
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
99 | 99 |
|
100 | 100 |
if( width > height ) |
101 | 101 |
{ |
102 |
mCube.move((width-height)/2 ,0, 0); |
|
103 |
mCube.scale(height/(3.0f*SIZE)); |
|
102 |
float factor = height/(3.0f*SIZE); |
|
103 |
mCube.move( new Static3D((width-height)/2,0,0) ); |
|
104 |
mCube.scale( new Static3D(factor,factor,factor) ); |
|
104 | 105 |
} |
105 | 106 |
else |
106 |
{ |
|
107 |
mCube.move(0 ,(height-width)/2, 0); |
|
108 |
mCube.scale(width/(3.0f*SIZE)); |
|
107 |
{ |
|
108 |
float factor = width/(3.0f*SIZE); |
|
109 |
mCube.move( new Static3D(0,(height-width)/2,0) ); |
|
110 |
mCube.scale( new Static3D(factor,factor,factor) ); |
|
109 | 111 |
} |
110 | 112 |
|
111 |
mCube.quaternion( new Float3D(3*SIZE/2,3*SIZE/2,0), mRot);
|
|
113 |
mCube.quaternion( new Static3D(3*SIZE/2,3*SIZE/2,0), mRot);
|
|
112 | 114 |
|
113 | 115 |
Distorted.onSurfaceChanged(width, height); |
114 | 116 |
} |
Also available in: Unified diff
Major push towards simplifying DistortedObject's public API.
All MATRIX effects are using the new API - the 'DataND' marker interfaces.