FileDocCategorySizeDatePackage
TouchHandler.javaAPI DocAndroid 5.1 API3145Thu Mar 12 22:22:44 GMT 2015com.android.testapp

TouchHandler

public class TouchHandler extends Object

Fields Summary
private static String
TAG
float
mLastX
float
mLastY
float
mRotateXValue
float
mRotateYValue
android.renderscript.Float3
mDistValue
android.renderscript.Float3
mPosValue
CompoundTransform
mCameraRig
com.android.scenegraph.CompoundTransform.RotateComponent
mRotateX
com.android.scenegraph.CompoundTransform.RotateComponent
mRotateY
com.android.scenegraph.CompoundTransform.TranslateComponent
mDist
com.android.scenegraph.CompoundTransform.TranslateComponent
mPosition
Camera
mCamera
Constructors Summary
Methods Summary
public CameragetCamera()

        return mCamera;
    
public voidinit(Scene scene)


        
        // Some initial values for camera position
        mRotateXValue = -20;
        mRotateYValue = 0;
        mDistValue = new Float3(0, 0, 45);
        mPosValue = new Float3(0, 4, 0);

        // Make a camera transform we can manipulate
        mCameraRig = scene.appendNewCompoundTransform();
        mCameraRig.setName("CameraRig");

        mPosition = mCameraRig.addTranslate("Position", mPosValue);
        mRotateY  = mCameraRig.addRotate("RotateY", new Float3(0, 1, 0), mRotateYValue);
        mRotateX  = mCameraRig.addRotate("RotateX", new Float3(1, 0, 0), mRotateXValue);
        mDist     = mCameraRig.addTranslate("Distance", mDistValue);

        mCamera = scene.appendNewCamera();
        mCamera.setTransform(mCameraRig);
    
public voidonActionDown(float x, float y)

        mLastX = x;
        mLastY = y;
    
public voidonActionMove(float x, float y)

        if (mRotateX == null) {
            return;
        }

        float dx = mLastX - x;
        float dy = mLastY - y;

        if (Math.abs(dy) <= 2.0f) {
            dy = 0.0f;
        }
        if (Math.abs(dx) <= 2.0f) {
            dx = 0.0f;
        }

        mRotateYValue += dx * 0.25f;
        mRotateYValue %= 360.0f;

        mRotateXValue  += dy * 0.25f;
        mRotateXValue  = Math.max(mRotateXValue , -80.0f);
        mRotateXValue  = Math.min(mRotateXValue , 0.0f);

        mRotateX.setAngle(mRotateXValue);
        mRotateY.setAngle(mRotateYValue);

        mLastX = x;
        mLastY = y;
    
public voidonActionScale(float scale)

        if (mDist == null) {
            return;
        }
        mDistValue.z *= 1.0f / scale;
        mDistValue.z = Math.max(10.0f, Math.min(mDistValue.z, 150.0f));
        mDist.setValue(mDistValue);