// --------- コンストラクタ ----------- //
public AppliFrame( Peculiar p[], int myself ) {
super( "Application" );
other = new Peculiar[U];
n = new Node[U];
number = myself;
for( int i = 0; i < p.length; i++ ) {
if( i == myself ) {
self = p[myself];
other[i] = null;
}
else
other[i] = p[i];
}
container = getContentPane(); // コンテンツペイン取得
container.setLayout( new BorderLayout() );
Box baseBox = Box.createHorizontalBox();
Box box[] = new Box[U];
lab = new JLabel[U];
labX = new JLabel[U]; labY = new JLabel[U]; labZ = new JLabel[U];
for( int i = 0; i < box.length; i++ )
box[i] = Box.createVerticalBox();
lab[0] = new JLabel( "A" ); lab[0].setForeground( Color.RED );
lab[1] = new JLabel( "B" ); lab[1].setForeground( Color.BLUE );
lab[2] = new JLabel( "C" ); lab[2].setForeground( Color.YELLOW );
lab[3] = new JLabel( "D" ); lab[3].setForeground( Color.GREEN );
for( int i = 0; i < lab.length; i++ ) {
if( i == myself ) {
labX[myself] = new JLabel( "x : " + self.eyeX + " " );
labY[myself] = new JLabel( "y : " + self.eyeY + " " );
labZ[myself] = new JLabel( "z : " + self.eyeZ + " " );
}
else {
if( other[i].flag == true ) {
labX[i] = new JLabel( "x : " + other[i].eyeX + " " );
labY[i] = new JLabel( "y : " + other[i].eyeY + " " );
labZ[i] = new JLabel( "z : " + other[i].eyeZ + " " );
}
else {
labX[i] = new JLabel( "x : --- " );
labY[i] = new JLabel( "y : --- " );
labZ[i] = new JLabel( "z : --- " );
}
}
}
for( int i = 0; i < box.length; i++ ) {
box[i].add( lab[i] ); // A,B,C,Dを追加
box[i].add( labX[i] ); // x 座標値を追加
box[i].add( labY[i] ); // y 座標値を追加
box[i].add( labZ[i] ); // z 座標値を追加
baseBox.add( box[i] );
}
Canvas3D canvas = new Canvas3D( SimpleUniverse.getPreferredConfiguration() ); // Canvas3D クラスのインスタンス生成
// 球体の表示・非表示を設定
selecter = new Switch( Switch.CHILD_MASK );
selecter.setCapability( Switch.ALLOW_SWITCH_WRITE ); // 書込みを許可
flag = new BitSet( U-1 );
on = new int[U];
// ----------- 光源の設定を行うノード ------------- //
public Node createLight( float posX, float posY, float posZ ) {
Light light = new PointLight( new Color3f (10.0f, 10.0f, 10.0f ), // 光の色
new Point3f ( posX, posY, posZ ), // 光源の位置
new Point3f ( 0.1f, 0.1f, 0.0f ) // 光の減衰率
);
BoundingSphere bounds = new BoundingSphere( new Point3d(posX, posY, posZ), Double.POSITIVE_INFINITY );
light.setInfluencingBounds( bounds ); // 描画範囲の定義
light.setEnable( true );
return light;
}
// ---------- 球の設定を行うノード ------------ //
public Node createSphere( Vector3d vector, Color3f color ) {
Transform3D translation = new Transform3D();
translation.setTranslation( vector );
TransformGroup transform = new TransformGroup( translation );
/***** 外観に関する設定 *****/
Appearance appearance = new Appearance();
Material material = new Material();
material.setDiffuseColor( color ); // 球体の色の設定
material.setLightingEnable( true );
appearance.setMaterial( material );
現在Java3Dで作った3DチャットをJava Web Startで配信してい
ます。ユーザが通常の方法でJava3Dをインストールしても
Java自体の最新アップデートでアプリが動かなくなってしまう
ため、j3d-websartでJava3DのライブラリをJava Web Start
配信するように変更しました。
このj3d-webstartのページ
https://j3d-webstart.dev.java.net/
を見ると、どうやらMac OS Xがサポートされているようです
ので早速試したところ、Canvas3D作るあたりでJavaVM自体が
お亡くなりになりました(泣)。
コンソールまでパッと消えてなくなります。