1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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
|
import org.distorted.library.type.Dynamic1D;
|
27
|
import org.distorted.library.type.Dynamic2D;
|
28
|
import org.distorted.library.type.Dynamic3D;
|
29
|
import org.distorted.library.type.Dynamic5D;
|
30
|
import org.distorted.library.type.Static1D;
|
31
|
import org.distorted.library.type.Static2D;
|
32
|
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
|
private float mBlackness, mAsianness;
|
39
|
|
40
|
private Static4D regionPinchSwirl, regionNose, regionLips, regionSkin, regionLEye, regionREye;
|
41
|
private Static3D centerLEyeSwirl, centerREyeSwirl, centerLEyePinch, centerREyePinch, 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
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53
|
|
54
|
AroundTheWorldEffectsManager()
|
55
|
{
|
56
|
mBlackness = 0;
|
57
|
mAsianness = 0;
|
58
|
|
59
|
centerLEyePinch = new Static3D(140,235,0);
|
60
|
centerREyePinch = new Static3D(453,235,0);
|
61
|
centerLEyeSwirl = new Static3D(175,235,0);
|
62
|
centerREyeSwirl = new Static3D(418,235,0);
|
63
|
centerNose = new Static3D(300,328,0);
|
64
|
centerLips = new Static3D(300,494,0);
|
65
|
|
66
|
regionPinchSwirl = new Static4D(0,0,65,65);
|
67
|
regionNose = new Static4D(0,0,89,89);
|
68
|
regionLips = new Static4D(0,0,95,95);
|
69
|
regionSkin = new Static4D(300,300,600,600);
|
70
|
regionLEye = new Static4D(175,232,31,20);
|
71
|
regionREye = new Static4D(420,232,31,20);
|
72
|
|
73
|
pinchFactor = new Static2D(1.0f, 0.0f);
|
74
|
swirlFactor1 = new Static1D(1.0f);
|
75
|
swirlFactor2 = new Static1D(1.0f);
|
76
|
sinkFactor = new Static1D(1.0f);
|
77
|
|
78
|
chromaSkin = new Static3D(0.5f, 0.11f, 0.11f);
|
79
|
chromaEyes = new Static3D(0.5f, 0.14f, 0.14f);
|
80
|
chromaSkinFactor = new Static1D(0.0f);
|
81
|
chromaEyesFactor = new Static1D(0.0f);
|
82
|
|
83
|
pinchDyn = new Dynamic2D();
|
84
|
pinchDyn.add(pinchFactor);
|
85
|
swirlDyn1= new Dynamic1D();
|
86
|
swirlDyn1.add(swirlFactor1);
|
87
|
swirlDyn2= new Dynamic1D();
|
88
|
swirlDyn2.add(swirlFactor2);
|
89
|
sinkDyn = new Dynamic1D();
|
90
|
sinkDyn.add(sinkFactor);
|
91
|
|
92
|
chromaSkinDyn = new Dynamic1D();
|
93
|
chromaSkinDyn.add(chromaSkinFactor);
|
94
|
chromaEyesDyn = new Dynamic1D();
|
95
|
chromaEyesDyn.add(chromaEyesFactor);
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
|
100
|
synchronized void apply(DistortedObject obj)
|
101
|
{
|
102
|
setRace(mBlackness, mAsianness);
|
103
|
|
104
|
obj.pinch(pinchDyn, centerLEyePinch, regionPinchSwirl);
|
105
|
obj.pinch(pinchDyn, centerREyePinch, regionPinchSwirl);
|
106
|
obj.swirl(swirlDyn1,centerLEyeSwirl, regionPinchSwirl);
|
107
|
obj.swirl(swirlDyn2,centerREyeSwirl, regionPinchSwirl);
|
108
|
obj.sink(sinkDyn, centerNose, regionNose);
|
109
|
obj.sink(sinkDyn, centerLips, regionLips);
|
110
|
|
111
|
obj.chroma(chromaSkinDyn, chromaSkin, regionSkin, false);
|
112
|
obj.chroma(chromaEyesDyn, chromaEyes, regionLEye, true);
|
113
|
obj.chroma(chromaEyesDyn, chromaEyes, regionREye, true);
|
114
|
}
|
115
|
|
116
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117
|
|
118
|
synchronized void setRace(float blackness, float asianness)
|
119
|
{
|
120
|
mBlackness = blackness;
|
121
|
mAsianness = asianness;
|
122
|
|
123
|
//android.util.Log.e("manager", "blackness="+blackness+" asianness="+asianness);
|
124
|
|
125
|
pinchFactor.set1(1-0.3f*asianness);
|
126
|
swirlFactor1.set( 20.0f*asianness);
|
127
|
swirlFactor2.set(-20.0f*asianness);
|
128
|
sinkFactor.set(1-0.4f*asianness);
|
129
|
chromaSkinFactor.set(0.25f*asianness);
|
130
|
chromaEyesFactor.set(0.78f*asianness);
|
131
|
}
|
132
|
}
|