Hierarchical Motion Explained
Building a Solar System
 More of this Feature
• Part 2: Adding the Moon
 
 Join The Discussion
"...truly scaleable to the dynamic bandwidth availability?"
MORAB2
 
 Related Resources
• Tutorials
• FAQs
 
 From Other Guides
• Real Space Stuff
• Astronomy for Kids
• What is XHTML and XML?
 
 Elsewhere On The Web
• VRML Repository
• 3DEZine
 

Dateline: 10/18/00

very little solar system
A little solar system

What do a human body and a solar system have in common? Hierarchical motion, of course! Hierarchy, as applied to motion, is just a big word for performing the motions in a very specific order.

We're going to look at this with VRML but it's applicable to all types of computer graphics systems. First the mechanics. Let's create a tiny solar system consisting of the Sun, Earth and Moon. In terms of geometry that's just going to be three spheres with different colors and radii.

Shape {
		appearance Appearance {
			material Material {
			# a green earth
				diffuseColor 0 0.7 0
			}
		}
		geometry Sphere	{ radius 0.5 }
	}

Next we're going to need a clock to count time and a couple of OrientationInterpolators to compute the rotations.

DEF	Year TimeSensor {
	cycleInterval 12
	loop TRUE 
}

DEF	EarthOrbit OrientationInterpolator {
	key	[0.0, 0.5, 1.0]
	keyValue [
		0.0 1.0 0.0 0.0,
		0.0 1.0 0.0 3.14,
		0.0 1.0 0.0 6.28
	]
}

Now on to the issue at hand. In order to place the Earth into orbit around the Sun we must use the Transform node to position the objects. In fact the Transform node is the key portion. The Transform node contains the information for positioning and the rotation of the objects. Since we want the Earth to travel around the Sun we must direct it to rotate around the position of the Sun.

If the Sun is left at the default position of 0,0,0 we must position the Earth some distance away. We can do this quite easily using the translation field of the Transform node. We need to wrap a Transform Node around the geometry of the Earth which we can do as follows:

DEF Earth Transform {
		translation	10 0 0
		children Shape {
				appearance Appearance {
					material Material {
						diffuseColor 0 0.7 0
					}
				}
				geometry Sphere	{ radius 0.5 }
		}
}

This will place the Earth 10 units away from the Sun.

Now let's get things moving.

Next page > Moving Along > Page 1, 2