Android 旋转曲面视图

Android 旋转曲面视图,android,opengl-es,rotation,glsurfaceview,Android,Opengl Es,Rotation,Glsurfaceview,我正在GLSURFACHEVIEW上显示2D图像,并希望以特定角度旋转它(即180度、75360度…) 我在touch事件中编写了以下代码。(这里GPUImageView扩展了GLSurfaceView),我从处理两个手指旋转手势的旋转手势检测器类中获取可变旋转度的值。下面的代码旋转GlsFaceView,但GlsFaceView中显示的内容/图像保持不变(不在其中旋转)。android有一些例子,但它们是针对3D的,而不是随度旋转 @Override public boolea

我正在GLSURFACHEVIEW上显示2D图像,并希望以特定角度旋转它(即180度、75360度…)

我在touch事件中编写了以下代码。(这里GPUImageView扩展了GLSurfaceView),我从处理两个手指旋转手势的旋转手势检测器类中获取可变旋转度的值。下面的代码旋转GlsFaceView,但GlsFaceView中显示的内容/图像保持不变(不在其中旋转)。android有一些例子,但它们是针对3D的,而不是随度旋转

    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
        rotationDetector.onTouchEvent(event);
        /* Rotate View Here */
        GPUImageView.this.setRotation(rotationDegree);
        requestRender();
        return true;
    }
我有一个自定义的旋转检测器类,它发送与两个手指旋转相关的事件

    private class RotateListener extends RotateGestureDetector.SimpleOnRotateGestureListener
    {
        @Override
        public boolean onRotate(RotateGestureDetector detector)
        {
            rotationDegree -= detector.getRotationDegreesDelta();
            return true;
        }
    }

也可以通过ModelMatrix旋转曲面视图

onDrawFrame()
{
Matrix.tramslateM(yourModelMatrix,offsetValue,translationInx,translationInY,translationInZ);
Matrix.rotateM(yourModelMatrix,offsetValue,andgle in degrees,inDirectionX,inDirectioY,inDirectionZ);
}

实际设置旋转度的代码在哪里?在您为这个特定函数显示的代码中,它是常量。我添加了如何修改rotationDegree变量的代码。rotationDegree是一个变量,当我的自定义RotationGestureDetector类检测到两个手指旋转时,它会被修改。正如我所说,旋转工作正常,但它只旋转外部视图,内部内容保持在相同的位置。你能用更多的代码解释它吗?因为我不是OpenGL背景,需要更多的代码如何使用modelMatrix和操纵您在此处显示的代码。在GLSURFACHEVIEW代码中,如果您有Renderer类,则必须使用一些参数覆盖三个方法,即OnSurfaeChanged()、onSurfaceCreated()和onDrawFrame()。我已在此代码中向您展示了GL曲面视图屏幕旋转和平移的代码。