• openGL es2.0 创建方向方体


    package com.gzdxid.utils;


    public class DrawCubeTextureLight {


    private DrawRectTextureLight frontRect = null;
    private DrawRectTextureLight leftRect = null;
    private DrawRectTextureLight bottomRect = null;
    private int flag;
    private float halfWidth;
    private float halfHeight;
    private float halfLength;
    final float tzz = 0.1f;
    final float tzs=0.0f;
    // flag==0:法线朝里;flag==1:法线朝外;
    public DrawCubeTextureLight(float width,float height,float length,int mProgram, int flag) {
    frontRect = new DrawRectTextureLight(width, height,mProgram);
    leftRect=new DrawRectTextureLight(height, length, mProgram);
    bottomRect=new DrawRectTextureLight(width, length, mProgram);
    this.flag = flag;
    this.halfWidth=width/2;
    this.halfHeight=height/2;
    this.halfLength=length/2;
    }


    // textureId:up-down-left-right-front-back
    public void drawSelf(int[] textureId) {
    switch (flag) {
    case 0:
    drawCube0(textureId);
    break;
    case 1:
    drawCube1(textureId);
    break;
    }
    }


    private void drawCube0(int[] textureId) {
    // TODO Auto-generated method stub
    // up
    MatrixState.pushMatrix();
    MatrixState.translate(0, halfHeight - tzz, 0);
    MatrixState.rotate(90, 1, 0, 0);
    bottomRect.drawSelf(textureId[0]);
    MatrixState.popMatrix();


    // down
    MatrixState.pushMatrix();
    MatrixState.translate(0, -halfHeight + tzz, 0);
    MatrixState.rotate(-90, 1, 0, 0);
    bottomRect.drawSelf(textureId[1]);
    MatrixState.popMatrix();


    // left
    MatrixState.pushMatrix();
    MatrixState.translate(-halfWidth + tzz, 0, 0);
    MatrixState.rotate(90, 0, 1, 0);
    leftRect.drawSelf(textureId[2]);
    MatrixState.popMatrix();


    // right
    MatrixState.pushMatrix();
    MatrixState.translate(halfWidth - tzz, 0, 0);
    MatrixState.rotate(-90, 0, 1, 0);
    leftRect.drawSelf(textureId[3]);
    MatrixState.popMatrix();


    // front
    MatrixState.pushMatrix();
    MatrixState.translate(0, 0, halfLength - tzz);
    MatrixState.rotate(180, 0, 1, 0);
    frontRect.drawSelf(textureId[4]);
    MatrixState.popMatrix();


    // back
    MatrixState.pushMatrix();
    MatrixState.translate(0, 0, -halfLength + tzz);
    frontRect.drawSelf(textureId[5]);
    MatrixState.popMatrix();


    }


    private void drawCube1(int[] textureId) {


    // up
    MatrixState.pushMatrix();
    MatrixState.translate(0, halfHeight - tzs, 0);
    MatrixState.rotate(-90, 1, 0, 0);
    bottomRect.drawSelf(textureId[0]);
    MatrixState.popMatrix();


    // down
    MatrixState.pushMatrix();
    MatrixState.translate(0, -halfHeight + tzs, 0);
    MatrixState.rotate(90, 1, 0, 0);
    bottomRect.drawSelf(textureId[1]);
    MatrixState.popMatrix();


    // left
    MatrixState.pushMatrix();
    MatrixState.translate(-halfWidth + tzs, 0, 0);
    MatrixState.rotate(-90, 0, 1, 0);
    leftRect.drawSelf(textureId[3]);
    MatrixState.popMatrix();


    // right
    MatrixState.pushMatrix();
    MatrixState.translate(halfWidth - tzs, 0, 0);
    MatrixState.rotate(90, 0, 1, 0);
    leftRect.drawSelf(textureId[2]);
    MatrixState.popMatrix();


    // front
    MatrixState.pushMatrix();
    MatrixState.translate(0, 0, halfLength - tzs);
    frontRect.drawSelf(textureId[4]);
    MatrixState.popMatrix();


    // back
    MatrixState.pushMatrix();
    MatrixState.translate(0, 0, -halfLength + tzs);
    MatrixState.rotate(180, 0, 1, 0);
    frontRect.drawSelf(textureId[5]);
    MatrixState.popMatrix();


    }


    }
  • 相关阅读:
    yaml文件执行后常见错误解决
    动态存储管理实战:GlusterFS
    Kubernetes角色访问控制RBAC和权限规则(Role+ClusterRole)
    Kubernetes 存储系统 Storage 介绍:PV,PVC,SC
    在容器中管理数据的两种方式
    k8s 如何关联pvc到特定的pv
    Mysqldump 的 的 6 大使用场景的导出命令
    Docker 容器日志管理
    k8s中节点级别的日志
    k8s中pod的容器日志查看命令
  • 原文地址:https://www.cnblogs.com/Anzhongliu/p/6092127.html
Copyright © 2020-2023  润新知