ball.java
来自「用java 3d实现的红色球体。在本file里将如何以点制作java 3d体现了」· Java 代码 · 共 51 行
JAVA
51 行
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package traak.java3d;import javax.media.j3d.BoundingSphere;import javax.media.j3d.BranchGroup;import javax.media.j3d.DirectionalLight;import javax.vecmath.Color3f;import javax.vecmath.Point3d;import javax.vecmath.Vector3f;import com.sun.j3d.utils.geometry.Sphere;import com.sun.j3d.utils.universe.SimpleUniverse;public class Ball { public Ball() { // Create the universe SimpleUniverse universe = new SimpleUniverse(); // Create a structure to contain objects BranchGroup group = new BranchGroup(); // Create a ball and add it to the group of objects Sphere sphere = new Sphere(0.5f); group.addChild(sphere); // Create a red light that shines for 100m from the origin Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); group.addChild(light1); // look towards the ball universe.getViewingPlatform().setNominalViewingTransform(); // add the group of objects to the Universe universe.addBranchGraph(group); } public static void main(String[] args) { new Ball(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?