Revision 8a99c681
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
---|---|---|
52 | 52 |
private MeshObject mMesh; |
53 | 53 |
private DistortedScreen mScreen; |
54 | 54 |
private DynamicQuat mQuatInt1, mQuatInt2; |
55 |
private int mObjWidth, mObjHeight; |
|
55 |
private int mObjWidth, mObjHeight, mObjDepth;
|
|
56 | 56 |
|
57 | 57 |
Static4D mQuat1, mQuat2; |
58 | 58 |
int mScreenMin; |
... | ... | |
71 | 71 |
|
72 | 72 |
mObjWidth = mTexture.getWidth(); |
73 | 73 |
mObjHeight= mTexture.getHeight(); |
74 |
mObjDepth = mTexture.getDepth(mMesh); |
|
74 | 75 |
|
75 | 76 |
mQuat1 = new Static4D(0,0,0,1); // unity |
76 | 77 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
... | ... | |
111 | 112 |
|
112 | 113 |
mEffects.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) ); |
113 | 114 |
mEffects.scale(factor); |
114 |
Static3D center = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, 0.0f );
|
|
115 |
Static3D center = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, -(float)mObjDepth/2 );
|
|
115 | 116 |
|
116 | 117 |
mEffects.quaternion(mQuatInt1, center); |
117 | 118 |
mEffects.quaternion(mQuatInt2, center); |
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.graphics.Bitmap; |
23 | 23 |
import android.graphics.BitmapFactory; |
24 |
import android.opengl.GLES30; |
|
25 | 24 |
import android.opengl.GLSurfaceView; |
26 | 25 |
|
27 | 26 |
import org.distorted.examples.R; |
... | ... | |
202 | 201 |
mFactorReg = 2*mFactorObj*act.getRegionR()/regionSize; |
203 | 202 |
mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg); |
204 | 203 |
|
205 |
Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
|
|
204 |
Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, -(float)mObjDepth/2 );
|
|
206 | 205 |
|
207 | 206 |
mObjectEffects.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) ); |
208 | 207 |
mObjectEffects.scale(mFactorObj); |
... | ... | |
215 | 214 |
mCenterEffects.quaternion(mQuatInt2, rotateCen); |
216 | 215 |
|
217 | 216 |
mCenterEffects.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 , |
218 |
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+10) );
|
|
217 |
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 10) ); |
|
219 | 218 |
mCenterEffects.move(mCenterInter); |
220 | 219 |
mCenterEffects.scale(factorCen); |
221 | 220 |
|
... | ... | |
223 | 222 |
mRegionEffects.quaternion(mQuatInt2, rotateCen); |
224 | 223 |
|
225 | 224 |
mRegionEffects.move( new Static3D( (width -mFactorObj*mObjWidth )/2 , |
226 |
(height-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+12) );
|
|
225 |
(height-mFactorObj*mObjHeight)/2 , 12) ); |
|
227 | 226 |
mRegionEffects.move(mCenterInter); |
228 | 227 |
mRegionEffects.move(mRegionInter); |
229 | 228 |
mRegionEffects.scale(mRegionScaleInter); |
src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java | ||
---|---|---|
198 | 198 |
mScreenMin = width<height ? width:height; |
199 | 199 |
|
200 | 200 |
float factor = 0.15f*mScreenMin/OBJ_SIZE; |
201 |
Static3D center = new Static3D( (float)OBJ_SIZE/2, (float)OBJ_SIZE/2, 0.0f );
|
|
201 |
Static3D center = new Static3D( (float)OBJ_SIZE/2, (float)OBJ_SIZE/2, -(float)OBJ_SIZE/2 );
|
|
202 | 202 |
Static3D moveVec= new Static3D( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0); |
203 | 203 |
|
204 | 204 |
for(int i=0; i<NUM_OBJECTS; i++) |
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.DistortedEffects; |
32 | 32 |
import org.distorted.library.DistortedScreen; |
33 | 33 |
import org.distorted.library.EffectTypes; |
34 |
import org.distorted.library.MeshObject; |
|
34 | 35 |
import org.distorted.library.type.Dynamic; |
35 | 36 |
import org.distorted.library.type.DynamicQuat; |
36 | 37 |
import org.distorted.library.MeshCubes; |
... | ... | |
41 | 42 |
|
42 | 43 |
import android.graphics.Bitmap; |
43 | 44 |
import android.graphics.BitmapFactory; |
44 |
import android.opengl.GLES30; |
|
45 | 45 |
import android.opengl.GLSurfaceView; |
46 | 46 |
|
47 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
53 | 53 |
private GLSurfaceView mView; |
54 | 54 |
private DistortedTexture mTexture; |
55 | 55 |
private DistortedEffects mEffects; |
56 |
private MeshObject mMesh; |
|
56 | 57 |
private DistortedScreen mScreen; |
57 | 58 |
private DynamicQuat mRot; |
58 | 59 |
|
... | ... | |
63 | 64 |
mView = v; |
64 | 65 |
mTexture = new DistortedTexture(1,1); |
65 | 66 |
mEffects = new DistortedEffects(); |
67 |
mMesh = new MeshCubes(1,1,false); |
|
66 | 68 |
mRot = new DynamicQuat(); |
67 | 69 |
|
68 | 70 |
Random rnd = new Random(System.currentTimeMillis()); |
... | ... | |
85 | 87 |
mRot.setMode(Dynamic.MODE_LOOP); |
86 | 88 |
|
87 | 89 |
mScreen = new DistortedScreen(); |
88 |
mScreen.attach(mTexture,mEffects,new MeshCubes(1,1,false));
|
|
90 |
mScreen.attach(mTexture,mEffects,mMesh);
|
|
89 | 91 |
} |
90 | 92 |
|
91 | 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
99 | 101 |
|
100 | 102 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
101 | 103 |
{ |
102 |
float scaleFactor = width>height ? height/3:width/3; |
|
104 |
float w = mTexture.getWidth(); |
|
105 |
float h = mTexture.getHeight(); |
|
106 |
float d = mTexture.getDepth(mMesh); |
|
107 |
|
|
108 |
float scaleFactor = 0.5f*(width>height ? height/h:width/w); |
|
109 |
Static3D center = new Static3D(w/2,h/2,-d/2); |
|
103 | 110 |
|
104 | 111 |
mEffects.abortEffects(EffectTypes.MATRIX); |
105 |
mEffects.move( new Static3D( (width-scaleFactor)/2 , (height-scaleFactor)/2 , 0) );
|
|
112 |
mEffects.move( new Static3D( (width-scaleFactor*w)/2 , (height-scaleFactor*h)/2 , 0) );
|
|
106 | 113 |
mEffects.scale(scaleFactor); |
107 |
mEffects.quaternion( mRot, new Static3D( (float)mTexture.getWidth()/2, (float)mTexture.getHeight()/2 , 0) );
|
|
114 |
mEffects.quaternion( mRot,center );
|
|
108 | 115 |
|
109 | 116 |
mScreen.resize(width, height); |
110 | 117 |
} |
Also available in: Unified diff
Make a MeshCubes object rendered with no effects have its front wall at the screen's surface (so that when we just replace MeshFlat with MeshCubes, it looks more similar)