Revision faa3ff56
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/effect/MatrixEffectShear.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Data3D; |
25 | 25 |
|
26 | 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
27 |
|
|
27 |
/** |
|
28 |
* Shear the Mesh. |
|
29 |
*/ |
|
28 | 30 |
public class MatrixEffectShear extends MatrixEffect |
29 | 31 |
{ |
30 | 32 |
private Data3D mShear, mCenter; |
31 | 33 |
|
32 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
33 | 35 |
/** |
34 |
* Shears the Object.
|
|
36 |
* Only for use by the library itself.
|
|
35 | 37 |
* |
36 |
* @param shear The 3-tuple of shear factors. The first controls level |
|
37 |
* of shearing in the X-axis, second - Y-axis and the third - |
|
38 |
* Z-axis. Each is the tangens of the shear angle, i.e 0 - |
|
39 |
* no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc. |
|
40 |
* @param center Center of shearing, i.e. the point which stays unmoved. |
|
38 |
* @y.exclude |
|
41 | 39 |
*/ |
42 |
public MatrixEffectShear(Data3D shear, Data3D center) |
|
43 |
{ |
|
44 |
super(EffectName.SHEAR); |
|
45 |
mShear = shear; |
|
46 |
mCenter = center; |
|
47 |
} |
|
48 |
|
|
49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
50 |
|
|
51 | 40 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
52 | 41 |
{ |
53 | 42 |
mCenter.get(uniforms,index+4,currentDuration,step); |
... | ... | |
55 | 44 |
} |
56 | 45 |
|
57 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
58 |
|
|
47 |
/** |
|
48 |
* Only for use by the library itself. |
|
49 |
* |
|
50 |
* @y.exclude |
|
51 |
*/ |
|
59 | 52 |
public void apply(float[] matrix, float[] uniforms, int index) |
60 | 53 |
{ |
61 | 54 |
float sx = uniforms[NUM_UNIFORMS*index ]; |
... | ... | |
85 | 78 |
|
86 | 79 |
Matrix.translateM(matrix, 0,-x, y, -z); |
87 | 80 |
} |
81 |
|
|
82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
83 |
// PUBLIC API |
|
84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
85 |
/** |
|
86 |
* Shear the Mesh. |
|
87 |
* |
|
88 |
* @param shear The 3-tuple of shear factors. The first controls level |
|
89 |
* of shearing in the X-axis, second - Y-axis and the third - |
|
90 |
* Z-axis. Each is the tangens of the shear angle, i.e 0 - |
|
91 |
* no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc. |
|
92 |
* @param center Center of shearing, i.e. the point which stays unmoved. |
|
93 |
*/ |
|
94 |
public MatrixEffectShear(Data3D shear, Data3D center) |
|
95 |
{ |
|
96 |
super(EffectName.SHEAR); |
|
97 |
mShear = shear; |
|
98 |
mCenter = center; |
|
99 |
} |
|
88 | 100 |
} |
Also available in: Unified diff
Javadoc.