package com.gg.top;
import java.nio.*;
import java.util.ArrayList;
import java.util.Random;
import javax.microedition.khronos.opengles.GL10;
import com.gg.util.Constant;
/* 用于绘制三维的陀螺(其中的圆部分) */
public class DrawCircle extends BasicTop {
int textureId; // 纹理id
int vertexNumber; // 所有顶点数量总和
private FloatBuffer vertexBuffer; // 顶点坐标缓冲
private FloatBuffer normalBuffer; // 法向量缓冲
private FloatBuffer textureBuffer; // 纹理缓冲
ArrayList<Float> val = new ArrayList<Float>(); // 顶点存放列表
ArrayList<Float> ial = new ArrayList<Float>(); // 法向量存放列表
ArrayList<Float> tal = new ArrayList<Float>();
float degreeSpan = 12f; // 圆截环每一份的度数大小
int degreeSpanNumber = (int) (360.0f / degreeSpan); // 圆截环数量
int coneCol = 2; // 圆锥平均切分的块数
float spanConeHeight = coneHeight / coneCol; // 圆锥每块所占的高度
float spanConeRadius = radius / coneCol;// 半径单位长度
float normalconeHeight = (coneHeight * radius * radius)
/ (coneHeight * coneHeight + radius * radius); // 法向量点所在圆截面的高度
float normalR = (coneHeight * coneHeight * radius)
/ (coneHeight * coneHeight + radius * radius); // 法向量点所在圆截面的半径
int cylinderCol = 1; // 圆柱平均分的块数
float spanCylinderHeight = cylinderHeight / cylinderCol; // 圆柱每块所占的高度
// public float xAngle; // 沿x轴旋转的角度
// public float yAngle; // 沿y轴旋转的角度
// public float zAngle; // 沿z轴旋转的角度
//public float zAutoAngle; // 自动沿z轴旋转的角度
public DrawCircle(int textureId) {
this.textureId = textureId;
generateData();
}
public void generateData(){
val.clear();
ial.clear();
for (float circle_degree = 360.0f; circle_degree > 0.0f; circle_degree -= degreeSpan)// 循环行
{
// // 求圆锥的点和法向量
// for (int j = 0; j < coneCol; j++) // 循环列
// {
// float currentR = j * spanConeRadius;// 当前截面的圆半径
// float currentconeHeight = j * spanConeHeight;// 当前截面的高度
//
// float x1 = (float) (currentR * Math.cos(Math
// .toRadians(circle_degree)));
// float y1 = (float) (currentR * Math.sin(Math
// .toRadians(circle_degree)));
// float z1 = currentconeHeight;
//
// float a1 = (float) (normalR * Math.cos(Math
// .toRadians(circle_degree)));
// float b1 = (float) (normalR * Math.sin(Math
// .toRadians(circle_degree)));
// float c1 = normalconeHeight;
// float l1 = getVectorLength(a1, b1, c1);// 模长
// a1 = a1 / l1;// 法向量规格化
// b1 = b1 / l1;
// c1 = c1 / l1;
//
// float x2 = (float) ((currentR + spanConeRadius) * Math.cos(Math
// .toRadians(circle_degree)));
// float y2 = (float) ((currentR + spanConeRadius) * Math.sin(Math
// .toRadians(circle_degree)));
// float z2 = currentconeHeight + spanConeHeight;
//
// float a2 = (float) (normalR * Math.cos(Math
// .toRadians(circle_degree)));
// float b2 = (float) (normalR * Math.sin(Math
// .toRadians(circle_degree)));
// float c2 = normalconeHeight;
//
// float l2 = getVectorLength(a2, b2, c2);// 模长
// a2 = a2 / l2;// 法向量规格化
// b2 = b2 / l2;
// c2 = c2 / l2;
//
// float x3 = (float) ((currentR + spanConeRadius) * Math.cos(Math
// .toRadians(circle_degree - degreeSpan)));
// float y3 = (float) ((currentR + spanConeRadius) * Math.sin(Math
// .toRadians(circle_degree - degreeSpan)));
// float z3 = currentconeHeight + spanConeHeight;
//
// float a3 = (float) (normalR * Math.cos(Math
// .toRadians(circle_degree - degreeSpan)));
// float b3 = (float) (normalR * Math.sin(Math
// .toRadians(circle_degree - degreeSpan)));
// float c3 = normalconeHeight;
//
// float l3 = getVectorLength(a3, b3, c3);// 模长
// a3 = a3 / l3;// 法向量规格化
// b3 = b3 / l3;
// c3 = c3 / l3;
//
// float x4 = (float) ((currentR) * Math.cos(Math
// .toRadians(circle_degree - degreeSpan)));
// float y4 = (float) ((currentR) * Math.sin(Math
// .toRadians(circle_degree - degreeSpan)));
// float z4 = currentconeHeight;
//
// float a4 = (float) (normalR * Math.cos(Math
// .toRadians(circle_degree - degreeSpan)));
// float b4 = (float) (normalR * Math.sin(Math
// .toRadians(circle_degree - degreeSpan)));
// float c4 = normalconeHeight;
//
// float l4 = getVectorLength(a4, b4, c4);// 模长
// a4 = a4 / l4;// 法向量规格化
// b4 = b4 / l4;
// c4 = c4 / l4;
//
// val.add(x1);
// val.add(y1);
// val.add(z1);// 两个三角形,共6个顶点的坐标
// val.add(x2);
// val.add(y2);
// val.add(z2);
// val.add(x4);
// val.add(y4);
// val.add(z4);
//
// val.add(x2);
// val.add(y2);
// val.add(z2);
// val.add(x3);
// val.add(y3);
// val.add(z3);
// val.add(x4);
// val.add(y4);
// val.add(z4);
//
// ial.add(a1);
// ial.add(b1);
// ial.add(c1);// 顶点对应的法向量
// ial.add(a2);
// ial.add(b2);
// ial.add(c2);
// ial.add(a4);
// ial.add(b4);
// ial.add(c4);
//
// ial.add(a2);
// ial.add(b2);
// ial.add(c2);
// ial.add(a3);
// ial.add(b3);
// ial.add(c3);
// ial.add(a4);
// ial.add(b4);
// ial.add(c4);
// }
//
// // 求圆柱的点和法向量
// for (int j = 0; j < cylinderCol; j++)// 循环列
// {
// float x1 = (float) (radius * Math.sin(Math
// .toRadians(circle_degree)));
// float y1 = (float) (radius * Math.cos(Math
// .toRadians(circle_degree)));
// float z1 = (float) (j * spanCylinderHeight + coneHeight);
//
// float a1 = (float) (normalR * Math.sin(Math
// .toRadians(circle_degree)));
// float b1 = (float) (normalR * Math.cos(Math
// .toRadians(circle_degree)));
// float c1 = 0;
// float l1 = getVectorLength(a1, b1, c1);// 模长
// a1 = a1 / l1;// 法向量规格化
// b1 = b1 / l1;
// c1 = c1 / l1;
//
// float x2 = (float) (radius * Math.sin(Math
// .toRadians(circle_degree - degreeSpan)));
// float y2 = (float) (radius * Math.cos(Math
// .toRadians(circle_degree - degreeSpan)));// 化为弧度制
// float z2 = (float) (j * spanCylinderHeight + coneHeight);
//
// float a2 = (float) (normalR * Math.sin(Math
// .toRadians(circle_degree - degreeSpan)));
// float b2 = (float) (normalR * Math.cos(Math
// .toRadians(circle_degree - degreeSpan)));
// float c2 = 0;
// float l2 = getVectorLength(a1, b1, c1);// 模长
// a2 = a2 / l2;// 法向量规格化
// b2 = b2 / l2;
// c2 = c2 / l2;
//
// float x3 = (float) (radius * Math.sin(Math
// .toRadians(circle_degree - degreeSpan)));
// float y3 = (float) (radius * Math.cos(Math
// .toRadians(circle_degree - degreeSpan)));
// float z3 = (float) ((j + 1) * spanCylinderHeight + coneHeight);
//
// float a3 = (float) (normalR * Math.sin(Math
// .toRadians(circle_degree - degreeSpan)));
// float b3 = (float) (normalR * Math.cos(Math
// .toRadians(circle_degree - degreeSpan)));
// float c3 = 0;
// float l3 = getVectorLength(a1, b1, c1);// 模长
// a3 = a3 / l3;// 法向量规格化
// b3 = b3 / l3;
// c3 = c3 / l3;
//
// float x4 = (float) (radius * Math.sin(Math
// .toRadians(circle_degree)));
// float y4 = (float) (radius * Math.cos(Math
// .toRadians(circle_degree)));
// float z4 = (float) ((j + 1) * spanCylinderHeight + coneHeight);
//
// float a4 = (float) (normalR * Math.sin(Math
// .toRadians(circle_degree)));
// float b4 = (float) (normalR * Math.cos(Math
// .toRadians(circle_degree)));
// float c4 = 0;
// float l4 = getVectorLength(a1, b1, c1);// 模长
// a4 = a4 / l4;// 法向量规格化
// b4 = b4 / l4;
// c4 = c4 / l4;
//
// val.add(x1);
// val.add(y1);
// val.add(z1);// 画两个三角形,共六个顶点
// val.add(x2);
// val.ad
没有合适的资源?快使用搜索试试~ 我知道了~
android 实现的陀螺游戏
共102个文件
class:43个
java:29个
jpg:16个
4星 · 超过85%的资源 需积分: 3 9 下载量 73 浏览量
2013-02-23
22:28:00
上传
评论
收藏 8.81MB ZIP 举报
温馨提示
用 android开发的一款陀螺游戏,用手指的划屏模拟真实的鞭打,让陀螺可以转下去。极具趣味性
资源推荐
资源详情
资源评论
收起资源包目录
android 实现的陀螺游戏 (102个子文件)
resources.ap_ 2.25MB
Top.apk 2.28MB
Top 的副本.apk 2.16MB
proguard.cfg 1KB
DrawTop.class 9KB
SelectSurfaceView.class 9KB
BasicTop.class 8KB
ClassicGame.class 7KB
MainMenuSurfaceView.class 6KB
DrawCylinder.class 6KB
DrawCone.class 6KB
ClassicGameSurfaceView.class 6KB
DrawCircle.class 6KB
MainActivity.class 6KB
MainMenuSurfaceView$SceneRenderer.class 5KB
SelectSurfaceView$SceneRenderer.class 5KB
ClassicGameSurfaceView$SceneRenderer.class 5KB
HelpSurfaceView.class 4KB
DrawTrack.class 3KB
Line.class 3KB
ScoreSurfaceView.class 3KB
EndSurfaceView.class 3KB
WelcomeSurfaceView.class 3KB
Track.class 3KB
Utils.class 2KB
Background.class 2KB
WelcomeSurfaceView$1.class 2KB
SelectSurfaceView$SceneRenderer$1.class 2KB
ClassicGameSurfaceView$SceneRenderer$1.class 2KB
VoiceControl.class 2KB
Circle.class 2KB
MainActivity$1.class 1KB
MainMenuSurfaceView$SceneRenderer$1.class 1KB
SurfaceViewFactory.class 1KB
TrackPoint.class 1KB
R$drawable.class 914B
MainActivity$2.class 836B
Direction.class 835B
Constant.class 796B
MainActivity$3.class 789B
GameFrame.class 618B
R$string.class 528B
Point.class 510B
R.class 447B
Vector.class 407B
R$layout.class 373B
R$attr.class 319B
.classpath 364B
classes.dex 76KB
DrawCircle.java 14KB
SelectSurfaceView.java 14KB
MainMenuSurfaceView.java 13KB
DrawCylinder.java 12KB
DrawCone.java 12KB
ClassicGame.java 11KB
DrawTop.java 10KB
BasicTop.java 9KB
ClassicGameSurfaceView.java 9KB
MainActivity.java 8KB
DrawTrack.java 4KB
HelpSurfaceView.java 3KB
WelcomeSurfaceView.java 3KB
Background.java 3KB
Line.java 3KB
Utils.java 2KB
ScoreSurfaceView.java 2KB
EndSurfaceView.java 2KB
Track.java 2KB
R.java 2KB
VoiceControl.java 2KB
SurfaceViewFactory.java 2KB
Circle.java 1KB
TrackPoint.java 1KB
GameFrame.java 913B
Direction.java 682B
Constant.java 653B
Point.java 288B
Vector.java 233B
welcomegg.jpg 440KB
classicgamebg.jpg 392KB
welcometop.jpg 237KB
mainmenubg.jpg 229KB
scorebg.jpg 173KB
helpbg.jpg 164KB
selectbg.jpg 154KB
help3.jpg 119KB
endbg.jpg 106KB
scorecylinder.jpg 56KB
startcylinder.jpg 53KB
circle.jpg 49KB
selectcylinder.jpg 42KB
helpcylinder.jpg 38KB
cylinder.jpg 33KB
help2.jpg 8KB
ic_launcher.png 3KB
ic_launcher.png 2KB
.project 839B
default.properties 363B
project.properties 361B
AndroidManifest.xml 804B
共 102 条
- 1
- 2
资源评论
- huobao892013-02-24不错不错 ,中英文代码注释
copy_zn
- 粉丝: 1
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- keil2 + proteus + 8051.exe
- 1961ee27df03bd4595d28e24b00dde4e_744c805f7e4fb4d40fa3f695bfbab035_8(1).c
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- windows注册表编辑工具
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- 校园通行码预约管理系统20240522075502
- 车类型数据集6250张VOC+YOLO格式.zip
- The PyTorch implementation of STGCN.STGCN-main.zip
- 092300108.cpp
- 车类型数据集6000张VOC+YOLO格式.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功