Revision 7490d738
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/library/effectqueue/EffectQueueMatrix.java | ||
---|---|---|
34 | 34 |
private static final int NUM_UNIFORMS = MatrixEffect.NUM_UNIFORMS; |
35 | 35 |
private static final int INDEX = EffectType.MATRIX.ordinal(); |
36 | 36 |
|
37 |
private static float[] mMVPMatrix = new float[16]; |
|
38 |
private static float[] mViewMatrix= new float[16];
|
|
37 |
private static float[] mMVPMatrix = new float[16];
|
|
38 |
private static float[] mModelViewMatrix = new float[16];
|
|
39 | 39 |
|
40 | 40 |
private static int[] mBoundingH = new int[MAIN_VARIANTS]; |
41 | 41 |
private static int[] mStretchH = new int[MAIN_VARIANTS]; |
... | ... | |
91 | 91 |
|
92 | 92 |
mTmpPoint[3] = 1.0f; |
93 | 93 |
|
94 |
Matrix.multiplyMM(mTmpMatrix, 0, projection, 0, mViewMatrix, 0); |
|
94 |
Matrix.multiplyMM(mTmpMatrix, 0, projection, 0, mModelViewMatrix, 0);
|
|
95 | 95 |
|
96 | 96 |
float halfX = mesh.getBoundingX(); |
97 | 97 |
float halfY = mesh.getBoundingY(); |
... | ... | |
152 | 152 |
|
153 | 153 |
void send(float distance, float mipmap, float[] projection, MeshBase mesh, int variant) |
154 | 154 |
{ |
155 |
Matrix.setIdentityM(mViewMatrix, 0); |
|
156 |
Matrix.translateM(mViewMatrix, 0, 0,0, -distance); |
|
155 |
Matrix.setIdentityM(mModelViewMatrix, 0); |
|
157 | 156 |
|
158 |
if( mipmap!=1 ) Matrix.scaleM(mViewMatrix, 0, mipmap, mipmap, mipmap); |
|
157 |
// The 'View' part of the MV matrix |
|
158 |
Matrix.translateM(mModelViewMatrix, 0, 0,0, -distance); |
|
159 |
if( mipmap!=1 ) Matrix.scaleM(mModelViewMatrix, 0, mipmap, mipmap, mipmap); |
|
159 | 160 |
|
160 |
for(int i=mNumEffects-1; i>=0; i--) ((MatrixEffect)mEffects[i]).apply(mViewMatrix,mUniforms,i); |
|
161 |
Matrix.multiplyMM(mMVPMatrix, 0, projection, 0, mViewMatrix, 0); |
|
161 |
// the 'Model' part of the MV matrix |
|
162 |
for(int i=mNumEffects-1; i>=0; i--) ((MatrixEffect)mEffects[i]).apply(mModelViewMatrix,mUniforms,i); |
|
163 |
|
|
164 |
// combined Model-View-Projection matrix |
|
165 |
Matrix.multiplyMM(mMVPMatrix, 0, projection, 0, mModelViewMatrix, 0); |
|
162 | 166 |
|
163 | 167 |
GLES31.glUniform3f( mBoundingH[variant] , mesh.getBoundingX(), mesh.getBoundingY(), mesh.getBoundingZ()); |
164 | 168 |
GLES31.glUniform3f( mStretchH[variant] , mesh.getStretchX() , mesh.getStretchY() , mesh.getStretchZ() ); |
165 |
GLES31.glUniformMatrix4fv(mMVMatrixH[variant] , 1, false, mViewMatrix, 0); |
|
166 |
GLES31.glUniformMatrix4fv(mMVPMatrixH[variant], 1, false, mMVPMatrix , 0); |
|
169 |
GLES31.glUniformMatrix4fv(mMVMatrixH[variant] , 1, false, mModelViewMatrix, 0);
|
|
170 |
GLES31.glUniformMatrix4fv(mMVPMatrixH[variant], 1, false, mMVPMatrix , 0);
|
|
167 | 171 |
} |
168 | 172 |
} |
Also available in: Unified diff
Fixes for the Projection matrix, FOV.
There was a confusion between the Projection of the Node onto the Screen, and the Projection of the Cubits on the Node.