ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android – 无法在屏幕上绘制带Z轴的顶点

2019-07-01 22:11:26  阅读:162  来源: 互联网

标签:android opengl-es-2-0


我需要在屏幕上绘制几个坐标,没有显示Z轴的坐标,但是没有显示Z轴值的坐标.我尝试在绘制坐标之前对坐标进行标准化.归一化时,绘制所有坐标.但是在非标准化坐标的情况下,隐藏具有Z轴的顶点.

OpenGL版本:ES 2.0

坐标:

float squareCoords[] = {
            202.00002f, 244.00002f, 0.0f,
            440.00003f, 625.00006f, 0.0f,
            440.00003f, 625.00006f, 0.0f,
            690.00006f, 186.0f,0.0f,

            202.00002f, 244.00002f, 50.0f,
            440.00003f, 625.00006f, 50.0f,
            440.00003f, 625.00006f, 50.0f,
            690.00006f, 186.0f, 50.0f
    };

指数方面:

short[] drawOrder = {
            0,1,2,3,
            0,4,
            1,5,
            2,6,
            4,5,6,7
    };

绘制代码:

 GLES20.glDrawElements(
                GLES20.GL_LINES, drawOrder.length,
                GLES20.GL_UNSIGNED_SHORT, drawListBuffer);

在表面更改代码:

public void onSurfaceChanged(GL10 unused, int width, int height) {
        mWidth = width;
        mHeight = height;

        GLES20.glViewport(0, 0, mWidth, mHeight);

        float ratio = (float) mWidth / mHeight;

        // this projection matrix is applied to object coordinates
        // in the onDrawFrame() method
        Matrix.orthoM(mProjMatrix, 0, 0f, width, 0.0f, height, 0, 50);

    }

OnDraw的:

public void onDrawFrame(GL10 unused) {
        Square square = new Square();
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT|GLES20.GL_DEPTH_BUFFER_BIT);

        if (mFirstDraw)
            mFirstDraw = false;

        long time = SystemClock.uptimeMillis() % 4000L;
      float angle = 0.090f * ((int) time);
       // float angle = 90;
       // Matrix.setRotateM(mRotationMatrix, 0, angle, 0, 0, -1.0f);
       // angle += 0.7f;
        if (angle > 360f)
            angle = 0f;
        Matrix.setLookAtM(mVMatrix, 0, 0f, 0f, 4f, 0f, 0f, 0f, 0f, 1f, 0f);
        // projection x view = modelView
        Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);
        // Creating rotation matrix
        Matrix.setRotateM(rotationMatrix, 0, angle, -1f, 0f, 0f);

        // rotation x camera = modelView
        float[] duplicateMatrix = Arrays.copyOf(mMVPMatrix, 16);

        Matrix.multiplyMM(mMVPMatrix, 0, duplicateMatrix, 0, rotationMatrix, 0);

        square.draw(mMVPMatrix);
    }

我正在旋转图表来确定是否绘制了Z轴上的顶点.

我个人认为这条线是罪魁祸首,在这里我给了远值50和接近值0.我想知道这些值应该是什么

Matrix.orthoM(mProjMatrix, 0, 0f, width, 0.0f, height, 0, 50);

解决方法:

这里的问题是远远不够高的价值.我把它放到了500

Matrix.orthoM(mProjectionMatrix, 0, 0f, width, 0.0f, height,0, 500);

并将坐标更改为:

float squareCoords[] = {
            202.00002f, 244.00002f, 0.0f,
            440.00003f, 625.00006f, 0.0f,
            440.00003f, 625.00006f, 0.0f,
            690.00006f, 186.0f,0.0f,

            202.00002f, 244.00002f, 200.0f,
            440.00003f, 625.00006f, 200.0f,
            440.00003f, 625.00006f, 200.0f,
            690.00006f, 186.0f, 200.0f
    };

它现在正在工作.

标签:android,opengl-es-2-0
来源: https://codeday.me/bug/20190701/1351186.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有