📄 poly_4d.java
字号:
/**
*
*/
package object3d;
import render.Textrue;
import Math.Matrix4X4;
import Math.Point4D;
import Math.Vector4D;
/**
* @author PanXu
*
*/
public class Poly_4D {
/**
*
*/
public Poly_4D() {
super();
// TODO 自动生成构造函数存根
Color = 0xff00ffff;
Pos = new Point4D ();
VIndex = new int [3];
n = new Vector4D();
Dir = new Vector4D();
this .State &= POLY_STATE_ACTIVE;
}
/**
* 常量
*/
//状态
public static int POLY_STATE_ACTIVE = 0x00000001;
public static int POLY_STATE_BACK = 0x00000002;
public static int POLY_STATE_CLIP = 0x00000004;
//着色模式
public static int POLY_SHADE_SOILD = 0x00000010;
public static int POLY_SHADE_GOURAUD = 0x00000020;
public static int POLY_SHADE_LINE = 0x00000040;
public static int POLY_SHADE_TEXTURE = 0x00000100;
public static int POLY_SHADE_RGB = 0x00000200;
/**
*
*/
//状态
public int State ;
//多边形颜色
public int Color ;
//位置
public Point4D Pos = null;
//顶点表
public Vertex4D Vlist[] = null;
public Vertex4D Tlist[] = null;
//顶点索引
public int VIndex [] = null;
//法线长度
public float nLen ;
//法线
public Vector4D n = null;
//朝向
public 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]);
//System .out.println(this .Dir.M[2]);
this .Temp .Set_CIRMAT((int)this .Dir.M[0],(int)this .Dir.M[1],
(int)this .Dir.M[2]);
//Temp .Print();
res = res .MAT4X4_MUL_Stack(Temp , res);
return res ;
}
/**
* 变换到世界坐标
*/
public void TranToWorld (Matrix4X4 mat)
{
if (mat == null)
{
System .out .println ("TranToWorld 空指针");
}
this .Tlist[this .VIndex[0]].Pos =
this .Vlist[this .VIndex[0]].Pos.MAT4X4_MUL_PT4D(mat);
this .Tlist[this .VIndex[1]].Pos =
this .Vlist[this .VIndex[1]].Pos.MAT4X4_MUL_PT4D(mat);
this .Tlist[this .VIndex[2]].Pos =
this .Vlist[this .VIndex[2]].Pos.MAT4X4_MUL_PT4D(mat);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -