本文整理汇总了Java中com.sun.j3d.utils.universe.SimpleUniverse.addBranchGraph方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleUniverse.addBranchGraph方法的具体用法?Java SimpleUniverse.addBranchGraph怎么用?Java SimpleUniverse.addBranchGraph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.j3d.utils.universe.SimpleUniverse
的用法示例。
在下文中一共展示了SimpleUniverse.addBranchGraph方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Java3DPanel
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
Java3DPanel() {
super();
setLayout(new BorderLayout());
Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
add(canvas3D);
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
simpleU.getViewingPlatform().setNominalViewingTransform();
try {
BranchGroup branchGroup = new BranchGroup();
TransformGroup transformGroup = getInteractiveTransformGroup();
branchGroup.addChild(transformGroup);
buildScene(transformGroup);
branchGroup.compile();
simpleU.addBranchGraph(branchGroup);
} catch (Exception e) {
e.printStackTrace();
}
setVisible(true);
}
示例2: J3dTest
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public J3dTest(){
// 创建一个虚拟空间
SimpleUniverse universe = new SimpleUniverse();
// 创建一个用来包含对象的数据结构
BranchGroup group = new BranchGroup();
// 创建一个球并把它加入到group中
Sphere sphere = new Sphere(0.5f); // 小球的半径为0.5米
group.addChild(sphere);
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 light1= new DirectionalLight(light1Color, light1Direction);
// 指定颜色和方向,产生单向光源
light1.setInfluencingBounds(bounds);
// 把光线的作用范围加入光源中
group.addChild(light1);
// 将光源加入group组,安放观察点
universe.getViewingPlatform().setNominalViewingTransform();
// 把group加入到虚拟空间中
universe.addBranchGraph(group);
}
示例3: Points3DPanel
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public Points3DPanel(PointsShape ptsShape) {
setLayout(new BorderLayout());
setOpaque(false);
setPreferredSize(new Dimension(PWIDTH, PHEIGHT));
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add("Center", canvas3D);
canvas3D.setFocusable(true);
canvas3D.requestFocus(); // the canvas now has focus, so receives key
// events
su = new SimpleUniverse(canvas3D);
createSceneGraph(ptsShape);
initUserPosition(); // set user's viewpoint
orbitControls(canvas3D); // controls for moving the viewpoint
su.addBranchGraph(sceneBG);
}
示例4: MainApp
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
/** Creates a new instance of MainApp
* Create a simple scene and attach it to the virtual universe
*
*/
public MainApp(String[] args) {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add("Center", canvas3D);
// SimpleUniverse is a Convenience Utility class
simpleU = new SimpleUniverse(canvas3D);
// This will move the ViewPlatform back a bit so the
// objects in the scene can be viewed.
simpleU.getViewingPlatform().setNominalViewingTransform();
BranchGroup scene = createSceneGraph(args.length > 0);
orbitControls(canvas3D);
simpleU.addBranchGraph(scene);
}
示例5: init
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
protected void init()
{
Node plot = createPlot();
BranchGroup scene = defineMouseBehaviour(plot);
setupLights(scene); // Surface plot wants an extra light
scene.compile();
universe = new SimpleUniverse(this);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(scene);
if (parallelProjection) {
setProjectionPolicy(universe, parallelProjection);
}
init = true;
}
示例6: Points3DPanel
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public Points3DPanel(PointsShape ptsShape) {
setLayout(new BorderLayout());
setOpaque(false);
setPreferredSize(new Dimension(PWIDTH, PHEIGHT));
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add("Center", canvas3D);
canvas3D.setFocusable(true);
canvas3D.requestFocus(); // the canvas now has focus, so receives key
// events
su = new SimpleUniverse(canvas3D);
createSceneGraph(ptsShape);
initUserPosition(); // set user's viewpoint
orbitControls(canvas3D); // controls for moving the viewpoint
su.addBranchGraph(sceneBG);
}
示例7: Main3D
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public Main3D() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse
.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
add(canvas, BorderLayout.CENTER);
universe = new SimpleUniverse(canvas);
// �V�[�����\�z
BranchGroup scene = createSceneGraph();
scene.compile();
// ���_���Z�b�g
universe.getViewingPlatform().setNominalViewingTransform();
// �}�E�X����
orbitControls(canvas);
universe.addBranchGraph(scene);
}
示例8: MainPanel
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public MainPanel() {
setPreferredSize(new Dimension(WIDTH, HEIGHT));
setLayout(new BorderLayout());
// 3D���f����`�悷��L�����p�X���쐬
GraphicsConfiguration config = SimpleUniverse
.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add(canvas3D, BorderLayout.CENTER);
canvas3D.setFocusable(true);
canvas3D.requestFocus();
// ���E���쐬
universe = new SimpleUniverse(canvas3D);
createSceneGraph(); // ���E�i�V�[���O���t�j���\�z
initUserPosition(); // ���[�U�̎��_��������
orbitControls(canvas3D); // �}�E�X����
universe.addBranchGraph(sceneBG);
}
示例9: Main
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public Main() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse
.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
add(canvas, BorderLayout.CENTER);
universe = new SimpleUniverse(canvas);
// �V�[�����\�z
BranchGroup scene = createSceneGraph();
scene.compile();
// ���_���Z�b�g
universe.getViewingPlatform().setNominalViewingTransform();
// �}�E�X����
orbitControls(canvas);
universe.addBranchGraph(scene);
}
示例10: Main
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public Main() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse
.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
add(canvas, BorderLayout.CENTER);
universe = new SimpleUniverse(canvas);
// �V�[�����\�z
BranchGroup scene = createSceneGraph();
scene.compile();
// ���_���Z�b�g
Transform3D viewPlatformTransform = new Transform3D();
viewPlatformTransform.setTranslation(new Vector3d(0.0, 0.0, 10.0));
universe.getViewingPlatform().getViewPlatformTransform().setTransform(viewPlatformTransform);
// �}�E�X����
orbitControls(canvas);
universe.addBranchGraph(scene);
}
示例11: CrystalBall
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public CrystalBall() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse
.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
add(canvas, BorderLayout.CENTER);
universe = new SimpleUniverse(canvas);
// �V�[�����\�z
BranchGroup scene = createSceneGraph();
scene.compile();
// ���_���Z�b�g
universe.getViewingPlatform().setNominalViewingTransform();
// �}�E�X����
orbitControls(canvas);
universe.addBranchGraph(scene);
}
示例12: RotatingCube
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public RotatingCube() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
add(canvas, BorderLayout.CENTER);
SimpleUniverse universe = new SimpleUniverse(canvas);
// �V�[�����\�z
BranchGroup scene = createSceneGraph();
scene.compile();
// ���_���Z�b�g
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(scene);
}
示例13: init
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public void init()
{
setLayout(new BorderLayout());
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
add("Center", c);
// Create a simple scene and attach it to the virtual universe
BranchGroup scene = createSceneGraph();
u = new SimpleUniverse(c);
// This will move the ViewPlatform back a bit so the
// objects in the scene can be viewed.
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(scene);
}
示例14: createUniverse
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
/**
* Returns a new 3D universe that displays <code>home</code> objects.
*/
private SimpleUniverse createUniverse(boolean displayShadowOnFloor, boolean listenToHomeUpdates,
boolean waitForLoading)
{
// Create a universe bound to no canvas 3D
ViewingPlatform viewingPlatform = new ViewingPlatform();
// Add an interpolator to view transform to get smooth transition
TransformGroup viewPlatformTransform = viewingPlatform.getViewPlatformTransform();
CameraInterpolator cameraInterpolator = new CameraInterpolator(viewPlatformTransform);
cameraInterpolator.setSchedulingBounds(new BoundingSphere(new Point3d(), 1E7));
viewPlatformTransform.addChild(cameraInterpolator);
viewPlatformTransform.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
Viewer viewer = new Viewer(new Canvas3D[0]);
SimpleUniverse universe = new SimpleUniverse(viewingPlatform, viewer);
View view = viewer.getView();
view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
// Update field of view from current camera
updateView(view, this.home.getCamera(), this.home.getTopCamera() == this.home.getCamera());
// Update point of view from current camera
updateViewPlatformTransform(viewPlatformTransform, this.home.getCamera(), false);
// Add camera listeners to update later point of view from camera
if (listenToHomeUpdates)
{
addCameraListeners(view, viewPlatformTransform);
}
// Link scene matching home to universe
universe.addBranchGraph(createSceneTree(displayShadowOnFloor, listenToHomeUpdates, waitForLoading));
return universe;
}
示例15: Visualizer3D
import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public Visualizer3D(World world) {
this.world = world;
setSize(640, 480);
setDefaultCloseOperation(EXIT_ON_CLOSE);
GraphicsConfiguration gc = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(gc);
getContentPane().add(canvas);
universe = new SimpleUniverse(canvas);
universe.getViewer().getView().setBackClipDistance(100000.0);
viewerTransformGroup = universe.getViewingPlatform().getViewPlatformTransform();
createEnvironment();
for (WorldObject object : world.getObjects()) {
if (object instanceof KinematicObject) {
BranchGroup bg = ((KinematicObject) object).getBranchGroup();
if (bg != null) {
universe.addBranchGraph(bg);
}
}
}
setVisible(true);
Matrix3d mat = new Matrix3d();
Matrix3d mat1 = new Matrix3d();
mat.rotZ(Math.PI);
mat1.rotY(Math.PI / 2);
mat.mul(mat1);
mat1.rotZ(-Math.PI / 2);
mat.mul(mat1);
viewerTransform.setRotation(mat);
}