import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.vecmath.*;
import java.awt.*;
import javax.swing.*;
public class
pro3d
{
public static void main(String[] args)
{
pro3d test = new pro3d();
}
public pro3d()
{
JFrame frame = [[new]] JFrame();
frame.setSize(250,250);
frame.setTitle("pro3d");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel cp = new JPanel();
cp.setLayout(null);
frame.add(cp);
GraphicsConfiguration g_config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(g_config);
[[canvas]].setBounds(0,0,250,250);
cp.add(canvas);
SimpleUniverse universe = new SimpleUniverse(canvas);
frame.setVisible(true);
BranchGroup group1 = new BranchGroup();
Sphere sphere = new Sphere(0.5f);
group1.addChild(sphere);
universe.addBranchGraph(group1);
ViewingPlatform camera = universe.getViewingPlatform();
camera.setNominalViewingTransform();
Color3f light_color = new Color3f(1.7f,1.7f,1.7f);
Vector3f light_direction = new Vector3f(0.2f,-0.2f,-0.6f);
DirectionalLight light = new DirectionalLight(light_color,light_direction);
BoundingSphere bounds = new BoundingSphere();
light.setInfluencingBounds(bounds);
BranchGroup group2 = new BranchGroup();
group2.addChild(light);
universe.addBranchGraph(group2);
}
}
最終更新:2011年02月14日 21:44