⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 object_4d.java

📁 一个J2ME的3D 一个J2ME的3D 一个J2ME的3D
💻 JAVA
字号:
/**
 * 
 */
package object3d;

import render.Textrue;
import Math.Matrix4X4;
import Math.Point4D;
import Math.Vector4D;

/**
 * @author PanXu
 *
 */
public class Object_4D {

	/**
	 * 
	 */
	public Object_4D(int VerNum , int PolyNum,
			Vertex4D [] Vl , Vertex4D [] Tl , Textrue tex) {
		super();
		// TODO 自动生成构造函数存根
		Dir = new Vector4D ();
		this .VerNum = VerNum;
		this .VList = new Vertex4D [VerNum];
		this .Tlist = new Vertex4D [VerNum];
		this .PolyNum = PolyNum ;
		this .PolyList = new Poly_4D [PolyNum];
		
		this .VList = Vl ;
		this .Tlist = Tl ;
		
		this .Tex = tex ;
		
		for (int i = 0 ; i < this .PolyNum ; i ++)
		{
			this .PolyList[i].Vlist = this .VList;
			this .PolyList[i].Tlist = this .Tlist;
			this .PolyList[i].Tex = this .Tex;
		}//for 
	}
	
	/**
	 * 常量
	 */
	public static int OBJ_STATE_ACTIVE 	= 0x0001;
	public static int OBJ_STATE_CULL		= 0x0002;
	
	int State ;
	
	Point4D Pos =new Point4D ();
	
	//颜色
	
	//顶点数
	int VerNum ;
	//顶点表
	Vertex4D VList [] = null;
	Vertex4D Tlist [] = null;
	//多边形个数
	int PolyNum ;
	//多边形表
	Poly_4D PolyList [] = null;
	//朝向
	Vector4D Dir = null;
	//材质
	Textrue Tex = null;
	
	//矩阵变换中间变量
	private static Matrix4X4 Temp = new Matrix4X4 ();
	/**
	 * 函数
	 */
	
	/**
	 * 生成变换矩阵
	 *
	 */
	public Matrix4X4 BuildTranMat ()
	{
		Matrix4X4 res = new Matrix4X4 ();
		res .Set_MOVMAT(- this .Pos.M[0],- this .Pos.M[1],- this .Pos.M[2]);
		
		this .Temp .Set_CIRMAT(-(int)this .Dir.M[0],-(int)this .Dir.M[1],
				-(int)this .Dir.M[2]);
		
		res .MAT4X4_MUL_Stack(res , Temp);
		return res ;
	}
	/**
	 * 变换到世界坐标
	 */
	public void TranToWorld (Matrix4X4 mat)
	{
		int i = 0 ;
		for (i = 0 ; i < this .PolyNum ; i ++)
		{
			this .PolyList[i].Tlist[this .PolyList[i].VIndex[0]].Pos = 
				this .PolyList[i].Vlist[this .PolyList[i].VIndex[0]].Pos.MAT4X4_MUL_PT4D(mat);
			this .PolyList[i].Tlist[this .PolyList[i].VIndex[1]].Pos = 
				this .PolyList[i].Vlist[this .PolyList[i].VIndex[1]].Pos.MAT4X4_MUL_PT4D(mat);
			this .PolyList[i].Tlist[this .PolyList[i].VIndex[2]].Pos = 
				this .PolyList[i].Vlist[this .PolyList[i].VIndex[2]].Pos.MAT4X4_MUL_PT4D(mat);
		}//for 
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -