This scene contains two butterflies. The first butterfly is in a Transform node that
is called Butterfly1. This Transform node contains two other Transform nodes, one for
the left wing and one for the right wing. The left wing contains two Shapes, one for the
top of the wing and one for the bottom of the wing.
All the geometry nodes are IndexedFaceSets. The geometry for the top of the left wing
is formed from the points (-0.89 0 0.67), (0 0 0.67), (0 0 -0.67), (-0.89 0 -0.67)
in the Coordinate subnode. The coordIndex field specifies that this points are to be
taken in order, which is counterclockwise around a rectangle. The normalPerVertex
field being FALSE means that there will be one normal for the face. Since the
rectangle is traversed counterclockwise, this normal will be vertical and equal
to (0, 1, 0). The TextureCoordinate node contains the vertices of the unit square
in the same order. This means that the ImageTexture "gauche.gif" will be applied
to the rectangle to cover it completely. The texture contains transparency. This means that
the rectangle will take the form of the wing. The other parts of the rectangle will
not be visible.
The bottom part of the wing is a rectangle containing the same points, but the coordIndex
specifies that they be taken in a different order. This time the points traverse clockwise,
so the normal will point downwards because this is a negative orientation. This means that
the image will appear on the underside of the rectangle.
Animation
There are two motions in getting the butterflies to fly. The first motion is the flapping
of the wings. This is accomplished by changing the rotation of the Transform nodes
Butterfly1LeftWing and Butterfly1RightWing which contain the wings.
Because the first butterfly is contained in the Butterfly1 Transform node, its movement
can be created be changing the translation and rotation fields of that node.
In xz coordinates the PositionInterpolator node specifies that the path of the butterfly is
a circle of radius 5. To make the flight path more interesting the y value has also been varied.
The cycleInterval is 20, so it takes 20 seconds to complete a circle. Because the
butterfly is rising and falling it must be rotated so that it is pointing in the direction that
it is travelling. These rotations were calculated from the direction of the path and put
into the OrientationInterpolator node.
The second butterfly is created in the same way but the TimeSensor cycleIntervals
are different to create interest.
Thanks to Christian Guillermet for supplying the images of the two butterflies from the
island of Reunion.