package com.bn.planeModel; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.util.ArrayList; import android.opengl.GLES20; import com.bn.core.MatrixState; /* * 创建椭球体类 顶点和纹理 * 用于绘制机身,机头和机舱 */ public class DrawSpheroid { int mProgram;//自定义渲染管线着色器程序id int muMVPMatrixHandle;//总变换矩阵引用id int maPositionHandle; //顶点位置属性引用id int maTexCoorHandle; //顶点纹理坐标属性引用id String mVertexShader;//顶点着色器代码脚本 String mFragmentShader;//片元着色器代码脚本 private FloatBuffer mVertexBuffer;//顶点坐标数据缓冲 private FloatBuffer mTextureBuffer;//纹理缓冲 public float mAngleX;//沿x轴旋转角度 public float mAngleY;//沿y轴旋转角度 public float mAngleZ;//沿z轴旋转角度 int vCount=0; float a; float b; //三轴半径长 float c; float angleSpan;//将球进行单位切分的角度 float hAngleBegin;//经度绘制起始角度 float hAngleOver;//经度绘制结束角度 float vAngleBegin;//纬度绘制起始角度 float vAngleOver;//纬度绘制结束角度 //hAngle表示经度,vAngle表示纬度。 public DrawSpheroid(float a,float b,float c,float angleSpan, float hAngleBegin,float hAngleOver,float vAngleBegin,float vAngleOver,int mProgram) { this.a=a; this.b=b; this.c=c; this.hAngleBegin=hAngleBegin; this.hAngleOver=hAngleOver; this.vAngleBegin=vAngleBegin; this.vAngleOver=vAngleOver; this.mProgram=mProgram; this.angleSpan=angleSpan; initVertexData(); initShader(); } //初始化顶点的信息 public void initVertexData() { ArrayList alVertix=new ArrayList();//存放顶点坐标 for(float vAngle=vAngleBegin;vAngle