透视投影绘制 游戏场景

 public void drawPerspective()
        {
        	MatrixState.setProjectFrustum(-ratio, ratio, -1, 1, 3, 40000);//设置透视投影
        	MatrixState.pushMatrix();
        	//这里进行相关变量的复制,用于不同线程之间的不同步,会发生抖动现象
        	synchronized(lock)
			{
        		curr_cx=cx;
	        	curr_cy=cy+2;
	        	curr_cz=cz;
	        	curr_tx=tx;
	        	curr_ty=ty;
	        	curr_tz=tz;
	        	curr_upx=upX;
	        	curr_upy=upY;
	        	curr_upz=upZ;
	        	
	        	curr_PlaneX=PLANE_X;
	        	curr_PlaneZ=PLANE_Z;  
	        	curr_PlaneY=PLANE_Y;
	        	curr_rot_Plane_X=rotationAngle_Plane_X;
	        	curr_rot_Plane_Y=rotationAngle_Plane_Y;
	        	curr_rot_Plane_Z=rotationAngle_Plane_Z;
	        	
	        	Matrix.setRotateM(fa, 0, curr_rot_Plane_Y, 0, 1, 0);//得到旋转矩阵
	        	YB[0]=(float) (Math.sin(Math.toRadians(-curr_rot_Plane_Z)));
	        	YB[1]=(float) (Math.cos(Math.toRadians(-curr_rot_Plane_Z))* Math.cos(Math.toRadians(rotationAngle_Plane_X)));
	        	YB[2]=(float) (Math.cos(Math.toRadians(-curr_rot_Plane_Z))* Math.sin(Math.toRadians(rotationAngle_Plane_X)));
	        	YB[3]=1;
	        	Matrix.multiplyMV(resultUp, 0, fa, 0, YB, 0);
	        	
	        	MatrixState.setCamera(curr_cx,curr_cy,curr_cz,curr_tx,curr_ty,curr_tz,
	        			resultUp[0],resultUp[1],resultUp[2]);//设置摄像机的位置
	        	MatrixState.copyMVMatrix();
	        	MatrixState.translate(-20*(float)Math.sin(Math.toRadians(curr_rot_Plane_Z/4)),
	        			-20*(float)Math.cos(Math.toRadians(curr_rot_Plane_Z/4)),0);
	        	copybaozhaList.clear();//复杂爆炸效果列表
	        	for(DrawBomb db:baoZhaList)
	        	{
	        		copybaozhaList.add(db);
	        	}
	        	cop_archie_bomb_List.clear();//复制高射炮子弹
	        	for(BombForControl db:archie_bomb_List)
	        	{
	        		cop_archie_bomb_List.add(db);
	        	}
	        	cop_bomb_List.clear();//复制炮弹列表
	        	for(BombForControl db:bomb_List)
	        	{
	        		cop_bomb_List.add(db);
	        	}
	        	cop_archie_List.clear();
	        	for(ArchieForControl db:archie_List)//高射炮炮弹复制
	        	{
	        		cop_archie_List.add(db);
	        	}
	        	cop_bullet_List.clear();//子弹复制
	        	for(BulletForControl db:bullet_List)
	        	{
	        		cop_bullet_List.add(db);
	        	}
	        	copy_tank_bomb_List.clear();//炮弹复制
	        	for(BombForControl db:tank_bomb_List)
	        	{
	        		copy_tank_bomb_List.add(db);
	        	}
			}
        	lightAngle+=2;
          //计算当前九宫格,并调用相应的方法绘制相应的物体
           drawAll();
          MatrixState.popMatrix();
        }

posted @ 2015-05-24 00:45  Anzhongliu  阅读(212)  评论(0编辑  收藏  举报