How to Create the Solar System in Java 3D

Written by antonin korenek
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Create the Solar System in Java 3D
Creating a solar system in Java can be a rewarding experience. (sonnensystem image by Marvin Gerste from

Java 3D is a graph-based modelling application for the Java platform. It is unlike most 3D modelers as you do not create objects by dragging and dropping. In Java 3D, you code manually. Creating a solar system is time-consuming as each object must be coded individually.

Skill level:

Other People Are Reading


  1. 1

    Study Java and Java 3D coding. Purchase books on these topics and see the links under Resources.

  2. 2

    Download, install and run solar system models. Look at the source code. Do not copy the code, as that is plagiarism.

  3. 3

    Open the Java 3D application.

  4. 4

    Create the sun, the central object of the solar system. Code in lighting to give it a 3D feel. Input the following code from the website Java3D to create a ball with light hitting it:

    import com.sun.j3d.utils.geometry.*;

    import com.sun.j3d.utils.universe.*;


    import javax.vecmath.*;

    public class Ball {

    public Ball() {

    SimpleUniverse universe = new SimpleUniverse();

    BranchGroup group = new BranchGroup();

    Sphere sphere = new Sphere(0.5f);


    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 light 1

      = new DirectionalLight(light1Color, light1Direction);






    public static void main(String[] args) { new Ball(); }


  5. 5

    Place the sun in the middle. Typically the coordinates will be (0,0,0) unless you want your solar system angled.

  6. 6

    Set the object's texture and colour. This makes the object look more realistic. Choose colours to mix with the following code:

    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);

    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);

    Color3f yellow = new Color3f(0.7f, .15f, .15f);

    TextureLoader loader = new TextureLoader("K:\3d\Arizona.jpg",

      "LUMINANCE", new Container());

    Texture texture = loader.getTexture();



    texture.setBoundaryColor( new Color4f( 0.0f, 1.0f, 0.0f, 0.0f ) );

  7. 7

    Add code that alters the texture. There are four ways a texture can be displayed; blended, decaled, replaced or modulated. The modulated option provides the most realistic result. Here is sample code for modulating:

    TextureAttributes texAttr = new TextureAttributes();


    Appearance ap = new Appearance();

    ap.setMaterial(new Material(red, black, red, black, 1.0f));

  8. 8

    Repeat Steps 4-7 for every object in the solar system.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.