Revision 16b22aab
Added by Leszek Koltunski about 5 years ago
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import org.distorted.examples.R; |
30 | 30 |
|
31 |
import org.distorted.library.effect.MatrixEffectMove; |
|
32 | 31 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
33 | 32 |
import org.distorted.library.effect.MatrixEffectScale; |
34 | 33 |
import org.distorted.library.main.DistortedEffects; |
35 | 34 |
import org.distorted.library.main.DistortedScreen; |
36 | 35 |
import org.distorted.library.main.DistortedTexture; |
37 |
import org.distorted.library.mesh.MeshBase; |
|
38 | 36 |
import org.distorted.library.mesh.MeshCubes; |
39 | 37 |
import org.distorted.library.type.Dynamic; |
40 | 38 |
import org.distorted.library.type.DynamicQuat; |
... | ... | |
54 | 52 |
|
55 | 53 |
private GLSurfaceView mView; |
56 | 54 |
private DistortedTexture mTexture; |
57 |
private MeshBase mMesh; |
|
58 | 55 |
private DistortedScreen mScreen; |
59 |
private Static3D mMove, mScale, mCenter;
|
|
56 |
private Static3D mScale;
|
|
60 | 57 |
|
61 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
62 | 59 |
|
... | ... | |
64 | 61 |
{ |
65 | 62 |
mView = v; |
66 | 63 |
mTexture = new DistortedTexture(1,1); |
67 |
mMesh = new MeshCubes(1,1,1); |
|
68 | 64 |
|
69 | 65 |
DistortedEffects effects = new DistortedEffects(); |
70 | 66 |
DynamicQuat rot = new DynamicQuat(); |
... | ... | |
88 | 84 |
rot.setDuration(8000); |
89 | 85 |
rot.setMode(Dynamic.MODE_LOOP); |
90 | 86 |
|
91 |
mMove = new Static3D(0,0,0); |
|
92 | 87 |
mScale = new Static3D(1,1,1); |
93 |
mCenter = new Static3D(0,0,0); |
|
94 | 88 |
|
95 |
effects.apply( new MatrixEffectMove(mMove)); |
|
96 | 89 |
effects.apply(new MatrixEffectScale(mScale)); |
97 |
effects.apply( new MatrixEffectQuaternion(rot,mCenter) );
|
|
90 |
effects.apply( new MatrixEffectQuaternion(rot,new Static3D(0,0,0)) );
|
|
98 | 91 |
|
99 | 92 |
mScreen = new DistortedScreen(); |
100 |
mScreen.attach(mTexture,effects,mMesh);
|
|
93 |
mScreen.attach(mTexture,effects,new MeshCubes(1,1,1));
|
|
101 | 94 |
} |
102 | 95 |
|
103 | 96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
113 | 106 |
{ |
114 | 107 |
float w = mTexture.getWidth(); |
115 | 108 |
float h = mTexture.getHeight(); |
116 |
float d = mTexture.getDepth(mMesh); |
|
117 |
|
|
118 | 109 |
float factor = 0.5f*(width>height ? height/h:width/w); |
119 | 110 |
|
120 |
mCenter.set(w/2,h/2,d/2); |
|
121 |
mMove.set( (width-factor*w)/2 , (height-factor*h)/2 , -factor*d/2 ); |
|
122 | 111 |
mScale.set(factor,factor,factor); |
123 |
|
|
124 | 112 |
mScreen.resize(width, height); |
125 | 113 |
} |
126 | 114 |
|
Also available in: Unified diff
Fix several more apps for the 'center-of-matrix-effects-in-screen-center' change.