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 );
/*・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ 直方体の生成 ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・*/
Cone cone = new Cone( 0.3f, 0.6f, Cone.GENERATE_NORMALS, appearance );
TransformGroup transformGroup = new TransformGroup( );
// TransformGroupクラスのインスタンスを生成
/*・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ カラーキューブの生成 ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・*/
/*・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ 座標変換の定義 ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・*/
Transform3D transform3D = new Transform3D( );
// Transform3Dクラスのインスタンスを生成
transform3D.rotX( Math.PI/4.0 );
// 「transform3D」の座標情報として「vector3d」を設定
/*・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・座標変換の設定・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・*/
transformGroup.setTransform( transform3D );
// 「transformGroup」の座標変換として「transform3D」を設定
/*・・・・・・・・・・・・・・・・・・・・・・・・・・・ 物体等をシーングラフに追加 ・・・・・・・・・・・・・・・・・・・・・・・・・・・*/
transformGroup.addChild( cone );
// 「colorCube」を「transformGroup」に追加
group.addChild( transformGroup );
// 「transformGroup」を「objRoot」に追加
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年09月30日 14:21