as4bbc12
|
分享:
x0
|
[JScript][教学] [分享] java 3d implements
java上实作3D图形(入门)
开始学习3D物件的使用也分享给大家看看吧
CODE:[Copy to clipboard]import javax.media.j3d.*; import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.applet.MainFrame;
public class CubeSides extends Applet3D {
public BranchGroup createSceneTree () { //3D scene BranchGroup root = new BranchGroup ();
// Create rotation PI / 6 axe X Transform3D rotationXAxis = new Transform3D (); rotationXAxis.rotX (Math.PI / 6); TransformGroup rotationXAxisGroup = new TransformGroup (rotationXAxis);
// Create rotation -PI / 6 axe Y Transform3D rotationYAxis = new Transform3D (); rotationYAxis.rotY (-Math.PI / 6); TransformGroup rotationYAxisGroup = new TransformGroup (rotationYAxis);
// create cube ColorCube cube = new ColorCube (0.5);
rotationYAxisGroup.addChild (cube); rotationXAxisGroup.addChild (rotationYAxisGroup); root.addChild (rotationXAxisGroup);
return root; }
//method main () public static void main (String [] args) { new MainFrame (new CubeSides (), args, 150, 150); } }
|