Graphics Programs Reference
In-Depth Information
▪
Renderer class:
to render an object as well as expose the
rotate
matrix
(or related attributes like rotation angle) associated with
this object
▪
Main class:
to calculate the angle of rotation and update the
rotate
matrix
using it
Load the
TOUCH ROTATION
application into your workspace. It contains both
classes as described. You do not need to worry about the class
GLES20Renderer
at this stage; all that it does is:
▪ Renders a 3D object, which has a
rotate matrix
(_
RMatrix
) as-
sociated with it
▪ Exposes access to the field
_zAngle
, which stores the angle of
rotation to update the
rotate matrix
Figure 2-16
.
Rotating arrow with touch
The
Main
class implements a touch listener for calculating the ratio of the total ho-
rizontal distance moved to the width of the screen (inside its
onTouch
method).
Because of the default sensitivity settings, if this ratio is 1/2, the object performs a
complete rotation about the axis perpendicular to the screen. This class also contains
if
blocks to compare consecutive finger moves across the screen for clockwise and
anticlockwise rotations (please note that the finger has to be lifted before the next
swipe across the screen). The
_TOUCH_SENSITIVITY
and
_filterSensit-
Search WWH ::
Custom Search