Revision e8b6aa95
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
33 | 33 |
import org.distorted.library.type.Static3D; |
34 | 34 |
import org.distorted.library.type.Static1D; |
35 | 35 |
import org.distorted.library.Distorted; |
36 |
import org.distorted.library.DistortedBitmap; |
|
36 |
import org.distorted.library.DistortedBitmapGrid; |
|
37 |
import org.distorted.library.DistortedObject; |
|
37 | 38 |
|
38 | 39 |
import android.graphics.Bitmap; |
39 | 40 |
import android.graphics.BitmapFactory; |
... | ... | |
50 | 51 |
|
51 | 52 |
private GLSurfaceView mView; |
52 | 53 |
private DistortedNode mScreen; |
53 |
private DistortedBitmap mLeaf;
|
|
54 |
private DistortedObject mLeaf;
|
|
54 | 55 |
|
55 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
56 | 57 |
|
57 | 58 |
OlimpicRenderer(GLSurfaceView v) |
58 | 59 |
{ |
59 | 60 |
mView = v; |
60 |
|
|
61 |
mLeaf = new DistortedBitmap(LEAF_SIZE,LEAF_SIZE,1); |
|
62 |
|
|
63 |
mScreen = new DistortedNode(new DistortedBitmap(9*LEAF_SIZE,9*LEAF_SIZE,1)); |
|
61 |
|
|
62 |
mLeaf = new DistortedObject(LEAF_SIZE,LEAF_SIZE,1); |
|
63 |
DistortedBitmapGrid grid = new DistortedBitmapGrid(1,1); |
|
64 |
|
|
65 |
mScreen = new DistortedNode(new DistortedObject(9*LEAF_SIZE,9*LEAF_SIZE,1), grid); |
|
64 | 66 |
|
65 | 67 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
66 | 68 |
rot.setMode(Dynamic1D.MODE_JUMP); |
... | ... | |
72 | 74 |
int[] colors = new int[] {0,0,1, 0,0,0, 1,0,0, 1,1,0, 0,1,0}; // blue, black, red, yellow, green |
73 | 75 |
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}; |
74 | 76 |
|
75 |
DistortedBitmap tmp;
|
|
77 |
DistortedObject tmp;
|
|
76 | 78 |
Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0); |
77 | 79 |
Static3D axis = new Static3D(0,0,1); |
78 | 80 |
Static3D moveVector = new Static3D(0,LEAF_SIZE,0); |
... | ... | |
81 | 83 |
{ |
82 | 84 |
if( i==0 ) |
83 | 85 |
{ |
84 |
mCircleNode[i] = new DistortedNode(new DistortedBitmap(3*LEAF_SIZE,3*LEAF_SIZE,1));
|
|
86 |
mCircleNode[i] = new DistortedNode(new DistortedObject(3*LEAF_SIZE,3*LEAF_SIZE,1), grid);
|
|
85 | 87 |
|
86 | 88 |
for(int j=0; j<NUM_LEAVES; j++) |
87 | 89 |
{ |
88 |
tmp = new DistortedBitmap(mLeaf, Distorted.CLONE_BITMAP);
|
|
89 |
mCircleNode[i].attach(tmp); |
|
90 |
tmp = new DistortedObject(mLeaf, Distorted.CLONE_BITMAP);
|
|
91 |
mCircleNode[i].attach(tmp,grid);
|
|
90 | 92 |
tmp.rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center ); |
91 | 93 |
tmp.move(moveVector); |
92 | 94 |
} |
... | ... | |
97 | 99 |
} |
98 | 100 |
|
99 | 101 |
mScreen.attach(mCircleNode[i]); |
100 |
tmp = (DistortedBitmap)mCircleNode[i].getObject();
|
|
102 |
tmp = mCircleNode[i].getObject(); |
|
101 | 103 |
tmp.move( new Static3D(positions[2*i], positions[2*i+1], 0) ); |
102 | 104 |
tmp.rotate( rot, axis, center ); |
103 | 105 |
tmp.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) ); |
... | ... | |
116 | 118 |
|
117 | 119 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
118 | 120 |
{ |
119 |
DistortedBitmap bmp = (DistortedBitmap)mScreen.getObject();
|
|
121 |
DistortedObject bmp = mScreen.getObject();
|
|
120 | 122 |
int bmpWidth = bmp.getWidth(); |
121 | 123 |
int bmpHeight = bmp.getHeight(); |
122 | 124 |
|
... | ... | |
164 | 166 |
catch(IOException e) { } |
165 | 167 |
} |
166 | 168 |
|
167 |
mLeaf.setBitmap(leaf);
|
|
169 |
mLeaf.setTexture(leaf);
|
|
168 | 170 |
|
169 | 171 |
try |
170 | 172 |
{ |
Also available in: Unified diff
Major change in API: separate the GRID from DistortedObject; completely remove classes derived from DistortedObject.