Project

General

Profile

« Previous | Next » 

Revision d7413405

Added by Leszek Koltunski over 6 years ago

OIT: lots of progress on all fronts. Still a few bugs to solve though!

View differences:

src/main/java/org/distorted/examples/transparency/TransparencyRenderer.java
84 84
      mNode         = new DistortedNode[NUM_OBJECTS];
85 85
      mTex          = new DistortedTexture[NUM_OBJECTS];
86 86

  
87
      FragmentEffectAlpha[] alpha= new FragmentEffectAlpha[NUM_OBJECTS];
88
      DistortedEffects[] effects = new DistortedEffects[NUM_OBJECTS];
87
      FragmentEffectAlpha[] alpha  = new FragmentEffectAlpha[NUM_OBJECTS];
88
      DistortedEffects[] effects   = new DistortedEffects[NUM_OBJECTS];
89
      PostprocessEffectBlur[] blur = new PostprocessEffectBlur[NUM_OBJECTS];
89 90

  
90 91
      mMove  = new Static3D(0,0,0);
91 92
      mScale = new Static3D(1.0f,1.0f,1.0f);
......
96 97
      MatrixEffectQuaternion quatEffect1 = new MatrixEffectQuaternion(mQuat1, mCenter);
97 98
      MatrixEffectQuaternion quatEffect2 = new MatrixEffectQuaternion(mQuat2, mCenter);
98 99

  
99
      PostprocessEffectBlur blur = new PostprocessEffectBlur(new Static1D(0));
100 100

  
101 101
      for(int i=0; i<NUM_OBJECTS; i++)
102 102
        {
......
104 104
        mMoveVector[i]   = new Static3D(0,0,0);
105 105
        mAlphaVector[i]  = new Static1D(0.5f);
106 106
        alpha[i]         = new FragmentEffectAlpha(mAlphaVector[i]);
107
        blur[i]          = new PostprocessEffectBlur(new Static1D(0));
107 108
        effects[i]       = new DistortedEffects();
108 109

  
109
        effects[i].apply(blur);
110
        effects[i].apply(blur[i]);
110 111
        effects[i].apply(alpha[i]);
111 112
        effects[i].apply(moveEffect);
112 113
        effects[i].apply(scaleEffect);
src/main/java/org/distorted/examples/triblur/TriblurRenderer.java
54 54

  
55 55
    private static final int[] OBJECTS =
56 56
        {
57
        -1, 0, 0, 255,   0,  0,  // x,y,z, R,G,B
58
         0, 0, 0, 255, 255,  0,  //
59
        +1, 0, 0,   0, 255,  0,  //
57
        -150, 0, 0,   255,   0,  0,  // x,y,z, R,G,B
58
           0, 0, 0,   255, 255,  0,  //
59
        +150, 0, 0,     0, 255,  0,  //
60 60
        };
61 61

  
62 62
    private static final int NUM_OBJECTS = OBJECTS.length/NUM;
......
65 65
    private GLSurfaceView mView;
66 66
    private DistortedTexture mTex;
67 67
    private DistortedNode[] mNode;
68
    private Static3D[]  mMoveVector;
69
    private Static3D[]  mChromaVector;
70 68
    private Static1D[]  mBlurVector;
71 69
    private DistortedScreen mScreen;
72 70
    private PostprocessEffectBlur[] mBlur;
73
    private FragmentEffectChroma[] mChroma;
74
    private int mDistance;
75 71
    private boolean[] mBlurStatus;
76 72
    private Static3D mMove1, mMove2, mScale1, mScale2, mCenter;
77 73

  
......
83 79
    TriblurRenderer(GLSurfaceView v)
84 80
      {
85 81
      mView = v;
86
      mDistance = (int)(OBJ_SIZE*0.6f);
87 82

  
88 83
      MeshCubes mesh = new MeshCubes(1,1,1);
89 84

  
......
96 91
      mScreen.setDebug(DistortedScreen.DEBUG_FPS);
97 92

  
98 93
      mBlurStatus   = new boolean[NUM_OBJECTS];
99
      mMoveVector   = new Static3D[NUM_OBJECTS];
100
      mChromaVector = new Static3D[NUM_OBJECTS];
101 94
      mBlurVector   = new Static1D[NUM_OBJECTS];
102 95
      mNode         = new DistortedNode[NUM_OBJECTS];
103 96
      mBlur         = new PostprocessEffectBlur[NUM_OBJECTS];
104
      mChroma       = new FragmentEffectChroma[NUM_OBJECTS];
97

  
98
      FragmentEffectChroma[] chroma= new FragmentEffectChroma[NUM_OBJECTS];
99
      Static3D[] chromaVector      = new Static3D[NUM_OBJECTS];
100
      Static3D[] moveVector        = new Static3D[NUM_OBJECTS];
105 101

  
106 102
      DistortedEffects[] effects= new DistortedEffects[NUM_OBJECTS];
107 103

  
......
120 116

  
121 117
      for(int i=0; i<NUM_OBJECTS; i++)
122 118
        {
123
        mMoveVector[i]   = new Static3D(0,0,0);
124
        mChromaVector[i] = new Static3D(OBJECTS[NUM*i+3],OBJECTS[NUM*i+4],OBJECTS[NUM*i+5]);
119
        moveVector[i]    = new Static3D(OBJECTS[NUM*i  ], OBJECTS[NUM*i+1], OBJECTS[NUM*i+2]);
120
        chromaVector[i]  = new Static3D(OBJECTS[NUM*i+3], OBJECTS[NUM*i+4], OBJECTS[NUM*i+5]);
125 121
        mBlurVector[i]   = new Static1D(10);
126 122
        mBlur[i]         = new PostprocessEffectBlur(mBlurVector[i]);
127
        mChroma[i]       = new FragmentEffectChroma( new Static1D(0.3f), mChromaVector[i]);
123
        chroma[i]        = new FragmentEffectChroma( new Static1D(0.3f), chromaVector[i]);
128 124
        effects[i]       = new DistortedEffects();
129 125

  
130 126
        effects[i].apply(mBlur[i]);
131
        effects[i].apply(mChroma[i]);
127
        effects[i].apply(chroma[i]);
132 128
        effects[i].apply( (i==0||i==NUM_OBJECTS-1) ?  moveEffect1 :  moveEffect2 );
133 129
        effects[i].apply( (i==0||i==NUM_OBJECTS-1) ? scaleEffect1 : scaleEffect2 );
134 130
        effects[i].apply(quatEffect1);
135 131
        effects[i].apply(quatEffect2);
136
        effects[i].apply(new MatrixEffectMove(mMoveVector[i]));
132
        effects[i].apply(new MatrixEffectMove(moveVector[i]));
137 133

  
138 134
        mBlurStatus[i] = true;
139 135
        mNode[i] = new DistortedNode(mTex, effects[i], mesh );
......
215 211
      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, -(float)OBJ_SIZE/2 );
216 212
      mMove1.set( (width -factor1*OBJ_SIZE)/2 ,(height-factor1*OBJ_SIZE)/2 ,0);
217 213
      mMove2.set( (width -factor2*OBJ_SIZE)/2 ,(height-factor2*OBJ_SIZE)/2 ,0);
218
      computeMoveVectors();
219 214
      mScreen.resize(width, height);
220 215
      }
221 216

  
222
///////////////////////////////////////////////////////////////////////////////////////////////////
223

  
224
    private void computeMoveVectors()
225
      {
226
      float size= 0.026f*OBJ_SIZE*mDistance;
227

  
228
      for(int i=0; i<NUM_OBJECTS; i++)
229
        {
230
        mMoveVector[i].set(size*OBJECTS[NUM*i], size*OBJECTS[NUM*i+1], size*OBJECTS[NUM*i+2]);
231
        }
232
      }
233

  
234 217
///////////////////////////////////////////////////////////////////////////////////////////////////
235 218

  
236 219
    void setRange(int object, int range)

Also available in: Unified diff