Revision faa3ff56
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/effect/MatrixEffectRotate.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.type.Data3D; |
26 | 26 |
|
27 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
28 |
|
|
28 |
/** |
|
29 |
* Rotate the Mesh by 'angle' degrees around the center, along an axis. |
|
30 |
*/ |
|
29 | 31 |
public class MatrixEffectRotate extends MatrixEffect |
30 | 32 |
{ |
31 | 33 |
private Data1D mAngle; |
... | ... | |
33 | 35 |
|
34 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 37 |
/** |
36 |
* Rotates the Object by 'angle' degrees around the center. |
|
37 |
* Static axis of rotation is given by the last parameter. |
|
38 |
* Only for use by the library itself. |
|
38 | 39 |
* |
39 |
* @param angle Angle that we want to rotate the Object to. Unit: degrees |
|
40 |
* @param axis Axis of rotation |
|
41 |
* @param center Coordinates of the Point we are rotating around. |
|
40 |
* @y.exclude |
|
42 | 41 |
*/ |
43 |
public MatrixEffectRotate(Data1D angle, Data3D axis, Data3D center) |
|
44 |
{ |
|
45 |
super(EffectName.ROTATE); |
|
46 |
mAngle = angle; |
|
47 |
mAxis = axis; |
|
48 |
mCenter = center; |
|
49 |
} |
|
50 |
|
|
51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
52 |
|
|
53 | 42 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
54 | 43 |
{ |
55 | 44 |
mCenter.get(uniforms,index+4,currentDuration,step); |
... | ... | |
58 | 47 |
} |
59 | 48 |
|
60 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 |
|
|
50 |
/** |
|
51 |
* Only for use by the library itself. |
|
52 |
* |
|
53 |
* @y.exclude |
|
54 |
*/ |
|
62 | 55 |
public void apply(float[] matrix, float[] uniforms, int index) |
63 | 56 |
{ |
64 | 57 |
float alpha = uniforms[NUM_UNIFORMS*index ]; |
... | ... | |
74 | 67 |
Matrix.rotateM( matrix, 0, alpha, axisX, axisY, axisZ); |
75 | 68 |
Matrix.translateM(matrix, 0,-x, y,-z); |
76 | 69 |
} |
70 |
|
|
71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
72 |
// PUBLIC API |
|
73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
74 |
/** |
|
75 |
* Rotate the Mesh by 'angle' degrees around the center, along an axis. |
|
76 |
* |
|
77 |
* @param angle Angle that we want to rotate the Object to. Unit: degrees |
|
78 |
* @param axis Axis of rotation |
|
79 |
* @param center Coordinates of the Point we are rotating around. |
|
80 |
*/ |
|
81 |
public MatrixEffectRotate(Data1D angle, Data3D axis, Data3D center) |
|
82 |
{ |
|
83 |
super(EffectName.ROTATE); |
|
84 |
mAngle = angle; |
|
85 |
mAxis = axis; |
|
86 |
mCenter = center; |
|
87 |
} |
|
77 | 88 |
} |
Also available in: Unified diff
Javadoc.