How to Create the Solar System in Java 3D

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.

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

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

Open the Java 3D application.

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






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


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

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",

Texture texture = loader.getTexture();



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

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:


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

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

Most recent