Project

General

Profile

« Previous | Next » 

Revision d38672b1

Added by Leszek Koltunski over 7 years ago

Further progress with Apps: 21 (out of 30) compile now.

View differences:

src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java
24 24
import android.opengl.GLSurfaceView;
25 25

  
26 26
import org.distorted.examples.R;
27
import org.distorted.library.effect.EffectName;
28
import org.distorted.library.effect.MatrixEffectMove;
29
import org.distorted.library.effect.MatrixEffectQuaternion;
30
import org.distorted.library.effect.MatrixEffectScale;
31
import org.distorted.library.effect.PostprocessEffectBlur;
27 32
import org.distorted.library.main.Distorted;
28 33
import org.distorted.library.main.DistortedEffects;
29 34
import org.distorted.library.main.DistortedEffectsPostprocess;
30 35
import org.distorted.library.main.DistortedNode;
31 36
import org.distorted.library.main.DistortedScreen;
32 37
import org.distorted.library.main.DistortedTexture;
33
import org.distorted.library.EffectNames;
34 38
import org.distorted.library.main.EffectQuality;
35
import org.distorted.library.EffectTypes;
36 39
import org.distorted.library.main.MeshCubes;
37
import org.distorted.library.type.Dynamic1D;
38
import org.distorted.library.type.Dynamic3D;
39
import org.distorted.library.type.DynamicQuat;
40 40
import org.distorted.library.type.Static1D;
41 41
import org.distorted.library.type.Static3D;
42 42
import org.distorted.library.type.Static4D;
......
68 68

  
69 69
    private GLSurfaceView mView;
70 70
    private DistortedTexture mTex1, mTex2;
71
    private DistortedEffects[] mEffects;
72 71
    private DistortedNode[] mNode;
73 72
    private DistortedEffectsPostprocess mPostEffects;
74 73
    private Static3D[]  mMoveVector;
75
    private Dynamic3D[] mMoveDynamic;
76 74
    private Static1D  mBlurVector;
77
    private Dynamic1D  mBlurDynamic;
78 75
    private DistortedScreen mScreen;
79
    private DynamicQuat mQuatInt1, mQuatInt2;
80 76
    private int mDistance;
81 77
    private boolean[] mBlurStatus;
78
    private Static3D mMove, mScale, mCenter;
82 79

  
83 80
    Static4D mQuat1, mQuat2;
84 81
    int mScreenMin;
......
91 88
      mDistance = -1;
92 89

  
93 90
      mBlurStatus = new boolean[NUM_OBJECTS];
94
      mMoveDynamic= new Dynamic3D[NUM_OBJECTS];
95 91
      mMoveVector = new Static3D[NUM_OBJECTS];
96 92
      mNode       = new DistortedNode[NUM_OBJECTS];
97
      mEffects    = new DistortedEffects[NUM_OBJECTS];
98 93
      mPostEffects= new DistortedEffectsPostprocess();
99 94

  
95
      DistortedEffects[] effects= new DistortedEffects[NUM_OBJECTS];
96

  
100 97
      for(int i=0; i<NUM_OBJECTS; i++)
101 98
        {
102
        mMoveVector[i]  = new Static3D(0,0,0);
103
        mEffects[i]     = new DistortedEffects();
104
        mMoveDynamic[i] = new Dynamic3D();
105

  
106
        mMoveDynamic[i].add(mMoveVector[i]);
99
        mMoveVector[i] = new Static3D(0,0,0);
100
        effects[i]     = new DistortedEffects();
107 101
        mBlurStatus[i] = false;
108 102
        }
109 103

  
110
      mBlurDynamic= new Dynamic1D();
111 104
      mBlurVector = new Static1D(10);
112
      mBlurDynamic.add(mBlurVector);
113
      mPostEffects.blur(mBlurDynamic);
105
      mPostEffects.apply( new PostprocessEffectBlur(mBlurVector) );
114 106

  
115 107
      MeshCubes mesh = new MeshCubes(1,1,1);
116 108

  
......
119 111

  
120 112
      mQuat1 = new Static4D(0,0,0,1);  // unity
121 113
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
122
      
123
      mQuatInt1 = new DynamicQuat(0,0.5f);
124
      mQuatInt2 = new DynamicQuat(0,0.5f);
125

  
126
      mQuatInt1.add(mQuat1);
127
      mQuatInt2.add(mQuat2);
128 114

  
129 115
      mScreen = new DistortedScreen(mView);
130 116
      mScreen.setDebug(DistortedScreen.DEBUG_FPS);
131 117

  
132 118
      for(int i=0; i<NUM_OBJECTS; i++)
133 119
        {
134
        mNode[i] = new DistortedNode(i < NUM_OBJECTS / 2 ? mTex1 : mTex2, mEffects[i], mesh);
120
        mNode[i] = new DistortedNode(i < NUM_OBJECTS / 2 ? mTex1 : mTex2, effects[i], mesh);
135 121
        mScreen.attach(mNode[i]);
136 122
        }
137 123

  
138 124
      mBlurStatus[0] = true;
139 125
      mNode[0].setPostprocessEffects(mPostEffects);
126

  
127
      mMove   = new Static3D(0,0,0);
128
      mScale  = new Static3D(1,1,1);
129
      mCenter = new Static3D(0,0,0);
130

  
131
      MatrixEffectMove moveEffect = new MatrixEffectMove(mMove);
132
      MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale);
133
      MatrixEffectQuaternion quatEffect1 = new MatrixEffectQuaternion(mQuat1, mCenter);
134
      MatrixEffectQuaternion quatEffect2 = new MatrixEffectQuaternion(mQuat2, mCenter);
135

  
136
      for(int i=0; i<NUM_OBJECTS; i++)
137
        {
138
        effects[i].apply(moveEffect);
139
        effects[i].apply(scaleEffect);
140
        effects[i].apply(quatEffect1);
141
        effects[i].apply(quatEffect2);
142
        effects[i].apply(new MatrixEffectMove(mMoveVector[i]));
143
        }
140 144
      }
141 145

  
142 146
///////////////////////////////////////////////////////////////////////////////////////////////////
......
160 164
      mScreenMin = width<height ? width:height;
161 165

  
162 166
    	float factor    = 0.15f*mScreenMin/OBJ_SIZE;
163
      Static3D center = new Static3D( (float)OBJ_SIZE/2, (float)OBJ_SIZE/2, -(float)OBJ_SIZE/2 );
164
      Static3D moveVec= new Static3D( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0);
165

  
166
      for(int i=0; i<NUM_OBJECTS; i++)
167
        {
168
        mEffects[i].abortEffects(EffectTypes.MATRIX);
169

  
170
        mEffects[i].move(moveVec);
171
        mEffects[i].scale(factor);
172
        mEffects[i].quaternion(mQuatInt1, center);
173
        mEffects[i].quaternion(mQuatInt2, center);
174
        mEffects[i].move(mMoveDynamic[i]);
175
        }
176

  
167
    	mScale.set(factor,factor,factor);
168
      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, -(float)OBJ_SIZE/2 );
169
      mMove.set( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0);
177 170
      computeMoveVectors();
178 171
      mScreen.resize(width, height);
179 172
      }
......
204 197
      mTex1.setTexture(bitmap1);
205 198
      mTex2.setTexture(bitmap2);
206 199

  
207
      DistortedEffects.enableEffect(EffectNames.BLUR);
200
      DistortedEffects.enableEffect(EffectName.BLUR);
208 201

  
209 202
      try
210 203
        {

Also available in: Unified diff