Revision 833685d0
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/cubes/CubesSurfaceView.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
class CubesSurfaceView extends GLSurfaceView |
34 | 34 |
{ |
35 |
int mX, mY; |
|
36 |
CubesRenderer mRenderer; |
|
35 |
private int mX, mY;
|
|
36 |
private CubesRenderer mRenderer;
|
|
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
39 | 39 |
|
... | ... | |
109 | 109 |
float rz = mRenderer.mQuat2.getZ(); |
110 | 110 |
float rw = mRenderer.mQuat2.getW(); |
111 | 111 |
|
112 |
// This is quaternion multiplication. (tx.ty.tz.tw) |
|
113 |
// is now equal to (qx,qy,qz,qw)*(rx,ry,rz,rw) |
|
112 | 114 |
float tx = rw*qx - rz*qy + ry*qz + rx*qw; |
113 | 115 |
float ty = rw*qy + rz*qx + ry*qw - rx*qz; |
114 | 116 |
float tz = rw*qz + rz*qw - ry*qx + rx*qy; |
115 | 117 |
float tw = rw*qw - rz*qz - ry*qy - rx*qx; |
116 |
|
|
118 |
|
|
119 |
// The point of this is so that there are always |
|
120 |
// exactly 2 quaternions: Quat1 representing the rotation |
|
121 |
// accumulating only since the last screen touch, and Quat2 |
|
122 |
// which remembers the combined effect of all previous |
|
123 |
// swipes. |
|
124 |
// We cannot be accumulating an ever-growing list of quaternions |
|
125 |
// and add a new one every time user swipes the screen - there |
|
126 |
// is a limited number of slots in the EffectQueueMatrix! |
|
117 | 127 |
mRenderer.mQuat1.set(0f, 0f, 0f, 1f); |
118 | 128 |
mRenderer.mQuat2.set(tx, ty, tz, tw); |
119 | 129 |
|
Also available in: Unified diff
Progress with Vertex3D