package com.bn.carracer;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import android.opengl.GLSurfaceView;
import android.opengl.GLU;
import android.opengl.GLUtils;
import android.view.KeyEvent;
import android.view.MotionEvent;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import static com.bn.carracer.Constant.*;
import static com.bn.carracer.Activity_GL_Racing.*;
public class MyGLSurfaceView extends GLSurfaceView {
static Activity_GL_Racing activity;
private SceneRenderer mRenderer;//场景渲染器
static float carX;//车的XYZ坐标
static float carOldX;//车上一步的X坐标
static float carY;
static float carZ;
static float carAlpha=DIRECTION_INI;//车的角度,0度为z轴负方向,角度为沿Y轴右手螺旋正转
static float carAlphaRD=0;//车的扰动角度值
static float carV;//车的当前速度
static float carLightAngle=135;//车定向灯光当前角度。
static boolean timeFlag=false;//开始记录时间标志位,false为不记录,true为开始记录时间。
static boolean rsLoadFlag=false;//纹理、绘制用物体对象加载标志
static boolean isBrake;//刹车中标志,用于控制车尾灯的开启/关闭
static boolean viewFlag=true;//用于控制汽车视角,true为第三人称视角,false为第一人称视角
static boolean yibiaopanFlag=true;//用于收放仪表盘。
static boolean mapFlag=true;//用于收放迷你地图。
static boolean daojishiFlag=false;//用于控制倒计时绘制的标志位
static int quanshu=0;//记录行驶圈数
static boolean halfFlag=false;//行驶半圈标志
static float SpeedFactor=1;//速度增减因子 ,步进0.3f
static int SpeedFactorControl=0;//速度增减状态,1为加速30%状态,0为标准状态,-1为减速30%状态
static long gameStartTime;//游戏开始时间
static long benquanStartTime;//游戏本圈时间
static float airshipRow;//飞艇所在地图行
static float airshipCol;//飞艇所在地图列
//key-pointerId value-0代表加速,1代表减速,2代表其他,其他包括收放小地图,收放速度表,切换第一人称、第三人称视角
static HashMap<Integer,Integer> isSpeedVirtualButton=new HashMap<Integer,Integer>();
public static long gameContinueTime()//获取游戏时间
{
return System.currentTimeMillis()-gameStartTime;
}
public static long thisCycleContinueTime()//获取本圈时间
{
return System.currentTimeMillis()-benquanStartTime;
}
static ArrayList<TreeForControl> treeList=new ArrayList<TreeForControl>();//用于绘制的树列表
//从车的坐标计算出摄像机的坐标
public static float[] calFromCarXYZToCameraXYZ(float carXtemp,float carYtemp,float carZtemp,float carAlphaTemp)
{
if(viewFlag)
{//若为第三人称视角
float cy=carYtemp+20.0f;
float cz=(float) (carZtemp+40*Math.cos(Math.toRadians(carAlphaTemp)));
float cx=(float) (carXtemp+40*Math.sin(Math.toRadians(carAlphaTemp)));
return new float[]{cx,cy,cz,carXtemp,carYtemp,carZtemp};
}
else
{//若为第一人称视角
float cx=(float)(carXtemp+1*Math.sin(Math.toRadians(carAlphaTemp)));
float cy=carYtemp+12;
float cz=(float)(carZtemp+1*Math.cos(Math.toRadians(carAlphaTemp)));
float ty=cy-1;
float tz=(float) (cz-40*Math.cos(Math.toRadians(carAlphaTemp)));
float tx=(float) (cx-40*Math.sin(Math.toRadians(carAlphaTemp)));
return new float[]{cx,cy,cz,tx,ty,tz};
}
}
static int keyState=0;//键盘状态 1-up 2-down 4-left 8-right
static ThreadKey kt;//键盘状态监控线程
static ThreadColl kc;//碰撞部件运动线程
static ThreadSpeed ts;//加减速弹簧的检测线程
ThreadCamera tc;//摄像机巡场线程
static int grassTextureId;//草地纹理id
static int moutainTextureId;//山纹理id
static int roadTextureId;//公路纹理id
static int lubiaoTextureId;//路边拦纹理id
static int zwTextureId;//驾驶方向标纹理id
static int waterTextureId;//水面纹理id
static int skyTextureId;//天空球纹理id
static int beginTextureId;//赛车开始标志纹理id
static int tunnelTextureId;//隧道纹理id
static int bridgeTextureId;//桥纹理id
static int buildingTextureId;//大楼纹理id
static int guanggaoTextureId;//广告纹理id
static int houseTextureId;//农房纹理id
static int treeTextureId;//树纹理id
static int chePaiTextureId1;//车牌1纹理id
static int chePaiTextureId2;//车牌2纹理id
static int upTextureId;//虚拟键盘UP键id
static int downTextureId;//虚拟键盘DOWN键id
static int mTextureId;//虚拟键盘M键id
static int qTextureId;//虚拟键盘Q键id
static int sTextureId;//虚拟键盘S键id
static int miniMapTextureId;//小地图纹理id
static int yibiaopanTextureId;//仪表盘纹理id
static int roadSignTextureId;//路标纹理id
static int airshipTextureId;//飞艇纹理id
static int trafficLightTextrueId;//交通灯纹理id
static int timeTextureId;//时间纹理id
static int daojishiTextureId;//倒计时纹理id
static int zhangaiwuTextureId;//障碍物纹理id
static int drumTextureId;//交通筒纹理id
static int prismTextureId;//交通棱柱纹理id
static Bitmap grassTextureBm;//草地纹理图
static Bitmap moutainTextureBm;//山纹理图
static Bitmap roadTextureBm;//公路纹理图
static Bitmap lubiaoTextureBm;//路边拦纹理图
static Bitmap zwTextureBm;//驾驶方向标纹理图
static Bitmap waterTextureBm;//水面纹理图
static Bitmap skyTextureBm;//天空球纹理图
static Bitmap beginTextureBm;//赛车开始标志纹理图
static Bitmap tunnelTextureBm;//隧道纹理图
static Bitmap bridgeTextureBm;//桥纹理图
static Bitmap buildingTextureBm;//大楼纹理图
static Bitmap guanggaoTextureBm;//广告纹理图
static Bitmap houseTextureBm;//农房纹理图
static Bitmap treeTextureBm;//树纹理图
static Bitmap chePaiTextureBm1;//车牌1纹理图
static Bitmap chePaiTextureBm2;//车牌2纹理图
static Bitmap upTextureBm;//虚拟键盘UP键图
static Bitmap downTextureBm;//虚拟键盘DOWN键图
static Bitmap mTextureBm;//虚拟键盘M键图
static Bitmap qTextureBm;//虚拟键盘Q键图
static Bitmap sTextureBm;//虚拟键盘S键图
static Bitmap miniMapTextureBm;//小地图纹理图
static Bitmap yibiaopanTextureBm;//仪表盘纹理图
static Bitmap roadSignTextureBm;//路标纹理图
static Bitmap airshipTextureBm;//飞艇纹理图
static Bitmap trafficLightTextrueBm;//交通灯纹理图
static Bitmap timeTextureBm;//时间纹理图
static Bitmap daojishiTextureBm;//倒计时纹理图
static Bitmap zhangaiwuTextureBm;//障碍物纹理图
static Bitmap drumTextureBm;//交通筒纹理图
static Bitmap prismTextureBm;//交通棱柱纹理图
static DrawGrassAndMoutain plain;//平原平原
static DrawGrassAndMoutain moutain;//石头山部件
static DrawPool pool;//池塘部件
static DrawSky sky;//天空球部件
static WDBJ_N wdbj_n;//逆时针弯道部件
static WDBJ_S wdbj_s;//顺时针弯道部件
static ZDBJ zdbj;//直道部件
static DrawBegin begin;//开始标志部件
static DrawTunnel tunnel;//隧道部件
static DrawBridgeOuter bridge;//桥部件
static DrawBuilding building;//大楼部件
static DrawBillBoard guanggao;//广告部件
static DrawHouse house;//农房部件
static DrawTree tree;//树部件
static DrawLicensePlate chepai;//车牌部件
static TextureRect goButton;//虚拟前进按钮
static TextureRect backButton;//虚拟后退按钮
static TextureRect MButton;//虚拟迷你地图控制按钮
static TextureRect QButton;//虚拟视角控制按钮
static TextureRect SButton;//虚拟仪表盘控制按钮
static DrawMiniMap minimap;//小地图部件
static Car miniCar;//迷你车部件
static DrawPanel panel;//仪表盘部件
static DrawRoadSign roadSign;//路标部件
static DrawAirship airship;//飞艇部件
static DrawTrafficLights tl;//交通灯部件
static
没有合适的资源?快使用搜索试试~ 我知道了~
Android3D游戏开发技术详解源代码(各种游戏项目源码)
共2000个文件
class:1111个
java:578个
png:551个
5星 · 超过95%的资源 需积分: 50 649 下载量 142 浏览量
2012-09-17
15:41:49
上传
评论 13
收藏 65.62MB RAR 举报
温馨提示
Android3D游戏开发技术详解源代码(各种游戏项目源码).rar ) 很强大的 全套的 光盘
资源推荐
资源详情
资源评论
收起资源包目录
Android3D游戏开发技术详解源代码(各种游戏项目源码) (2000个子文件)
resources.ap_ 2.89MB
resources.ap_ 2.89MB
resources.ap_ 2.58MB
resources.ap_ 1.97MB
resources.ap_ 1.55MB
resources.ap_ 1.5MB
resources.ap_ 1.01MB
resources.ap_ 854KB
resources.ap_ 644KB
resources.ap_ 430KB
resources.ap_ 393KB
resources.ap_ 385KB
resources.ap_ 385KB
resources.ap_ 382KB
resources.ap_ 310KB
resources.ap_ 257KB
resources.ap_ 204KB
resources.ap_ 201KB
resources.ap_ 201KB
resources.ap_ 186KB
resources.ap_ 178KB
resources.ap_ 159KB
resources.ap_ 145KB
resources.ap_ 133KB
resources.ap_ 100KB
resources.ap_ 83KB
resources.ap_ 83KB
resources.ap_ 81KB
resources.ap_ 74KB
resources.ap_ 66KB
resources.ap_ 58KB
resources.ap_ 57KB
resources.ap_ 56KB
resources.ap_ 56KB
resources.ap_ 56KB
resources.ap_ 49KB
resources.ap_ 49KB
resources.ap_ 49KB
resources.ap_ 34KB
resources.ap_ 34KB
resources.ap_ 34KB
resources.ap_ 24KB
resources.ap_ 24KB
resources.ap_ 24KB
resources.ap_ 19KB
resources.ap_ 15KB
resources.ap_ 13KB
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_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 11KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
resources.ap_ 10KB
CountrysideRacing.apk 2.98MB
BilliardsGameAll.apk 2.93MB
Rotat_Toy_Brick.apk 2.61MB
Sample21_1.apk 2.01MB
GL_Basketball_Shot.apk 1.57MB
Sample19_1.apk 1.53MB
BuildSkyscraperFinish.apk 1.03MB
Sample15_9.apk 864KB
Sample11_3.apk 653KB
Sample13_1.apk 440KB
Sample10_2.apk 402KB
Sample13_3.apk 393KB
Sample13_2.apk 393KB
Sample15_2.apk 390KB
Sample6_3.apk 319KB
Sample7_5.apk 265KB
Sample15_7.apk 219KB
Sample7_9.apk 210KB
Sample7_10.apk 207KB
Sample9_1.apk 194KB
Sample7_7.apk 187KB
Sample11_4.apk 167KB
Sample3_1.apk 150KB
Sample11_1.apk 142KB
Sample15_6.apk 113KB
Sample8_4.apk 89KB
Sample10_1.apk 89KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
zhanglu231123
- 粉丝: 235
- 资源: 100
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
- 基于单片机的风力发电机转速控制源码
- 基于C++实现的风力发电气动平衡监测系统+源代码+测量数据(高分课程设计)
- 毕业设计- 基于STM32F103C8T6 单片机,物联网技术的太阳能发电装置+源代码+文档说明+架构图+界面截图
- 基于 LSTM(长短期记忆)(即改进的循环神经网络)预测风力发电厂中风力涡轮机产生的功率+源代码+文档说明
- 基于stm32f103+空心杯电机+oled按键+运动算法
- 《CKA/CKAD应试指南/从docker到kubernetes 完全攻略》学习笔记 第1章docker基础(1.1-1.4)
- 基于python实现的水下压缩空气储能互补系统建模仿真与经济效益分析+源代码+论文
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页