Project

General

Profile

« Previous | Next » 

Revision 7bebb196

Added by Leszek Koltunski over 5 years ago

Massive: make the coordinate system agree with that of OpenGL (i.e. invert the Y axis).

View differences:

src/main/java/org/distorted/library/effect/MatrixEffectMove.java
54 54
    float sy = uniforms[NUM_UNIFORMS*index+1];
55 55
    float sz = uniforms[NUM_UNIFORMS*index+2];
56 56

  
57
    Matrix.translateM(matrix, 0, sx,-sy, sz);
57
    Matrix.translateM(matrix, 0, sx, sy, sz);
58 58
    }
59 59

  
60 60
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effect/MatrixEffectQuaternion.java
65 65
    float y = uniforms[NUM_UNIFORMS*index+5];
66 66
    float z = uniforms[NUM_UNIFORMS*index+6];
67 67

  
68
    Matrix.translateM(matrix, 0, x,-y,-z);
68
    Matrix.translateM(matrix, 0, x, y, z);
69 69
    multiplyByQuat( matrix, qX, qY, qZ, qW);
70
    Matrix.translateM(matrix, 0,-x, y, z);
70
    Matrix.translateM(matrix, 0,-x,-y,-z);
71 71
    }
72 72

  
73 73
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effect/MatrixEffectRotate.java
63 63
    float y = uniforms[NUM_UNIFORMS*index+5];
64 64
    float z = uniforms[NUM_UNIFORMS*index+6];
65 65

  
66
    Matrix.translateM(matrix, 0, x,-y,-z);
66
    Matrix.translateM(matrix, 0, x, y, z);
67 67
    Matrix.rotateM( matrix, 0, alpha, axisX, axisY, axisZ);
68
    Matrix.translateM(matrix, 0,-x, y, z);
68
    Matrix.translateM(matrix, 0,-x,-y,-z);
69 69
    }
70 70

  
71 71
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effect/MatrixEffectShear.java
59 59
    float y  = uniforms[NUM_UNIFORMS*index+5];
60 60
    float z  = uniforms[NUM_UNIFORMS*index+6];
61 61

  
62
    Matrix.translateM(matrix, 0, x,-y, z);
62
    Matrix.translateM(matrix, 0, x, y, z);
63 63

  
64 64
    matrix[4] += sx*matrix[0]; // Multiply viewMatrix by 1 x 0 0 , i.e. X-shear.
65 65
    matrix[5] += sx*matrix[1]; //                        0 1 0 0
......
76 76
    matrix[6] += sz*matrix[10];//                        0 z 1 0
77 77
    matrix[7] += sz*matrix[11];//                        0 0 0 1
78 78

  
79
    Matrix.translateM(matrix, 0,-x, y, -z);
79
    Matrix.translateM(matrix, 0,-x,-y,-z);
80 80
    }
81 81

  
82 82
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effect/VertexEffectDeform.java
42 42
    {
43 43
    mCenter.get(uniforms,index+CENTER_OFFSET,currentDuration,step);
44 44
    mRegion.get(uniforms,index+REGION_OFFSET,currentDuration,step);
45
    boolean ret = mVector.get(uniforms,index,currentDuration,step);
46

  
47
    uniforms[index+REGION_OFFSET+1] =-uniforms[index+REGION_OFFSET+1];  // region's y
48

  
49
    return ret;
45
    return mVector.get(uniforms,index,currentDuration,step);
50 46
    }
51 47

  
52 48
///////////////////////////////////////////////////////////////////////////////////////////////////
......
116 112
      + "const float C = 5.0; \n"
117 113

  
118 114
      + "vec3 center = vUniforms[effect+1].yzw; \n"
119
      + "vec3 ps     = center-v.xyz; \n"
115
      + "vec3 ps     = center-v; \n"
120 116
      + "vec3 aPS    = abs(ps); \n"
121 117
      + "vec3 maxps  = u_objD + abs(center); \n"
122 118
      + "float d     = degree_region(vUniforms[effect+2],ps); \n"
......
135 131

  
136 132
      + "float mvXvert = -B * ps.x * aForce.y * (1.0-quot.y) * denomV; \n"     // impact the vertical   component of the force vector has on horizontal movement
137 133
      + "float mvYhorz = -B * ps.y * aForce.x * (1.0-quot.x) * denomH; \n"     // impact the horizontal component of the force vector has on vertical   movement
138
      + "float mvYvert =  force.y * (1.0-quot.x*Aw.x*denomV) * vertCorr.y; \n" // impact the vertical   component of the force vector has on vertical   movement
139
      + "float mvXhorz = -force.x * (1.0-quot.y*Aw.y*denomH) * vertCorr.x; \n" // impact the horizontal component of the force vector has on horizontal movement
134
      + "float mvYvert = force.y * (1.0-quot.x*Aw.x*denomV) * vertCorr.y; \n"  // impact the vertical   component of the force vector has on vertical   movement
135
      + "float mvXhorz = force.x * (1.0-quot.y*Aw.y*denomH) * vertCorr.x; \n"  // impact the horizontal component of the force vector has on horizontal movement
140 136

  
141
      + "v.x -= (mvXvert+mvXhorz); \n"
142
      + "v.y -= (mvYvert+mvYhorz); \n"
137
      + "v.x += (mvXvert+mvXhorz); \n"
138
      + "v.y += (mvYvert+mvYhorz); \n"
143 139

  
144 140
      + "v.z += force.z*d*d*(3.0*d*d -8.0*d +6.0); \n"                         // thick bubble
145 141
      + "float b = -(12.0*force.z*d*(1.0-d)*(1.0-d)*(1.0-d))*one_over_denom; \n"
src/main/java/org/distorted/library/effect/VertexEffectDistort.java
42 42
    {
43 43
    mCenter.get(uniforms,index+CENTER_OFFSET,currentDuration,step);
44 44
    mRegion.get(uniforms,index+REGION_OFFSET,currentDuration,step);
45
    boolean ret = mVector.get(uniforms,index,currentDuration,step);
46

  
47
    uniforms[index+1] =-uniforms[index+1];
48
    uniforms[index+REGION_OFFSET+1] =-uniforms[index+REGION_OFFSET+1];  // region's y
49

  
50
    return ret;
45
    return mVector.get(uniforms,index,currentDuration,step);
51 46
    }
52 47

  
53 48
///////////////////////////////////////////////////////////////////////////////////////////////////
......
113 108
    addEffect(EffectName.DISTORT,
114 109

  
115 110
        "vec3 center = vUniforms[effect+1].yzw; \n"
116
      + "vec3 ps = center-v.xyz; \n"
111
      + "vec3 ps = center-v; \n"
117 112
      + "vec3 force = vUniforms[effect].xyz; \n"
118 113
      + "float d = degree(vUniforms[effect+2],center,ps); \n"
119 114
      + "float denom = dot(ps+(1.0-d)*force,ps); \n"
src/main/java/org/distorted/library/effect/VertexEffectPinch.java
53 53
    boolean ret = mPinch.get(uniforms,index,currentDuration,step);
54 54

  
55 55
    uniforms[index+1] = (float)(Math.PI*uniforms[index+1]/180);
56
    uniforms[index+REGION_OFFSET+1] =-uniforms[index+REGION_OFFSET+1];  // region's y
57 56

  
58 57
    return ret;
59 58
    }
......
75 74
    addEffect(EffectName.PINCH,
76 75

  
77 76
        "vec3 center = vUniforms[effect+1].yzw; \n"
78
      + "vec3 ps = center-v.xyz; \n"
77
      + "vec3 ps = center-v; \n"
79 78
      + "float h = vUniforms[effect].x; \n"
80 79
      + "float t = degree(vUniforms[effect+2],center,ps) * (1.0-h)/max(1.0,h); \n"
81 80
      + "float angle = vUniforms[effect].y; \n"
src/main/java/org/distorted/library/effect/VertexEffectSink.java
45 45
    {
46 46
    mCenter.get(uniforms,index+CENTER_OFFSET,currentDuration,step);
47 47
    mRegion.get(uniforms,index+REGION_OFFSET,currentDuration,step);
48
    boolean ret = mSink.get(uniforms,index,currentDuration,step);
49

  
50
    uniforms[index+REGION_OFFSET+1] =-uniforms[index+REGION_OFFSET+1];  // region's y
51

  
52
    return ret;
48
    return mSink.get(uniforms,index,currentDuration,step);
53 49
    }
54 50

  
55 51
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
51 51
    mRegion.get(uniforms,index+REGION_OFFSET,currentDuration,step);
52 52
    boolean ret = mSwirl.get(uniforms,index,currentDuration,step);
53 53

  
54
    uniforms[index  ] = (float)(Math.PI*uniforms[index]/180);
55
    uniforms[index+REGION_OFFSET+1] =-uniforms[index+REGION_OFFSET+1];  // region's y
54
    uniforms[index] = (float)(Math.PI*uniforms[index]/180);
56 55

  
57 56
    return ret;
58 57
    }
src/main/java/org/distorted/library/effect/VertexEffectWave.java
54 54
    uniforms[index+3] = (float)(Math.PI*uniforms[index+3]/180);
55 55
    uniforms[index+4] = (float)(Math.PI*uniforms[index+4]/180);
56 56

  
57
    uniforms[index+REGION_OFFSET+1] =-uniforms[index+REGION_OFFSET+1];  // region's y
58

  
59 57
    return ret;
60 58
    }
61 59

  
......
136 134
      + "float amplitude = vUniforms[effect  ].x; \n"
137 135
      + "float length    = vUniforms[effect  ].y; \n"
138 136

  
139
      + "vec3 ps = center - v.xyz; \n"
137
      + "vec3 ps = center - v; \n"
140 138
      + "float deg = amplitude*degree_region(vUniforms[effect+2],ps); \n"
141 139

  
142 140
      + "if( deg != 0.0 && length != 0.0 ) \n"
src/main/java/org/distorted/library/main/DistortedScreen.java
54 54
  private long lastTime=0;
55 55
  private long[] durations;
56 56
  private int currDuration;
57
  private static MatrixEffectMove mMoveEffect = new MatrixEffectMove( new Static3D(5,5,0) );
57
  private static Static3D mMoveVector = new Static3D(5,-5,0);
58
  private static MatrixEffectMove mMoveEffect = new MatrixEffectMove(mMoveVector);
58 59
  ///// END DEBUGGING //////////////////////////
59 60

  
60 61
  private int mCurRenderedFBO;    // During the first FBO_QUEUE_SIZE frames, we blit the very first
......
106 107
      fpsCanvas.drawText(fpsString, FPS_W/2, 0.75f*FPS_H, mPaint);
107 108
      fpsTexture.setTexture(fpsBitmap);
108 109

  
110
      mMoveVector.set2(mHeight-FPS_H-5);
111

  
109 112
      lastTime = time;
110 113
      }
111 114

  
......
173 176
      durations = new long[NUM_FRAMES + 1];
174 177
      currDuration = 0;
175 178

  
176
      for (int i = 0; i < NUM_FRAMES + 1; i++) durations[i] = 16;  // Assume FPS will be
177
      durations[NUM_FRAMES] = NUM_FRAMES * 16;              // close to 1000/16 ~ 60
179
      for (int i=0; i<NUM_FRAMES+1; i++) durations[i] = 16;  // Assume FPS will be
180
      durations[NUM_FRAMES] = NUM_FRAMES * 16;               // close to 1000/16 ~ 60
178 181
      }
179 182
    }
180 183
  }
src/main/java/org/distorted/library/main/EffectQueueFragment.java
78 78
          }
79 79
        }
80 80

  
81
      mUniforms[NUM_UNIFORMS*i+5] = mUniforms[NUM_UNIFORMS*i+5]-halfX;
82
      mUniforms[NUM_UNIFORMS*i+6] =-mUniforms[NUM_UNIFORMS*i+6]+halfY;
83
      mUniforms[NUM_UNIFORMS*i+7] = mUniforms[NUM_UNIFORMS*i+7]-halfZ;
81
      mUniforms[NUM_UNIFORMS*i+5] -= halfX;
82
      mUniforms[NUM_UNIFORMS*i+6] -= halfY;
83
      mUniforms[NUM_UNIFORMS*i+7] -= halfZ;
84 84
      }
85 85

  
86 86
    mTime = currTime;  
src/main/java/org/distorted/library/main/EffectQueueMatrix.java
154 154
  void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ, int variant)
155 155
    {
156 156
    Matrix.setIdentityM(mViewMatrix, 0);
157
    Matrix.translateM(mViewMatrix, 0, -projection.mWidth/2, projection.mHeight/2, -projection.mDistance);
157
    Matrix.translateM(mViewMatrix, 0, -projection.mWidth/2, -projection.mHeight/2, -projection.mDistance);
158 158
    float mipmap = projection.mMipmap;
159 159
    if( mipmap!=1 ) Matrix.scaleM(mViewMatrix, 0, mipmap, mipmap, mipmap);
160 160

  
161 161
    for(int i=0; i<mNumEffects; i++) ((MatrixEffect)mEffects[i]).apply(mViewMatrix,mUniforms,i);
162 162

  
163
    Matrix.translateM(mViewMatrix, 0, halfX,-halfY,-halfZ);
163
    Matrix.translateM(mViewMatrix, 0, halfX,halfY,halfZ);
164 164
    Matrix.multiplyMM(mMVPMatrix, 0, projection.mProjectionMatrix, 0, mViewMatrix, 0);
165 165

  
166 166
    GLES31.glUniform3f( mObjDH[variant] , halfX, halfY, halfZ);
src/main/java/org/distorted/library/main/EffectQueueVertex.java
80 80
          }
81 81
        }
82 82

  
83
      mUniforms[NUM_UNIFORMS*i+5] = mUniforms[NUM_UNIFORMS*i+5]-halfX;
84
      mUniforms[NUM_UNIFORMS*i+6] =-mUniforms[NUM_UNIFORMS*i+6]+halfY;
85
      mUniforms[NUM_UNIFORMS*i+7] = mUniforms[NUM_UNIFORMS*i+7]-halfZ;
83
      mUniforms[NUM_UNIFORMS*i+5] -= halfX;
84
      mUniforms[NUM_UNIFORMS*i+6] -= halfY;
85
      mUniforms[NUM_UNIFORMS*i+7] -= halfZ;
86 86
      }
87 87

  
88 88
    mTime = currTime;

Also available in: Unified diff