import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public pro() {
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group =
new BranchGroup();
Appearance appearance = new Appearance( );
Material material = new Material( );
appearance.setMaterial( material );
Color3f color2f = new Color3f( 0.9f, 0.9f, 0.9f );
material.setDiffuseColor(color2f);
Cone cone = new Cone( 0.4f, 0.4f, Cone.GENERATE_NORMALS, appearance );
TransformGroup transformGroup = new TransformGroup( );
Transform3D transform3D = new Transform3D( );
Vector3d vector3d = new Vector3d(0.4, 0, 0 );
transform3D.setTranslation(vector3d );
transformGroup.setTransform(transform3D );
Appearance ap = new Appearance( );
Material ma = new Material( );
ap.setMaterial( ma );
Color3f color4f = new Color3f( 0.9f, 0.9f, 0.9f );
material.setDiffuseColor(color4f);
Cone con = new Cone( 0.9f, 0.9f, Cone.GENERATE_NORMALS, ap );
TransformGroup tg = new TransformGroup( );
Transform3D t3D = new Transform3D( );
Vector3d v3d = new Vector3d( 0.7, 0.7, 0.7 );
t3D.setScale( v3d );
tg.setTransform( t3D );
transformGroup.addChild(cone);
tg.addChild(con );
group.addChild( transformGroup );
group.addChild( tg );
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 light= new DirectionalLight(light1Color, light1Direction);
light.setInfluencingBounds(bounds);
group.addChild(light);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);
}
public static void main(String[] args) {
new pro();
}
}
最終更新:2010年10月04日 06:11