private Vector3D dir = new Vector3D(-3511, 731, 878); // Light vector
private final int dirIntensity = 4096; // Light intensity
private final int ambIntensity = 1755; // Ambient light intensity
...
light = new Light(dir,dirIntensity,ambIntensity);
effect = new Effect3D( light, Effect3D.NORMAL_SHADING, true, null);
g3.renderFigure(figure, 0, 0, layout, effect);
...
例5 投影
你可以3D模型上使用透视或平行投影。通过简单的调用实现两者间转换。
// Camera distance
private final static int persNear = 1; // Minimum distance to the camera
private final static int persFar = 4096; // Maximum distance to the camera
private final static int persAngle = 682; // Angle
...
//Setting the projection method
if(persEnabled){
layout.setPerspective(persNear, persFar, persAngle);
}else{
layout.setParallelSize(800, 800);
}
例6 旋转模型