Project

General

Profile

« Previous | Next » 

Revision 4b34bb08

Added by Leszek Koltunski about 8 years ago

progress with Around the World

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldActivity.java
39 39

  
40 40
      AroundTheWorldSurfaceView       view = (AroundTheWorldSurfaceView)       this.findViewById(R.id.aroundTheWorldSurfaceView);
41 41
      AroundTheWorldSurfaceViewPicker pick = (AroundTheWorldSurfaceViewPicker) this.findViewById(R.id.aroundTheWorldSurfaceViewPicker);
42
      AroundTheWorldEffectsManager    mana = view.getManager();
43
      AroundTheWorldRendererPicker    renp = pick.getRenderer();
42 44

  
43
      pick.setEffectsManager(view.getManager());
45
      renp.move(0,0);
46
      mana.setRace(0.33f,0.33f);
47

  
48
      pick.setEffectsManager(mana);
44 49
      }
45 50

  
46 51
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java
23 23

  
24 24
import org.distorted.library.DistortedObject;
25 25
import org.distorted.library.type.Dynamic;
26
import org.distorted.library.type.Dynamic1D;
27
import org.distorted.library.type.Dynamic2D;
26 28
import org.distorted.library.type.Dynamic3D;
27 29
import org.distorted.library.type.Dynamic5D;
30
import org.distorted.library.type.Static1D;
31
import org.distorted.library.type.Static2D;
28 32
import org.distorted.library.type.Static3D;
29 33
import org.distorted.library.type.Static4D;
30 34
import org.distorted.library.type.Static5D;
31 35

  
32 36
class AroundTheWorldEffectsManager
33 37
  {
34
  private int mHeight, mWidth;
35 38
  private float mBlackness, mAsianness;
36 39

  
40
  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

  
37 52
///////////////////////////////////////////////////////////////////////////////////////////////////
38 53

  
39 54
  AroundTheWorldEffectsManager()
40 55
    {
41
    mHeight    = 0;
42
    mWidth     = 0;
43 56
    mBlackness = 0;
44 57
    mAsianness = 0;
45
    }
46 58

  
47
///////////////////////////////////////////////////////////////////////////////////////////////////
59
    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);
48 63

  
49
  void setSize(int width, int height)
50
    {
51
    mWidth = width;
52
    mHeight= height;
64
    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);
53 94
    }
54 95

  
55 96
///////////////////////////////////////////////////////////////////////////////////////////////////
......
58 99
    {
59 100
    setRace(mBlackness, mAsianness);
60 101

  
61
    // TODO
102
    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);
62 112
    }
63 113

  
64 114
///////////////////////////////////////////////////////////////////////////////////////////////////
......
68 118
    mBlackness = blackness;
69 119
    mAsianness = asianness;
70 120

  
71
    android.util.Log.e("manager", "blackness="+blackness+" asianness="+asianness);
72
    // TODO
121
    //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);
73 129
    }
74 130
  }
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
52 52
      {
53 53
      mView = view;
54 54
      mEffects = new AroundTheWorldEffectsManager();
55

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

  
57 60
///////////////////////////////////////////////////////////////////////////////////////////////////
58 61

  
59
   public AroundTheWorldEffectsManager getManager()
62
   AroundTheWorldEffectsManager getManager()
60 63
     {
61 64
     return mEffects;
62 65
     }
......
120 123
      mObjWidth = mObject.getWidth();
121 124
      mObjHeight= mObject.getHeight();
122 125

  
123
      mEffects.setSize(mObjWidth,mObjHeight);
124

  
125 126
      mObject.setBitmap(bitmap);
126 127
      mEffects.apply(mObject);
127 128

  

Also available in: Unified diff