quadshape2.java
来自「用于java3d的初级测试。由于本人是java3d新手。所以没有注示每段代码的具」· Java 代码 · 共 49 行
JAVA
49 行
import javax.media.j3d.*;
public class quadShape2 extends Shape3D {
private float vert[] = {
-.6f , .6f , .0f ,
-.6f , -.6f, .0f ,
-.3f , .6f , .0f ,
-.3f , -.6f, .0f ,
-.0f , .6f , .0f ,
-.0f , -.6f, .0f ,
.3f , .6f , .0f ,
.3f , -.6f, .0f ,
.6f , .6f , .0f ,
.6f , -.6f, .0f ,
};
private float color[] = {
1.0f,0.5f,0.0f,
1.0f,0.0f,0.5f,
1.0f,0.8f,0.0f,
5.0f,1.0f,0.0f,
0.0f,1.0f,0.5f,
0.9f,1.0f,0.0f,
0.5f,0.0f,1.0f,
0.0f,0.5f,1.0f,
1.0f,0.5f,0.0f,
1.0f,0.0f,0.5f,
};
public quadShape2() {
int[] index={ 2 , 1 , 3 , 4 , 4 , 7 , 9 , 6};
int VertexCount=8;
IndexedQuadArray quad = new IndexedQuadArray(10,
IndexedQuadArray.COORDINATES|
IndexedQuadArray.COLOR_3 , VertexCount);
quad.setCoordinates(0,vert);
quad.setColors(0,color);
quad.setCoordinateIndices(0,index);
quad.setColorIndices(0,index);
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
Appearance ap = new Appearance();
ap.setPolygonAttributes(pa);
this.setGeometry(quad);
this.setAppearance(ap);
this.setGeometry(quad);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?