Earth Moon Phases Tutorial

by Bernard Agnamazian

This tutorial will help you to understand some of the basic capabilities of J3DWorkbench.

We will create a simplified simulation of the solar system with the Earth orbiting around the Sun, and the Moon orbiting around the Earth. The light coming from Sun will highlight the moon phases and the Earth's seasons.

One View (i.e. 'camera') is arbitrarily situated in the solar system, and another View is placed in the Earth's frame of reference, showing the Moon phases as seen from Earth.

Click here to download the finished scene, or the textures used in its composition.

Some J3DWorkbench features used:

Object Wizard
Branch Group
Views
Lights
RotationInterpolators
Texture Generator
Keystrocke Trigger
Switch Node

Main Scene creation

Sun, Earth and Moon creation

Choose a Sphere made of 512 Facets and a Radius of 1

	Insert>Object Wizard ...>Shape Wizard>Sphere 

Increase its size by using its SCALE property in the Properties panel

	TRANSFORM>SCALE>X & Y & Z = 1.2


Change the name (NAME) to "Sun" in the Properties panel. Do the same for Earth (SCALE = 1)

Next, we will set the Earth in its orbit and animate it. This is accomplished by using a RotationInterpolator.

Interpolators act on their child node by 'interpolating' between certain configurable values, often in a cyclical fashion. RotationInterpolators set rotation motion to their children.

Add a new RotationInterpolator to the Scene.

	Insert>Interpolators ...>New RotationInterpolator

Change the name to 'Earth - Moon revolution + rotation'
Set the rotation speed (here 1 second = 1 day) :

	ALPHA>INCREASE_DURATION = 365250(milliseconds)  
Set the angle of rotation (Here it is a whole rotation of 360 degrees) :
	ANGLE BEGIN = 0 ANGLE END = 360 
Note : This will generate a Clockwise rotation. For an Anti Clockwise rotation swap these two values. LOOP_COUNT = -1 (continuous rotation) Set the translation which will be applied to the "Earth - Moon system", resulting in an orbit.
	TRANSFORM>TRANSLATION>X = 20
Consider the following coordinate system



Note : A transformation (rotation, translation ...) is always done in the local frame of reference of the object. If an object for example, has its rotation set to a certain value, and a translation set on the 'Z' axis, it will look like the following:



Note: On the other hand, if an object inherits a rotation from its parent (e.g. from a RotationIterpolator), then its local frame of reference is rotated. As a result, a 'Z' translation on this object will look like this (Earth - Moon case):


If the rotation is constantly changing, then the result is an orbit around the original, non-translated position.

Create a group of objects which will contain the ensemble "Earth - Moon". NAME = Earth Moon Group

	Insert>New Branch Group
Place the Earth in this group, and this group in the RotationInterpolator. Use the drag & drop facility.

Tilt the Earth's axis against the main plane (ecliptic)

	Earth group>TRANSFORM>ROTATION> X = 23.7 (degrees)
	
Note : X is the axis around which the object is rotated.

Test this ensemble by enabling it : Right click on "Earth - Moon revolution + rotation" RotationIterpolator, and then click Turn ON

Note : A rotation is always done around a local axis of the object it belongs to (here the Earth frame of reference), not around an absolute frame of reference (in our case the Sun frame of reference)

Keep the Earth's axis constant against the ecliptic

In order to keep the Earth's axis constant in the Sun's' frame of reference, we have to compensate for the Earth's revolution around the Sun by using a counter rotation of one revolution (1 day).

This does not happen to the moon. The moon presents the same face to the Earth, and hence its axes are constant in the Earth's frame of reference (one of the odd things about our solar system is that the orbit of the moon is equal to its revolution : 28 days for one loop around the Earth and 28 days for one spin with respect to Sun's frame of reference).





Create a RotationInterpolator

	NAME = "Cancels axis rotation induced by earth revolution (axes constant in main ref frame)"
	
	ALPHA>INCREASE_DURATION = 1000 (equivalent to 1 day) 
	      ANGLE BEGIN = 360 (opposite of above)
	      ANGLE END = 0 
	      LOOP_COUNT = -1 
Insert the Earth into this RotationInterpolator, and this RotationInterpolator into the "Earth Moon Group (axes constant in main frame of ref.)" (use the drag and drop feature).


Enable this rotation.

Create the Earth rotation by adding another RotationIterpolator inside the Earth group.

	NAME = "Earth rotation"
	ALPHA>INCREASE_DURATION = 1000 (equivalent to 1 day)
	      ANGLE BEGIN = 0 
	      ANGLE END = 360 
	      LOOP_COUNT = 1

Because this ensemble, rotation+Earth must be tilted at 23.7 degrees let's create a group which will contain this new Earth rotation + the Earth itself, and set the tilt on this group.



Note : All objects contained in this frame of ref. will be (automatically) tilted against the main frame of ref..

In the same way, add the Moon and its rotation + tilt to the "Earth Moon Group":
	
	Moon Properties : 	 SCALE = 0.5, TRANSLATION = 5.5
	Moon Group Tilt :	 ROTATION>X = 5.1
	Moon Revolution Period : INCREASE_DURATION> = 27322 

Decoration

Textures

Add the texture to the Earth :
	Earth Properties>APPEARANCE>TEXTURE>Create New ...
then click on

Now let's create the background :

The Cube is mapped to the background and the texture is mapped onto the Cube. This has the effect of drawing the texture at a distance which is equivalent to infinity.
As the view is from inside the cube, you cannot see its texture. Make it visible from inside by setting :
	Cube properties>APPERANCE>CULL_FACE = FRONT
Add a 'hot, turbulent' effect to the Sun: Create a "Noise Texture Generator":
	Insert>Effects ...>New Texture Generator
Drop the Sun into it.
Set
	FPS=10
(for example) and enable it.

Lights

In order to simulate the sun's radiance, let's create a directional light pointing towards the Moon - Earth system.
	Insert>Lights ... >New Directional light
Drop it in the "Earth Moon Group" in order to have this spotlight constantly directed toward the Earth and Moon, and rotating with them.
Set the direction opposite the sun. i.e. a rotation of 180 degree around the Y axis :
	Directional Light properties>TRANSFORM>ROTATION=180
Adjust the color:
	Light properties>COLOR = RGB{255,251,219}
	
Decrease the default color of the "Ambient light" (created by default with the scene).
	Ambient light properties>COLOR = RGB{80,80,80}

Orbit Path Indicator

Create a Torus for the orbits of the Earth and the Moon:
	Insert>Object Wizard ...>Shape Wizard>Torus
	Facets=512 
	Inner Radius = 0.01
	Outer Radius = 20 for Earth and 5.5 for Moon
	
Drop the Moon Orbit in the group "Moon"


Season Labels

Create a text label on an invisible panel :
	Insert>Object Wizard ...>Shape Wizard>Text2D Wizard
Text to Render = Spring

Choose a color (green for Spring!)

Check off "Oriented to View" in order to have the text panel constantly oriented toward the camera



Set its position :
	TRANSLATION>X = -20, TRANSLATION>Y = 1
Do the same for the other seasons:
	Summer : TRANSLATION>Z=20, TRANSLATION>Y=1
	Autumn : TRANSLATION>X=20, TRANSLATION>Y=1
	Winter : TRANSLATION>Z=-20, TRANSLATION>Y=1

Miscellaneous

Earth View

In order to observe the moon phases seen from the Earth, let's create a new view which will be fixed with respect to the Earth and oriented toward the Moon :
	Insert>New View
Drop this new View in the Moon group.

Use the navigation facility to position the camera so that you can see the moon phases changing with time. For details about using the mouse and keyboard arrows to navigate the View, please see Help topic: Navigation and Object Manipulation


You can even detach the View frame from the Workbench! Right click on the View tab, and choose Detached

Animation Interaction

You can interact with the Interpolators, the Lights, the Effects etc ... by typing a key on your keyboard.

KeyStrokeTrigger allows you to enable or disable its direct relative object, child or parent.
The following parameters of this object permit the control of the object by the KeyStrokeTrigger.

	TRIGGERS>TRIGGERED_BY_PARENT (default value) 
		 TRIGGERED_BY_CHILD  


	Insert>BehaviorsNew KeystrokeTrigger

Select the key which will be used to trigger enable or disable the involved object
	KEYSTROKE = space (default value)
	

Drop the "Earth - Moon revolution + rotation" interpolator in this KeyStrokeTrigger

You have also the possibility to make appear or disappear (visible or not) the objects in the scene.
The Switch Node will hide or show its child objects.

	Insert>Behaviors New Switch Node
Put all the Season labels into this Switch, and this Switch into a new KeyStrokeTrigger with :
	KEYSTROKE = "s"

Do the same for the Moon and Earth orbit :
	KEYSTROKE = "o"
Now you can turn on or off the labels or orbital path indicators, using the keys 's' and 'o'.

Help text

Coming soon ...