Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6688985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:27:59+00:00 2026-05-26T05:27:59+00:00

I have a tiny little program in Java which supposed to display 2 spheres.

  • 0

I have a tiny little program in Java which supposed to display 2 spheres. It works fine until I the translation of a sphere gets out of the range of -1.0 to 1.0, the object in this case will disappear. I have a SimpleUniverse setup and I tried several setBounds in several places, but I couldn’t figure out, how is it disappear. The real strangeness, that this is position isn’t dependent on the camera position, as I have an OrbitBehavior on the ViewPlatform transform at moving closer doesn’t show the object.

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;
    }
}

This is the main program:

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);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:28:00+00:00Added an answer on May 26, 2026 at 5:28 am

    Bah, never mind. The light source had only a bounding sphere with radius 1.0f and the object was rendered but with black.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this tiny little issue with the datagrid. In my grid I have
OK, so I have this tiny little corner of my code where I'd like
I have 3 tiny files which I use to make a static library and
I have written a little script which retrieves pictures and movies from my camera
I have two tiny little problems; 1 . I want to add a previous
I have a teeny tiny little issue concerning a jQuery-based slideshow in Opera. What
I have a little problem with the width of the tiny carousel. I implemented
We have a big SVG object which we've fragmented into little pieces. Most of
I have this tiny Qt project with a project file like this: TEMPLATE =
I have a tiny (rikiki) problem in SWT ... I am making a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.