我已经绘制了 3D 对象。现在我想做放大/缩小并通过 2 个手指手势移动对象。
我检查了许多链接来做手势,opengl
但没有得到太多帮助。
代码:
@Override
public boolean onTouchEvent(MotionEvent event) {
//
float x = event.getX();
float y = event.getY();
//If a touch is moved on the screen
if(event.getAction() == MotionEvent.ACTION_MOVE) {
//Calculate the change
float dx = x - oldX;
float dy = y - oldY;
//Define an upper area of 10% on the screen
int upperArea = this.getHeight() / 10;
//Zoom in/out if the touch move has been made in the upper
if(y < upperArea) {
z -= dx * TOUCH_SCALE / 2;
//Rotate around the axis otherwise
} else {
xrot += dy * TOUCH_SCALE;
yrot += dx * TOUCH_SCALE;
}
//A press on the screen
} else if(event.getAction() == MotionEvent.ACTION_UP) {
}
//Remember the values
oldX = x;
oldY = y;
//We handled the event
return true;
}
请帮助我提前谢谢。