Revision 7589635e
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.EffectTypes; |
31 |
import org.distorted.library.type.Interpolator1D;
|
|
31 |
import org.distorted.library.type.Dynamic1D;
|
|
32 | 32 |
import org.distorted.library.DistortedNode; |
33 |
import org.distorted.library.type.Float3D;
|
|
34 |
import org.distorted.library.type.Float1D;
|
|
33 |
import org.distorted.library.type.Static3D;
|
|
34 |
import org.distorted.library.type.Static1D;
|
|
35 | 35 |
import org.distorted.library.Distorted; |
36 | 36 |
import org.distorted.library.DistortedBitmap; |
37 | 37 |
|
... | ... | |
52 | 52 |
private DistortedNode[] mCircleNode; |
53 | 53 |
private DistortedNode mScreen; |
54 | 54 |
private DistortedBitmap mLeaf; |
55 |
private Interpolator1D mRot;
|
|
55 |
private Dynamic1D mRot;
|
|
56 | 56 |
|
57 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
58 | 58 |
|
... | ... | |
64 | 64 |
|
65 | 65 |
mScreen = new DistortedNode(new DistortedBitmap(9*LEAF_SIZE,9*LEAF_SIZE,1)); |
66 | 66 |
|
67 |
mRot = new Interpolator1D();
|
|
68 |
mRot.setMode(Interpolator1D.MODE_JUMP);
|
|
67 |
mRot = new Dynamic1D();
|
|
68 |
mRot.setMode(Dynamic1D.MODE_JUMP);
|
|
69 | 69 |
mRot.setCount(0.0f); |
70 | 70 |
mRot.setDuration(5000); |
71 |
mRot.add(new Float1D( 0));
|
|
72 |
mRot.add(new Float1D(360));
|
|
71 |
mRot.add(new Static1D( 0));
|
|
72 |
mRot.add(new Static1D(360));
|
|
73 | 73 |
|
74 | 74 |
mCircleNode = new DistortedNode[NUM_CIRCLES]; |
75 | 75 |
|
... | ... | |
77 | 77 |
int[] positions = new int[] {0*LEAF_SIZE,2*LEAF_SIZE, 3*LEAF_SIZE,2*LEAF_SIZE, 6*LEAF_SIZE,2*LEAF_SIZE, 3*LEAF_SIZE/2,9*LEAF_SIZE/2, 9*LEAF_SIZE/2,9*LEAF_SIZE/2}; |
78 | 78 |
|
79 | 79 |
DistortedBitmap tmp; |
80 |
Float3D center = new Float3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0); |
|
81 |
|
|
80 |
Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0); |
|
81 |
Static3D axis = new Static3D(0,0,1); |
|
82 |
Static3D moveVector = new Static3D(0,LEAF_SIZE,0); |
|
83 |
|
|
82 | 84 |
for(int i=0; i<NUM_CIRCLES; i++) |
83 | 85 |
{ |
84 | 86 |
if( i==0 ) |
... | ... | |
89 | 91 |
{ |
90 | 92 |
tmp = new DistortedBitmap(mLeaf, Distorted.CLONE_BITMAP); |
91 | 93 |
mCircleNode[i].attach(tmp); |
92 |
tmp.rotate(center, j*(360/NUM_LEAVES));
|
|
93 |
tmp.move(0,LEAF_SIZE,0);
|
|
94 |
tmp.rotate(center, new Static1D(j*(360/NUM_LEAVES)), axis);
|
|
95 |
tmp.move(moveVector);
|
|
94 | 96 |
} |
95 | 97 |
} |
96 | 98 |
else |
... | ... | |
100 | 102 |
|
101 | 103 |
mScreen.attach(mCircleNode[i]); |
102 | 104 |
tmp = (DistortedBitmap)mCircleNode[i].getObject(); |
103 |
tmp.move(positions[2*i], positions[2*i+1], 0);
|
|
104 |
tmp.rotate( center, mRot, 0.0f, 0.0f, 1.0f);
|
|
105 |
tmp.chroma(0.8f, new Float3D(colors[3*i],colors[3*i+1], colors[3*i+2]));
|
|
105 |
tmp.move( new Static3D(positions[2*i], positions[2*i+1], 0) );
|
|
106 |
tmp.rotate( center, mRot, axis );
|
|
107 |
tmp.chroma(0.8f, new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]));
|
|
106 | 108 |
} |
107 | 109 |
} |
108 | 110 |
|
... | ... | |
129 | 131 |
if( bmpHeight/bmpWidth > height/width ) |
130 | 132 |
{ |
131 | 133 |
int w = (height*bmpWidth)/bmpHeight; |
132 |
bmp.move((width-w)/2 ,0, 0); |
|
133 |
bmp.scale((float)height/bmpHeight); |
|
134 |
float factor = (float)height/bmpHeight; |
|
135 |
|
|
136 |
bmp.move( new Static3D((width-w)/2 ,0, 0) ); |
|
137 |
bmp.scale( new Static3D(factor,factor,factor) ); |
|
134 | 138 |
} |
135 | 139 |
else |
136 | 140 |
{ |
137 | 141 |
int h = (width*bmpHeight)/bmpWidth; |
138 |
bmp.move(0 ,(height-h)/2, 0); |
|
139 |
bmp.scale((float)width/bmpWidth); |
|
142 |
float factor = (float)width/bmpWidth; |
|
143 |
|
|
144 |
bmp.move( new Static3D(0,(height-h)/2,0) ); |
|
145 |
bmp.scale( new Static3D(factor,factor,factor) ); |
|
140 | 146 |
} |
141 | 147 |
|
142 | 148 |
Distorted.onSurfaceChanged(width, height); |
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.