Revision 23b733db
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/library/effectqueue/EffectQueueMatrix.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import org.distorted.library.effect.EffectType; |
26 | 26 |
import org.distorted.library.effect.MatrixEffect; |
27 |
import org.distorted.library.mesh.MeshBase; |
|
27 | 28 |
import org.distorted.library.message.EffectMessageSender; |
28 | 29 |
|
29 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
36 | 37 |
private static float[] mMVPMatrix = new float[16]; |
37 | 38 |
private static float[] mViewMatrix= new float[16]; |
38 | 39 |
|
39 |
private static int[] mObjDH = new int[MAIN_VARIANTS]; |
|
40 |
private static int[] mBoundingH = new int[MAIN_VARIANTS]; |
|
41 |
private static int[] mStretchH = new int[MAIN_VARIANTS]; |
|
40 | 42 |
private static int[] mMVPMatrixH = new int[MAIN_VARIANTS]; |
41 | 43 |
private static int[] mMVMatrixH = new int[MAIN_VARIANTS]; |
42 | 44 |
|
... | ... | |
56 | 58 |
|
57 | 59 |
static void uniforms(int mProgramH, int variant) |
58 | 60 |
{ |
59 |
mObjDH[variant] = GLES31.glGetUniformLocation(mProgramH, "u_objD"); |
|
61 |
mBoundingH[variant] = GLES31.glGetUniformLocation(mProgramH, "u_Bounding"); |
|
62 |
mStretchH[variant] = GLES31.glGetUniformLocation(mProgramH, "u_Stretch"); |
|
60 | 63 |
mMVPMatrixH[variant]= GLES31.glGetUniformLocation(mProgramH, "u_MVPMatrix"); |
61 | 64 |
mMVMatrixH[variant] = GLES31.glGetUniformLocation(mProgramH, "u_MVMatrix"); |
62 | 65 |
} |
... | ... | |
79 | 82 |
// return a float which describes how much larger an object must be so that it appears to be (about) |
80 | 83 |
// 'marginInPixels' pixels larger in each direction. Used in Postprocessing. |
81 | 84 |
|
82 |
float magnify(float[] projection, int width, int height, float mipmap, float halfX, float halfY, float halfZ, float marginInPixels)
|
|
85 |
float magnify(float[] projection, int width, int height, float mipmap, MeshBase mesh, float marginInPixels)
|
|
83 | 86 |
{ |
84 | 87 |
mMinX = Integer.MAX_VALUE; |
85 | 88 |
mMaxX = Integer.MIN_VALUE; |
... | ... | |
90 | 93 |
|
91 | 94 |
Matrix.multiplyMM(mTmpMatrix, 0, projection, 0, mViewMatrix, 0); |
92 | 95 |
|
96 |
float halfX = mesh.getBoundingX(); |
|
97 |
float halfY = mesh.getBoundingY(); |
|
98 |
float halfZ = mesh.getBoundingZ(); |
|
99 |
|
|
93 | 100 |
mTmpPoint[0] = +halfX; mTmpPoint[1] = +halfY; mTmpPoint[2] = +halfZ; magnifyDir(); |
94 | 101 |
mTmpPoint[0] = +halfX; mTmpPoint[1] = +halfY; mTmpPoint[2] = -halfZ; magnifyDir(); |
95 | 102 |
mTmpPoint[0] = +halfX; mTmpPoint[1] = -halfY; mTmpPoint[2] = +halfZ; magnifyDir(); |
... | ... | |
143 | 150 |
|
144 | 151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
145 | 152 |
|
146 |
void send(float distance, float mipmap, float[] projection, float halfX, float halfY, float halfZ, int variant)
|
|
153 |
void send(float distance, float mipmap, float[] projection, MeshBase mesh, int variant)
|
|
147 | 154 |
{ |
148 | 155 |
Matrix.setIdentityM(mViewMatrix, 0); |
149 | 156 |
Matrix.translateM(mViewMatrix, 0, 0,0, -distance); |
... | ... | |
153 | 160 |
for(int i=mNumEffects-1; i>=0; i--) ((MatrixEffect)mEffects[i]).apply(mViewMatrix,mUniforms,i); |
154 | 161 |
Matrix.multiplyMM(mMVPMatrix, 0, projection, 0, mViewMatrix, 0); |
155 | 162 |
|
156 |
GLES31.glUniform3f( mObjDH[variant] , halfX, halfY, halfZ); |
|
163 |
GLES31.glUniform3f( mBoundingH[variant] , mesh.getBoundingX(), mesh.getBoundingY(), mesh.getBoundingZ()); |
|
164 |
GLES31.glUniform3f( mStretchH[variant] , mesh.getStretchX() , mesh.getStretchY() , mesh.getStretchZ() ); |
|
157 | 165 |
GLES31.glUniformMatrix4fv(mMVMatrixH[variant] , 1, false, mViewMatrix, 0); |
158 | 166 |
GLES31.glUniformMatrix4fv(mMVPMatrixH[variant], 1, false, mMVPMatrix , 0); |
159 | 167 |
} |
Also available in: Unified diff
Further corrections.