【问题标题】:Getting a ray for raypicking in openGL ES在 openGL ES 中获取用于光线拾取的光线
【发布时间】:2014-12-29 21:34:41
【问题描述】:

好的,所以我将此代码用于 opengl ES 的光线,但我遇到了错误

this.P0 = farCoOrds;
this.P1 = nearCoOrds;

在代码的最后。它说,

无法解析符号

代码如下:

public class Ray {
    public static float[] P0 = new float[3];
    public static float [] P1 = new float[3];
    public Ray(GL10 gl, int width, int height, float xTouch, float yTouch) {
        MatrixGrabber matrixGrabber = new MatrixGrabber();
        matrixGrabber.getCurrentState(gl);

        int[] viewport = {0, 0, width, height};

        float[] nearCoOrds = new float[3];
        float[] farCoOrds = new float[3];
        float[] temp = new float[4];
        float[] temp2 = new float[4];
        // get the near and far ords for the click
        float winx = xTouch, winy =(float)viewport[3] - yTouch;
    //        Log.d(TAG, "modelView is =" + Arrays.toString(matrixGrabber.mModelView));
    //        Log.d(TAG, "projection view is =" + Arrays.toString( matrixGrabber.mProjection ));

        int result = GLU.gluUnProject(winx, winy, 1.0f, matrixGrabber.mModelView, 0, 
    matrixGrabber.mProjection, 0, viewport, 0, temp, 0);

        Matrix.multiplyMV(temp2, 0, matrixGrabber.mModelView, 0, temp, 0);
        if(result == GL10.GL_TRUE){
            nearCoOrds[0] = temp2[0] / temp2[3];
            nearCoOrds[1] = temp2[1] / temp2[3];
            nearCoOrds[2] = temp2[2] / temp2[3];

        }

        result = GLU.gluUnProject(winx, winy, 0, matrixGrabber.mModelView, 0,    
    matrixGrabber.mProjection, 0, viewport, 0, temp, 0);
        Matrix.multiplyMV(temp2,0,matrixGrabber.mModelView, 0, temp, 0);
        if(result == GL10.GL_TRUE){
            farCoOrds[0] = temp2[0] / temp2[3];
            farCoOrds[1] = temp2[1] / temp2[3];
            farCoOrds[2] = temp2[2] / temp2[3];
        }
        this.P0 = farCoOrds;
        this.P1 = nearCoOrds;
    }   
}

有什么问题?

【问题讨论】:

  • P0P1 定义在哪里?
  • 这不是我想我要问的是他们应该被定义为什么。

标签: android opengl-es ray-picking


【解决方案1】:

未定义 P0 [] 和 P1 []。我将它们定义为 public static float[] P0 = new float[3] 和 public static float[] P1 = new float[3]。

【讨论】:

    猜你喜欢
    • 2012-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-13
    • 2016-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多