📄 object3d.java
字号:
/*
* Generic 3D Model for Java Virtual Cube
* --------------------------------------
*
* Copyright 1996, Song Li
* URL: http://www.cs.umbc.edu/~sli2
*
* Portion of Program by David W. Liu
* URL: http://reality.sgi.com/employees/davidliu_mti
*
*
* You can use the code for any nonprofittable use. But remember to mention
* the authors' names in your revised program. You are also encouraged to
* improve the program or give your comments and bug reports. If there are
* further questions, please contact me and I'll be glad to help. My E-Mail
* address is: sli2@gl.umbc.edu.
*
*/
import java.awt.Color;
import java.awt.Graphics;
class Object3D {
Matrix3D TransMat ;
Vertex TransVer [] ;
// Faces are defined by reference to Vertices.
public Vertex Vertices [] = null ;
public Face Faces [] = null ;
public int VerNum ;
public int FaceNum ;
public Object3D () {
TransMat = new Matrix3D () ;
TransMat.Unify () ;
}
public void Define (Vertex vertices[], int vernum,
Face faces[], int facenum) {
Vertices = new Vertex [vernum] ;
for (int i=0; i<vernum; i++)
Vertices[i] = new Vertex (vertices[i]) ;
TransVer = vertices;
VerNum = vernum;
Faces = faces;
FaceNum = facenum;
}
public void Unify () {TransMat.Unify () ;}
/** Transform all the vertices in the model using 3D matrix mat,
and put result into TransVer. Vertices is a "permenant" copy
of the model, which is used to avoid model distortion caused
by inaccuracy of floating point calculation.
*/
void Transform () {
TransMat.Transform (Vertices, TransVer, VerNum) ;
}
void XRotate (double theta) {TransMat.ProXRotate (theta) ;}
void YRotate (double theta) {TransMat.ProYRotate (theta) ;}
void ZRotate (double theta) {TransMat.ProZRotate (theta) ;}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -