Java3D,算是比较古老的技术,Java8中Oracle对JavaFX支持了Java3D.相关资料参照Oracle官网
Java3D实现简单几何空间图形说明:
实例应用:创建3D直线
package com.java3d.dennist.study;
import javax.media.j3d.Appearance;
import javax.media.j3d.LineArray;
import javax.media.j3d.LineAttributes;
import javax.media.j3d.Shape3D;
/**
*
*
* @version : 1.1
*
* @author : 苏若年 发送邮件
*
* @since : 1.0 创建时间: 2013-5-6 下午02:57:47
*
* TODO :
*
*/
public class LineShape extends Shape3D{
// 直线的定点坐标
private float vert[ ]={
.5f,0.5f,0.0f, -0.5f,0.5f,0.0f,
.3f,0.0f,0.0f, -0.3f,0.0f,0.0f,
-0.5f,-0.5f,0.0f, 0.5f,-0.5f,0.0f};
// 各定点的颜色
private float color[ ]={
.0f,0.5f,1.0f, 0.0f,0.5f,1.0f,
.0f,0.8f,2.0f, 1.0f,0.0f,0.3f,
.0f,1.0f,0.3f, 0.3f,0.8f,0.0f};
public LineShape( ) {
// 创建直线数组对象
LineArray line=new LineArray(6,LineArray.COORDINATES|LineArray.COLOR_3);
// 设置直线对象的坐标数组
line.setCoordinates(0,vert);
// 设置直线对象的颜色数组
line.setColors(0,color);
// 创建直线属性对象
LineAttributes linea=new LineAttributes( );
// 设置线宽
linea.setLineWidth(10.0f);
// 设置直线的渲染效果
linea.setLineAntialiasingEnable(true);
Appearance app=new Appearance( );
app.setLineAttributes(linea);
this.setGeometry(line);
this.setAppearance(app);
}
}
将3d直线放置到场景中
package com.java3d.dennist.study;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.DirectionalLight;
import javax.m