English 中文(简体)
在Java3D的0-1.0至1.0米范围内只可见一物体的翻译位置
原标题:Translation position of an object only visible in the -1.0 to +1.0 range in Java3D
  • 时间:2011-10-17 15:48:27
  •  标签:
  • java
  • java-3d

在贾瓦,我几乎没有什么方案可以展示两个领域。 在我翻译一个领域从0到1.0不等之前,它会进行罚款,本案的标语将消失。 我有一个简单的联邦制,我曾在几个地方尝试过几套联邦制,但我无法指出,它是如何消失的。 真正的奇怪态度是,这种立场取决于摄像头的位置,因为我有一位OrbitBehavior on the ViewPlatform transformation at changing don t就显示物体。

This is the setup for the spheres: public class CelestialBody extends TransformGroup {

    CelestialBody(float posX, float posY, float posZ) {
        // This is set for the dynamic behaviour.
        setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

        Transform3D t3d = new Transform3D();
        t3d.setTranslation(new Vector3f(posX, posY, posZ));
        setTransform(t3d);
        setBounds(new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f), 10000.0f));

        Sphere sphere = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 100, createAppearance());

        addChild(sphere);
    }

    private Appearance createAppearance() {
        Appearance appear = new Appearance();
        Material mat = new Material();
        mat.setShininess(100.0f);
        appear.setMaterial(mat);

        return appear;
    }
}

这是主要方案:

public class CelestialApp extends Frame {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new CelestialApp();
    }

    private SimpleUniverse universe = null;

    public CelestialApp() {
    // ...

        BranchGroup scene = constructContentBranch();
        scene.compile();

        universe = new SimpleUniverse(defaultCanvas);
        setupView();
        universe.addBranchGraph(scene);
    }

    private void setupView() {
        ViewingPlatform vp =  universe.getViewingPlatform();
        OrbitBehavior orbit = new OrbitBehavior();
        orbit.setSchedulingBounds(new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f), 10000.0f));
        vp.setNominalViewingTransform();
        vp.setViewPlatformBehavior(orbit);
    }

    private BranchGroup constructContentBranch() {
        BranchGroup scene = new BranchGroup();

        CelestialBody body1 = new CelestialBody(-2.0f, 0.0f, 0.0f);
        scene.addChild(body1);

        CelestialBody body2 = new CelestialBody(2.0f, 0.0f, -1.1f);
        scene.addChild(body2);

        PhysicalBehavior physics1 = new PhysicalBehavior(body1);
        scene.addChild(physics1);

        PhysicalBehavior physics2 = new PhysicalBehavior(body2, new Vector3d(0.0f, 0.0f, 0.0f));
        scene.addChild(physics2);

        setupLights(scene);

        return scene;
    }

    private void setupLights(BranchGroup scene) {
        AmbientLight lightA = new AmbientLight();
        lightA.setInfluencingBounds(new BoundingSphere());
        lightA.setColor(new Color3f(0.3f, 0.3f, 0.3f));
        scene.addChild(lightA);

        DirectionalLight lightD1 = new DirectionalLight();
        lightD1.setInfluencingBounds(new BoundingSphere());
        Vector3f dir = new Vector3f(-0.3f, -1.0f, -0.5f);
        dir.normalize();
        lightD1.setDirection(dir);
        lightD1.setColor(new Color3f(1.0f, 1.0f, 1.0f));
        scene.addChild(lightD1);

        Background bg = new Background(0.0f, 0.0f, 0.0f);
        bg.setApplicationBounds(new BoundingSphere());
        scene.addChild(bg);
    }
}
最佳回答

巴哈教徒永远不忘。 光电源只具有 bound1.0f的束缚范围,物体是用黑体提供的。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签