package com.bn.Sample5_3;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import android.opengl.GLES20;
//颜色立方体
public class Cube
{
int mProgram;//自定义渲染管线着色器程序id
int muMVPMatrixHandle;//总变换矩阵引用
int maPositionHandle; //顶点位置属性引用
int maColorHandle; //顶点颜色属性引用
String mVertexShader;//顶点着色器代码脚本
String mFragmentShader;//片元着色器代码脚本
FloatBuffer mVertexBuffer;//顶点坐标数据缓冲
FloatBuffer mColorBuffer;//顶点着色数据缓冲
int vCount=0;
public Cube(MySurfaceView mv)
{
//初始化顶点坐标与着色数据
initVertexData();
//初始化shader
initShader(mv);
}
//初始化顶点坐标与着色数据的方法
public void initVertexData()
{
//顶点坐标数据的初始化================begin============================
vCount=12*6;
float vertices[]=new float[]
{
//前面
0,0,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
0,0,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
0,0,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
0,0,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
//后面
0,0,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
0,0,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
0,0,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
0,0,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
//左面
-Constant.UNIT_SIZE,0,0,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,0,0,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,0,0,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,0,0,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
//右面
Constant.UNIT_SIZE,0,0,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,0,0,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,0,0,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,0,0,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
//上面
0,Constant.UNIT_SIZE,0,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
0,Constant.UNIT_SIZE,0,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
0,Constant.UNIT_SIZE,0,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
0,Constant.UNIT_SIZE,0,
-Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
Constant.UNIT_SIZE,Constant.UNIT_SIZE,Constant.UNIT_SIZE,
//下面
0,-Constant.UNIT_SIZE,0,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
0,-Constant.UNIT_SIZE,0,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
0,-Constant.UNIT_SIZE,0,
-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
0,-Constant.UNIT_SIZE,0,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,-Constant.UNIT_SIZE,
Constant.UNIT_SIZE,-Constant.UNIT_SIZE,Constant.UNIT_SIZE,
};
//创建顶点坐标数据缓冲
//vertices.length*4是因为一个整数四个字节
ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length*4);
vbb.order(ByteOrder.nativeOrder());//设置字节顺序
mVertexBuffer = vbb.asFloatBuffer();//转换为Float型缓冲
mVertexBuffer.put(vertices);//向缓冲区中放入顶点坐标数据
mVertexBuffer.position(0);//设置缓冲区起始位置
//特别提示:由于不同平台字节顺序不同数据单元不是字节的一定要经过ByteBuffer
//转换,关键是要通过ByteOrder设置nativeOrder(),否则有可能会出问题
//顶点坐标数据的初始化================end============================
//顶点颜色值数组,每个顶点4个色彩值RGBA
float colors[]=new float[]{
//前面
1,1,1,0,//中间为白色
1,0,0,0,
1,0,0,0,
1,1,1,0,//中间为白色
1,0,0,0,
1,0,0,0,
1,1,1,0,//中间为白色
1,0,0,0,
1,0,0,0,
1,1,1,0,//中间为白色
1,0,0,0,
1,0,0,0,
//后面
1,1,1,0,//中间为白色
0,0,1,0,
0,0,1,0,
1,1,1,0,//中间为白色
0,0,1,0,
0,0,1,0,
1,1,1,0,//中间为白色
0,0,1,0,
0,0,1,0,
1,1,1,0,//中间为白色
0,0,1,0,
0,0,1,0,
//左面
1,1,1,0,//中间为白色
1,0,1,0,
1,0,1,0,
1,1,1,0,//中间为白色
1,0,1,0,
1,0,1,0,
1,1,1,0,//中间为白色
1,0,1,0,
1,0,1,0,
1,1,1,0,//中间为白色
1,0,1,0,
1,0,1,0,
//右面
1,1,1,0,//中间为白色
1,1,0,0,
1,1,0,0,
1,1,1,0,//中间为白色
1,1,0,0,
1,1,0,0,
1,1,1,0,//中间为白色
1,1,0,0,
1,1,0,0,
1,1,1,0,//中间为白色
1,1,0,0,
1,1,0,0,
//上面
1,1,1,0,//中间为白色
0,1,0,0,
0,1,0,0,
1,1,1,0,//中间为白色
0,1,0,0,
0,1,0,0,
1,1,1,0,//中间为白色
0,1,0,0,
0,1,0,0,
1,1,1,0,//中间为白色
0,1,0,0,
0,1,0,0,
//下面
1,1,1,0,//中间为白色
0,1,1,0,
0,1,1,0,
1,1,1,0,//中间为白色
0,1,1,0,
0,1,1,0,
1,1,1,0,//中间为白色
0,1,1,0,
0,1,1,0,
1,1,1,0,//中间为白色
0,1,1,0,
0,1,1,0,
};
//创建顶点着�
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
android 3D游戏开发技术宝典-opengl ES2.0的第5章 投影及各种变换 (388个子文件)
resources.ap_ 12KB
resources.ap_ 12KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 10KB
resources.ap_ 10KB
Sample5_11.apk 20KB
Sample5_6.apk 20KB
Sample5_10.apk 20KB
Sample5_9.apk 20KB
Sample5_7.apk 20KB
Sample5_8.apk 19KB
Sample5_5.apk 19KB
Sample5_4.apk 19KB
Sample5_3.apk 19KB
Sample5_2.apk 18KB
Sample5_1.apk 18KB
Cube.class 6KB
Cube.class 6KB
Cube.class 6KB
SixPointedStar.class 5KB
SixPointedStar.class 5KB
Belt.class 4KB
Belt.class 4KB
Circle.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
ShaderUtil.class 3KB
Belt.class 3KB
Circle.class 3KB
PointsOrLines.class 3KB
ColorRect.class 3KB
TrianglePair.class 3KB
MatrixState.class 3KB
MatrixState.class 2KB
MatrixState.class 2KB
MatrixState.class 2KB
MatrixState.class 2KB
MatrixState.class 2KB
MatrixState.class 2KB
MatrixState.class 2KB
MatrixState.class 2KB
MySurfaceView$SceneRenderer.class 2KB
MySurfaceView$SceneRenderer.class 2KB
MySurfaceView$SceneRenderer.class 2KB
MySurfaceView$SceneRenderer.class 2KB
Sample5_6_Activity.class 2KB
MySurfaceView$SceneRenderer.class 2KB
MySurfaceView$SceneRenderer.class 2KB
MySurfaceView$SceneRenderer.class 2KB
MySurfaceView$SceneRenderer.class 2KB
Sample5_11_Activity.class 2KB
MySurfaceView$SceneRenderer.class 2KB
MySurfaceView$SceneRenderer.class 2KB
MySurfaceView$SceneRenderer.class 2KB
Sample5_10_Activity.class 2KB
MySurfaceView.class 2KB
MySurfaceView.class 2KB
MySurfaceView.class 1KB
MatrixState.class 1KB
Sample5_10_Activity$1.class 1KB
Sample5_3_Activity.class 1KB
Sample5_5_Activity.class 1KB
Sample5_8_Activity.class 1KB
Sample5_4_Activity.class 1KB
Sample5_1_Activity.class 1KB
Sample5_2_Activity.class 1KB
Sample5_9_Activity.class 1KB
Sample5_7_Activity.class 1KB
MatrixState.class 1KB
Sample5_6_Activity$1.class 1KB
Sample5_6_Activity$2.class 1KB
Sample5_6_Activity$4.class 1KB
Sample5_6_Activity$3.class 1KB
MySurfaceView.class 1KB
Sample5_11_Activity$2.class 1KB
Sample5_11_Activity$1.class 1KB
Cube.class 1KB
MySurfaceView.class 978B
MySurfaceView.class 908B
MySurfaceView.class 908B
MySurfaceView.class 908B
MySurfaceView.class 908B
MySurfaceView.class 908B
MySurfaceView.class 908B
R$id.class 676B
R$id.class 642B
共 388 条
- 1
- 2
- 3
- 4
qq_45052877
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Matlab人脸肤色定理的教师人数统计+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab霍夫曼变换的表盘读数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab火灾烟雾检测源码带GUI界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的恶劣天气交通标志识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的霍夫曼变换的表盘示数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的车道线识别系统 +源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的教室人数统计系统带Gui界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的教室人数统计系统带Gui界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB 的霍夫曼变换答题卡识别源码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab+bp神经网络的神经网络汉字识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0