Project

General

Profile

« Previous | Next » 

Revision b3a555a7

Added by Leszek Koltunski about 8 years ago

Improve Around The World

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java
35 35

  
36 36
class AroundTheWorldEffectsManager
37 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;
38
  private float mWhiteness, mBlackness, mAsianness;  // those always sum up to 1
39

  
40
  // WHITENESS
41
  // Vertex effects:
42
  // a) make the lips smaller (SINK)
43
  private Static4D wRegionLips;
44
  private Static3D wCenterLips;
45
  private Static1D wLipsFactor;
46
  private Dynamic1D wLipsDyn;
47

  
48
  // ASIANNESS
49
  // Vertex Effects:
50
  // a) move lips & nose higher (DISTORT)
51
  private Static4D aRegionLipsNose;
52
  private Static3D aCenterLipsNose;
53
  private Static3D aLipsNoseFactor;
54
  private Dynamic3D aLipsNoseDyn;
55
  // b) make the nose broader (PINCH)
56
  private Static4D aRegionNoseBroader;
57
  private Static3D aCenterNoseBroader;
58
  private Static2D aNoseBroaderFactor;
59
  private Dynamic2D aNoseBroaderDyn;
60
  // c) make the nostrils more visible (DISTORT)
61
  private Static4D aRegionNostrils;
62
  private Static3D aCenterNostrils;
63
  private Static3D aNostrilsFactor;
64
  private Dynamic3D aNostrilsDyn;
65
  // d) rotate eyes (2 x SWIRL)
66
  private Static4D aRegionEyes;
67
  private Static3D aCenterLEye, aCenterREye;
68
  private Static1D aLEyeFactor, aREyeFactor;
69
  private Dynamic1D aLEyeDyn, aREyeDyn;
70
  // e) move eyebrow higher (DISTORT)
71
  private Static4D aRegionEyebrows;
72
  private Static3D aCenterEyebrows;
73
  private Static3D aEyebrowsFactor;
74
  private Dynamic3D aEyebrowsDyn;
75

  
76
  // Fragment effects:
77
  // a) change color of the skin to more brown and less red (CHROMA)
78
  private Static4D aRegionSkinColor;
79
  private Static3D aChromaSkin;
80
  private Static1D aChromaSkinFactor;
81
  private Dynamic1D aChromaSkinDyn;
82
  // b) darken both eyes (2 x SMOOTH_CHROMA)
83
  private Static4D aRegionLEyeColor, aRegionREyeColor;
84
  private Static3D aChromaEyes;
85
  private Static1D aChromaEyesFactor;
86
  private Dynamic1D aChromaEyesDyn;
87

  
88
  // BLACKNESS
51 89

  
52 90
///////////////////////////////////////////////////////////////////////////////////////////////////
53 91

  
54 92
  AroundTheWorldEffectsManager()
55 93
    {
94
    mWhiteness = 1;
56 95
    mBlackness = 0;
57 96
    mAsianness = 0;
58 97

  
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);
98
    // WHITENESS
99
    // Vertex Effects
100
    wRegionLips = new Static4D(0,0,100,100);
101
    wCenterLips = new Static3D(300,500,0);
102
    wLipsFactor = new Static1D(0.7f);
103
    wLipsDyn    = new Dynamic1D();
104
    wLipsDyn.add(wLipsFactor);
105

  
106
    // ASIANNESS
107
    // Vertex Effects
108
    aRegionLipsNose    = new Static4D(0,0,267,267);
109
    aCenterLipsNose    = new Static3D(300,560,0);
110
    aLipsNoseDyn       = new Dynamic3D();
111
    aLipsNoseFactor    = new Static3D(0,0,0);
112
    aLipsNoseDyn.add(aLipsNoseFactor);
113

  
114
    aRegionNoseBroader = new Static4D(0,0,130,130);
115
    aCenterNoseBroader = new Static3D(300,307,0);
116
    aNoseBroaderDyn    = new Dynamic2D();
117
    aNoseBroaderFactor = new Static2D(0,90);
118
    aNoseBroaderDyn.add(aNoseBroaderFactor);
119

  
120
    aRegionNostrils    = new Static4D(0,0,60,60);
121
    aCenterNostrils    = new Static3D(300,336,0);
122
    aNostrilsDyn       = new Dynamic3D();
123
    aNostrilsFactor    = new Static3D(0,0,0);
124
    aNostrilsDyn.add(aNostrilsFactor);
125

  
126
    aRegionEyes        = new Static4D(0,0,83,83);
127
    aCenterLEye        = new Static3D(176,230,0);
128
    aCenterREye        = new Static3D(420,230,0);
129
    aLEyeDyn           = new Dynamic1D();
130
    aREyeDyn           = new Dynamic1D();
131
    aLEyeFactor        = new Static1D(0);
132
    aREyeFactor        = new Static1D(0);
133
    aLEyeDyn.add(aLEyeFactor);
134
    aREyeDyn.add(aREyeFactor);
135

  
136
    aRegionEyebrows    = new Static4D(0,0,142,142);
137
    aCenterEyebrows    = new Static3D(300,100,0);
138
    aEyebrowsDyn       = new Dynamic3D();
139
    aEyebrowsFactor    = new Static3D(0,0,0);
140
    aEyebrowsDyn.add(aEyebrowsFactor);
141

  
142
    // Fragment Effects
143
    aRegionSkinColor   = new Static4D(300,300,600,600);
144
    aRegionLEyeColor   = new Static4D(172,232,29,25);
145
    aRegionREyeColor   = new Static4D(424,232,29,25);
146

  
147
    aChromaSkin        = new Static3D(0.5f, 0.5f, 0.5f);
148
    aChromaEyes        = new Static3D(0.5f, 0.14f, 0.14f);
149
    aChromaSkinFactor  = new Static1D(0.0f);
150
    aChromaEyesFactor  = new Static1D(0.0f);
151

  
152
    aChromaSkinDyn = new Dynamic1D();
153
    aChromaSkinDyn.add(aChromaSkinFactor);
154
    aChromaEyesDyn = new Dynamic1D();
155
    aChromaEyesDyn.add(aChromaEyesFactor);
96 156
    }
97 157

  
98 158
///////////////////////////////////////////////////////////////////////////////////////////////////
......
101 161
    {
102 162
    setRace(mBlackness, mAsianness);
103 163

  
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);
164
    // WHITENESS
165
    obj.sink(wLipsDyn, wCenterLips, wRegionLips);
166

  
167
    // ASIANNESS
168
    obj.distort(aLipsNoseDyn, aCenterLipsNose, aRegionLipsNose);
169
    obj.pinch(aNoseBroaderDyn, aCenterNoseBroader, aRegionNoseBroader);
170
    obj.distort(aNostrilsDyn, aCenterNostrils, aRegionNostrils);
171
    obj.swirl(aLEyeDyn, aCenterLEye, aRegionEyes);
172
    obj.swirl(aREyeDyn, aCenterREye, aRegionEyes);
173
    obj.distort(aEyebrowsDyn, aCenterEyebrows, aRegionEyebrows);
110 174

  
111
    obj.chroma(chromaSkinDyn, chromaSkin, regionSkin, false);
112
    obj.chroma(chromaEyesDyn, chromaEyes, regionLEye, true);
113
    obj.chroma(chromaEyesDyn, chromaEyes, regionREye, true);
175
    obj.chroma(aChromaSkinDyn, aChromaSkin, aRegionSkinColor, false);
176
    obj.chroma(aChromaEyesDyn, aChromaEyes, aRegionLEyeColor, true);
177
    obj.chroma(aChromaEyesDyn, aChromaEyes, aRegionREyeColor, true);
178

  
179
    // BLACKNESS
114 180
    }
115 181

  
116 182
///////////////////////////////////////////////////////////////////////////////////////////////////
117 183

  
118 184
  synchronized void setRace(float blackness, float asianness)
119 185
    {
186
    mWhiteness = 1 - blackness - asianness;
120 187
    mBlackness = blackness;
121 188
    mAsianness = asianness;
122 189

  
123 190
    //android.util.Log.e("manager", "blackness="+blackness+" asianness="+asianness);
124 191

  
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);
192
    // WHITENESS
193
    wLipsFactor.set(1.0f-0.3f*mWhiteness);
194

  
195
    // ASIANNESS
196
    aLipsNoseFactor.set2(-23.0f*mAsianness);
197
    aNoseBroaderFactor.set1(1.0f+0.92f*mAsianness);
198
    aNostrilsFactor.set2(-12.0f*mAsianness);
199
    aLEyeFactor.set(+11.0f*mAsianness);
200
    aREyeFactor.set(-11.0f*mAsianness);
201
    aEyebrowsFactor.set2(-40.0f*mAsianness);
202

  
203
    aChromaSkinFactor.set(0.2f*mAsianness);
204
    aChromaEyesFactor.set(0.7f*mAsianness);
205

  
206
    // BLACKNESS
131 207
    }
132 208
  }
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
53 53
      mView = view;
54 54
      mEffects = new AroundTheWorldEffectsManager();
55 55

  
56
      Distorted.setMaxVertex(6);
56
      Distorted.setMaxVertex(12);
57 57
      Distorted.setMaxFragment(3);
58 58
      }
59 59

  

Also available in: Unified diff