📄 copyofball.java
字号:
package csu.chailei.test;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.geometry.Box;
import javax.media.j3d.Appearance;
import javax.vecmath.*;
public class CopyOfBall {
/**
* @param args
*/
public CopyOfBall()
{
//new Universe
SimpleUniverse universe=new SimpleUniverse();
//new Branch
BranchGroup group=new BranchGroup();
//new a spere add group
Sphere sphere=new Sphere(0.3f);
Sphere sphere2=new Sphere(0.2f);
Cone con=new Cone(0.1f,0.1f);
group.addChild(sphere);
//group.addChild(sphere2);
TransformGroup tg=new TransformGroup();
//tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
TransformGroup tg1=new TransformGroup();
Transform3D tf3D=new Transform3D();
Transform3D tf3D1=new Transform3D();
Vector3f vector=new Vector3f(.0f,0.4f,.0f);
Vector3f vectorcon=new Vector3f(0.4f,.0f,.0f);
tf3D.setTranslation(vector);
tf3D1.setTranslation(vectorcon);
tg.setTransform(tf3D);
tg1.setTransform(tf3D1);
tg.addChild(sphere2);
tg1.addChild(con);
group.addChild(tg1);
group.addChild(tg);
///
Alpha rotationAlpha = new Alpha(-1, 8000);
RotationInterpolator rotator =
new RotationInterpolator(rotationAlpha, tg, tf3D,
0.0f, (float) Math.PI*2.0f);
BoundingSphere bound =
new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
rotator.setSchedulingBounds(bound);
group.addChild(rotator);
// Appearance ap=new Appearance();
// Color3f ac=new Color3f(1.2f,1.1f,0.1f);
// ColoringAttributes c=new ColoringAttributes(ac,1);
//
// ap.setColoringAttributes(c);
// Box b=new Box(0.3f,0.3f,0.3f,ap);
// group.addChild(b);
//Appearance a=new Appearance();
//new a light
Color3f lightColor=new Color3f(1.8f,0.1f,0.1f);//color
BoundingSphere bounds=new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0);//point radium
Vector3f lightDirection=new Vector3f(-8.0f,-7.0f,-12.0f);//derection
DirectionalLight light1=
new DirectionalLight(lightColor,lightDirection);
light1.setInfluencingBounds(bounds);
group.addChild(light1);
//view spere
universe.getViewingPlatform().setNominalViewingTransform();
//add to universe
universe.addBranchGraph(group);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new CopyOfBall();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -