Revision 2f20ae3a
Added by Leszek Koltunski about 8 years ago
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldActivity.java | ||
---|---|---|
36 | 36 |
{ |
37 | 37 |
super.onCreate(icicle); |
38 | 38 |
setContentView(R.layout.aroundtheworldlayout); |
39 |
|
|
40 |
AroundTheWorldSurfaceView view = (AroundTheWorldSurfaceView) this.findViewById(R.id.aroundTheWorldSurfaceView); |
|
41 |
AroundTheWorldSurfaceViewPicker pick = (AroundTheWorldSurfaceViewPicker) this.findViewById(R.id.aroundTheWorldSurfaceViewPicker); |
|
42 |
|
|
43 |
pick.setEffectsManager(view.getManager()); |
|
39 | 44 |
} |
40 | 45 |
|
41 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java | ||
---|---|---|
32 | 32 |
class AroundTheWorldEffectsManager |
33 | 33 |
{ |
34 | 34 |
private int mHeight, mWidth; |
35 |
|
|
36 |
private Static3D shearFactor; |
|
37 |
private Dynamic3D shearDynamic; |
|
38 |
private Static3D scaleFactor; |
|
39 |
private Dynamic3D scaleDynamic; |
|
40 |
private Static3D deformForce; |
|
41 |
private Static5D windFactor11, windFactor12; |
|
42 |
private Dynamic5D windDynamic1; |
|
43 |
private Static5D windFactor21, windFactor22; |
|
44 |
private Dynamic5D windDynamic2; |
|
45 |
private Static5D windFactor31, windFactor32; |
|
46 |
private Dynamic5D windDynamic3; |
|
35 |
private float mBlackness, mAsianness; |
|
47 | 36 |
|
48 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
49 | 38 |
|
50 |
AroundTheWorldEffectsManager(DistortedObject obj)
|
|
39 |
AroundTheWorldEffectsManager() |
|
51 | 40 |
{ |
52 |
mHeight = obj.getHeight(); |
|
53 |
mWidth = obj.getWidth(); |
|
54 |
|
|
55 |
shearFactor = new Static3D(0,0,0); |
|
56 |
shearDynamic= new Dynamic3D(); |
|
57 |
shearDynamic.add(shearFactor); |
|
58 |
|
|
59 |
scaleFactor = new Static3D(1,1,1); |
|
60 |
scaleDynamic= new Dynamic3D(); |
|
61 |
scaleDynamic.add(scaleFactor); |
|
62 |
|
|
63 |
deformForce = new Static3D(mWidth/3,0,0); |
|
64 |
|
|
65 |
windFactor11 = new Static5D(mHeight/10,mHeight/5, 180, 0, 90); |
|
66 |
windFactor12 = new Static5D(mHeight/10,mHeight/5,-180, 0, 90); |
|
67 |
windDynamic1 = new Dynamic5D(1000,0.0f); |
|
68 |
windDynamic1.add(windFactor11); |
|
69 |
windDynamic1.add(windFactor12); |
|
70 |
windDynamic1.setMode(Dynamic.MODE_JUMP); |
|
71 |
windDynamic1.setAccessMode(Dynamic.ACCESS_SEQUENTIAL); |
|
41 |
mHeight = 0; |
|
42 |
mWidth = 0; |
|
43 |
mBlackness = 0; |
|
44 |
mAsianness = 0; |
|
45 |
} |
|
72 | 46 |
|
73 |
windFactor21 = new Static5D(mHeight/10,mHeight/5,-180, 90, 10); |
|
74 |
windFactor22 = new Static5D(mHeight/10,mHeight/5,+180, 90, 10); |
|
75 |
windDynamic2 = new Dynamic5D(1000,0.0f); |
|
76 |
windDynamic2.add(windFactor21); |
|
77 |
windDynamic2.add(windFactor22); |
|
78 |
windDynamic2.setMode(Dynamic.MODE_JUMP); |
|
79 |
windDynamic2.setAccessMode(Dynamic.ACCESS_SEQUENTIAL); |
|
47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
80 | 48 |
|
81 |
windFactor31 = new Static5D(mHeight/10,mHeight/10,-180, 90, 90); |
|
82 |
windFactor32 = new Static5D(mHeight/10,mHeight/10,+180, 90, 90); |
|
83 |
windDynamic3 = new Dynamic5D(1000,0.0f); |
|
84 |
windDynamic3.add(windFactor31); |
|
85 |
windDynamic3.add(windFactor32); |
|
86 |
windDynamic3.setMode(Dynamic.MODE_JUMP); |
|
87 |
windDynamic3.setAccessMode(Dynamic.ACCESS_SEQUENTIAL); |
|
49 |
void setSize(int width, int height) |
|
50 |
{ |
|
51 |
mWidth = width; |
|
52 |
mHeight= height; |
|
88 | 53 |
} |
89 | 54 |
|
90 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
91 | 56 |
|
92 |
synchronized void apply(DistortedObject obj, int wind)
|
|
57 |
synchronized void apply(DistortedObject obj) |
|
93 | 58 |
{ |
94 |
Static3D midLeft = new Static3D(0,mHeight/2,0); |
|
95 |
Static3D midRight = new Static3D(mWidth,mHeight/2,0); |
|
96 |
Static4D windRegion = new Static4D(0,0,mWidth,mHeight); |
|
97 |
|
|
98 |
setWind(wind); |
|
59 |
setRace(mBlackness, mAsianness); |
|
99 | 60 |
|
100 |
obj.shear(shearDynamic,midLeft); |
|
101 |
obj.scale(scaleDynamic); |
|
102 |
obj.deform(deformForce,midRight); |
|
103 |
obj.wave(windDynamic1, midRight, windRegion); |
|
104 |
obj.wave(windDynamic2, midRight, windRegion); |
|
105 |
obj.wave(windDynamic3, midRight, windRegion); |
|
61 |
// TODO |
|
106 | 62 |
} |
107 | 63 |
|
108 | 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
109 | 65 |
|
110 |
synchronized void setWind(int wind)
|
|
66 |
synchronized void setRace(float blackness, float asianness)
|
|
111 | 67 |
{ |
112 |
float tanAngle = (wind-50)/50.0f; |
|
113 |
|
|
114 |
shearFactor.set2(tanAngle); |
|
115 |
scaleFactor.set1(1/(float)Math.sqrt(1+tanAngle*tanAngle)); |
|
116 |
windDynamic1.setDuration( wind > 0 ? 100000/wind : Long.MAX_VALUE); |
|
117 |
windDynamic2.setDuration( wind > 0 ? 80000/wind : Long.MAX_VALUE); |
|
118 |
windDynamic3.setDuration( wind > 0 ? 100000/wind : Long.MAX_VALUE); |
|
119 |
|
|
120 |
float waveA = (mHeight/(20.0f-0.15f*wind)); |
|
121 |
windFactor21.set1(waveA); |
|
122 |
windFactor22.set1(waveA); |
|
68 |
mBlackness = blackness; |
|
69 |
mAsianness = asianness; |
|
123 | 70 |
|
124 |
float waveB = (mHeight/(wind+5.0f)); |
|
125 |
windFactor31.set1(waveB); |
|
126 |
windFactor32.set1(waveB); |
|
71 |
android.util.Log.e("manager", "blackness="+blackness+" asianness="+asianness); |
|
72 |
// TODO |
|
127 | 73 |
} |
128 | 74 |
} |
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
---|---|---|
51 | 51 |
AroundTheWorldRenderer(GLSurfaceView view) |
52 | 52 |
{ |
53 | 53 |
mView = view; |
54 |
mEffects = new AroundTheWorldEffectsManager(); |
|
54 | 55 |
} |
55 | 56 |
|
56 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 |
|
|
58 |
|
|
59 |
public AroundTheWorldEffectsManager getManager() |
|
60 |
{ |
|
61 |
return mEffects; |
|
62 |
} |
|
63 |
|
|
64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
65 |
|
|
58 | 66 |
public void onDrawFrame(GL10 glUnused) |
59 | 67 |
{ |
60 | 68 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
... | ... | |
108 | 116 |
} |
109 | 117 |
|
110 | 118 |
mObject = new DistortedBitmap(bitmap.getWidth(),bitmap.getHeight(),30); |
111 |
mEffects = new AroundTheWorldEffectsManager(mObject); |
|
112 | 119 |
|
113 | 120 |
mObjWidth = mObject.getWidth(); |
114 | 121 |
mObjHeight= mObject.getHeight(); |
115 | 122 |
|
123 |
mEffects.setSize(mObjWidth,mObjHeight); |
|
124 |
|
|
116 | 125 |
mObject.setBitmap(bitmap); |
126 |
mEffects.apply(mObject); |
|
117 | 127 |
|
118 | 128 |
try |
119 | 129 |
{ |
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldSurfaceView.java | ||
---|---|---|
49 | 49 |
setRenderer(mRenderer); |
50 | 50 |
} |
51 | 51 |
} |
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
public AroundTheWorldEffectsManager getManager() |
|
55 |
{ |
|
56 |
return mRenderer.getManager(); |
|
57 |
} |
|
58 |
|
|
52 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
53 | 60 |
|
54 | 61 |
public AroundTheWorldRenderer getRenderer() |
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldSurfaceViewPicker.java | ||
---|---|---|
30 | 30 |
class AroundTheWorldSurfaceViewPicker extends GLSurfaceView |
31 | 31 |
{ |
32 | 32 |
private AroundTheWorldRendererPicker mRenderer; |
33 |
private AroundTheWorldEffectsManager mManager; |
|
33 | 34 |
|
34 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 36 |
|
... | ... | |
50 | 51 |
setRenderer(mRenderer); |
51 | 52 |
} |
52 | 53 |
} |
54 |
|
|
53 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
54 | 56 |
|
55 | 57 |
public AroundTheWorldRendererPicker getRenderer() |
... | ... | |
57 | 59 |
return mRenderer; |
58 | 60 |
} |
59 | 61 |
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
|
|
64 |
public void setEffectsManager(AroundTheWorldEffectsManager manager) |
|
65 |
{ |
|
66 |
mManager = manager; |
|
67 |
} |
|
68 |
|
|
60 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | 70 |
|
62 | 71 |
@Override public boolean onTouchEvent(MotionEvent event) |
... | ... | |
91 | 100 |
} |
92 | 101 |
|
93 | 102 |
mRenderer.move(xf,yf); |
103 |
mManager.setRace( 1.0f - (yf+1.5f)/3.0f, (xf+0.865f)/(3*0.865f) ); |
|
94 | 104 |
} |
95 | 105 |
|
96 | 106 |
return true; |
src/main/java/org/distorted/examples/fov/FOVSurfaceView.java | ||
---|---|---|
47 | 47 |
setRenderer(renderer); |
48 | 48 |
} |
49 | 49 |
} |
50 |
|
|
51 | 50 |
} |
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 | 51 |
|
Also available in: Unified diff
Around the World: setRace