Complex 3D shapes often follow a natural hierarchy - a car has wheels, or a torso has arms and legs, etc. You can create a hierarchy in ShapeScript by using the group command:

group {
    position -0.5 0 0
    sphere {
        position 0 0 0
    cylinder {
        position 1 0 0

Like other 3D shapes, a group has a position and orientation in 3D space, but it can also contain child shapes which inherit its coordinate system; if you move the group, its children move with it. The position, orientation and size properties of the children will be treated as relative to those of the containing group.

You can override the current options (material, detail, etc.) at any point inside a group and only the subsequent children will be affected. You can also use relative transform commands to manipulate the position of subsequent shapes inside the group:

group {
    color 1 0 0
    translate 1
    color 0 1 0
    translate 1
    rotate 0.1
    scale 0.5
    color 0 0 1


Note: Changes made to properties such as transform or material are scoped to the group, and will not carry beyond the closing }.

Index | Next: Lights