1 |
7ba38011
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Distorted. //
|
5 |
|
|
// //
|
6 |
|
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Distorted is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
|
|
package org.distorted.examples.aroundtheworld;
|
21 |
|
|
|
22 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23 |
|
|
|
24 |
|
|
import org.distorted.library.DistortedObject;
|
25 |
|
|
import org.distorted.library.type.Dynamic;
|
26 |
4b34bb08
|
Leszek Koltunski
|
import org.distorted.library.type.Dynamic1D;
|
27 |
|
|
import org.distorted.library.type.Dynamic2D;
|
28 |
7ba38011
|
Leszek Koltunski
|
import org.distorted.library.type.Dynamic3D;
|
29 |
|
|
import org.distorted.library.type.Dynamic5D;
|
30 |
4b34bb08
|
Leszek Koltunski
|
import org.distorted.library.type.Static1D;
|
31 |
|
|
import org.distorted.library.type.Static2D;
|
32 |
7ba38011
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
33 |
|
|
import org.distorted.library.type.Static4D;
|
34 |
|
|
import org.distorted.library.type.Static5D;
|
35 |
|
|
|
36 |
|
|
class AroundTheWorldEffectsManager
|
37 |
|
|
{
|
38 |
2f20ae3a
|
Leszek Koltunski
|
private float mBlackness, mAsianness;
|
39 |
7ba38011
|
Leszek Koltunski
|
|
40 |
4b34bb08
|
Leszek Koltunski
|
private Static4D regionPinchSwirl, regionNose, regionLips, regionSkin, regionLEye, regionREye;
|
41 |
|
|
private Static3D centerLEye, centerREye, centerNose, centerLips;
|
42 |
|
|
|
43 |
|
|
private Dynamic2D pinchDyn;
|
44 |
|
|
private Dynamic1D swirlDyn1, swirlDyn2, sinkDyn;
|
45 |
|
|
private Static1D swirlFactor1, swirlFactor2, sinkFactor;
|
46 |
|
|
private Static2D pinchFactor;
|
47 |
|
|
|
48 |
|
|
private Static3D chromaSkin, chromaEyes;
|
49 |
|
|
private Static1D chromaSkinFactor, chromaEyesFactor;
|
50 |
|
|
private Dynamic1D chromaSkinDyn, chromaEyesDyn;
|
51 |
|
|
|
52 |
7ba38011
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53 |
|
|
|
54 |
2f20ae3a
|
Leszek Koltunski
|
AroundTheWorldEffectsManager()
|
55 |
7ba38011
|
Leszek Koltunski
|
{
|
56 |
2f20ae3a
|
Leszek Koltunski
|
mBlackness = 0;
|
57 |
|
|
mAsianness = 0;
|
58 |
7ba38011
|
Leszek Koltunski
|
|
59 |
4b34bb08
|
Leszek Koltunski
|
centerLEye = new Static3D( 88,117,0);
|
60 |
|
|
centerREye = new Static3D(211,117,0);
|
61 |
|
|
centerNose = new Static3D(150,175,0);
|
62 |
|
|
centerLips = new Static3D(150,240,0);
|
63 |
7ba38011
|
Leszek Koltunski
|
|
64 |
4b34bb08
|
Leszek Koltunski
|
regionPinchSwirl = new Static4D(0,0,42,100);
|
65 |
|
|
regionNose = new Static4D(0,0,51,100);
|
66 |
|
|
regionLips = new Static4D(0,0,57,100);
|
67 |
|
|
regionSkin = new Static4D(150,150,300,300);
|
68 |
|
|
regionLEye = new Static4D( 87,117,15,12);
|
69 |
|
|
regionREye = new Static4D(213,117,15,12);
|
70 |
|
|
|
71 |
|
|
pinchFactor = new Static2D(1.0f, 0.0f);
|
72 |
|
|
swirlFactor1 = new Static1D(1.0f);
|
73 |
|
|
swirlFactor2 = new Static1D(1.0f);
|
74 |
|
|
sinkFactor = new Static1D(1.0f);
|
75 |
|
|
|
76 |
|
|
chromaSkin = new Static3D(0.5f, 0.11f, 0.11f);
|
77 |
|
|
chromaEyes = new Static3D(0.5f, 0.14f, 0.14f);
|
78 |
|
|
chromaSkinFactor = new Static1D(0.0f);
|
79 |
|
|
chromaEyesFactor = new Static1D(0.0f);
|
80 |
|
|
|
81 |
|
|
pinchDyn = new Dynamic2D();
|
82 |
|
|
pinchDyn.add(pinchFactor);
|
83 |
|
|
swirlDyn1= new Dynamic1D();
|
84 |
|
|
swirlDyn1.add(swirlFactor1);
|
85 |
|
|
swirlDyn2= new Dynamic1D();
|
86 |
|
|
swirlDyn2.add(swirlFactor2);
|
87 |
|
|
sinkDyn = new Dynamic1D();
|
88 |
|
|
sinkDyn.add(sinkFactor);
|
89 |
|
|
|
90 |
|
|
chromaSkinDyn = new Dynamic1D();
|
91 |
|
|
chromaSkinDyn.add(chromaSkinFactor);
|
92 |
|
|
chromaEyesDyn = new Dynamic1D();
|
93 |
|
|
chromaEyesDyn.add(chromaEyesFactor);
|
94 |
7ba38011
|
Leszek Koltunski
|
}
|
95 |
|
|
|
96 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97 |
|
|
|
98 |
2f20ae3a
|
Leszek Koltunski
|
synchronized void apply(DistortedObject obj)
|
99 |
7ba38011
|
Leszek Koltunski
|
{
|
100 |
2f20ae3a
|
Leszek Koltunski
|
setRace(mBlackness, mAsianness);
|
101 |
7ba38011
|
Leszek Koltunski
|
|
102 |
4b34bb08
|
Leszek Koltunski
|
obj.pinch(pinchDyn, centerLEye, regionPinchSwirl);
|
103 |
|
|
obj.pinch(pinchDyn, centerREye, regionPinchSwirl);
|
104 |
|
|
obj.swirl(swirlDyn1,centerLEye, regionPinchSwirl);
|
105 |
|
|
obj.swirl(swirlDyn2,centerREye, regionPinchSwirl);
|
106 |
|
|
obj.sink(sinkDyn, centerNose, regionNose);
|
107 |
|
|
obj.sink(sinkDyn, centerLips, regionLips);
|
108 |
|
|
|
109 |
|
|
obj.chroma(chromaSkinDyn, chromaSkin, regionSkin, false);
|
110 |
|
|
obj.chroma(chromaEyesDyn, chromaEyes, regionLEye, true);
|
111 |
|
|
obj.chroma(chromaEyesDyn, chromaEyes, regionREye, true);
|
112 |
7ba38011
|
Leszek Koltunski
|
}
|
113 |
|
|
|
114 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
115 |
|
|
|
116 |
2f20ae3a
|
Leszek Koltunski
|
synchronized void setRace(float blackness, float asianness)
|
117 |
7ba38011
|
Leszek Koltunski
|
{
|
118 |
2f20ae3a
|
Leszek Koltunski
|
mBlackness = blackness;
|
119 |
|
|
mAsianness = asianness;
|
120 |
7ba38011
|
Leszek Koltunski
|
|
121 |
4b34bb08
|
Leszek Koltunski
|
//android.util.Log.e("manager", "blackness="+blackness+" asianness="+asianness);
|
122 |
|
|
|
123 |
|
|
pinchFactor.set1(1-0.2f*asianness);
|
124 |
|
|
swirlFactor1.set( 10.0f*asianness);
|
125 |
|
|
swirlFactor2.set(-10.0f*asianness);
|
126 |
|
|
sinkFactor.set(1-0.4f*asianness);
|
127 |
|
|
chromaSkinFactor.set(0.28f*asianness);
|
128 |
|
|
chromaEyesFactor.set(0.78f*asianness);
|
129 |
7ba38011
|
Leszek Koltunski
|
}
|
130 |
|
|
}
|