Revision 62c869ad
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/library/effect/MatrixEffectScale.java | ||
---|---|---|
46 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
47 | 47 |
/** |
48 | 48 |
* Only for use by the library itself. |
49 |
* <p> |
|
50 |
* Here and in Shear we have the whole reason why there are two separate 'P' and 'V' (Point and |
|
51 |
* Vector) matrices - Scale and Shear have to manipulate Points and Normal Vectors differently. |
|
52 |
* |
|
53 |
* Points get multiplied by (sx,sy,sz) - and vectors by (1/sx,1/sy,1/sz) (think about it!) - or |
|
54 |
* better by sx*sy*sz*(1/sx,1/sy,1/sz) to avoid dividing my zero (vectors are normalized after) |
|
49 | 55 |
* |
50 | 56 |
* @y.exclude |
51 | 57 |
*/ |
52 |
public void apply(float[] matrix, float[] uniforms, int index) |
|
58 |
public void apply(float[] matrixP, float[] matrixV, float[] uniforms, int index)
|
|
53 | 59 |
{ |
54 | 60 |
float sx = uniforms[NUM_UNIFORMS*index ]; |
55 | 61 |
float sy = uniforms[NUM_UNIFORMS*index+1]; |
56 | 62 |
float sz = uniforms[NUM_UNIFORMS*index+2]; |
57 | 63 |
|
58 |
Matrix.scaleM(matrix, 0, sx, sy, sz); |
|
64 |
Matrix.scaleM(matrixP, 0, sx, sy, sz); |
|
65 |
Matrix.scaleM(matrixV, 0, sy*sz, sx*sz, sx*sy); |
|
59 | 66 |
} |
60 | 67 |
|
61 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Fix normals in case of MatrixEffectScale / Shear.
Fix displaying the normal vector.