The magazine of the Melbourne PC User Group
Robots in stereo
Ken Holmes |
 |
In November 1995, ROBOTS3D.LZH was put on the BBS
and is not available for the link on this page. It was a version meant to be viewed with red/green goggles to
see various animated stick-figure animals(?) in stereo. As it was essentially a C++ programming exercise (to
keep me off the streets), it was placed in the programming file area. I don't know how many of the 100-odd
downloaders were interested in the C++ code included with the .EXE file, but hope they found running the
latter to be fun.
This version is meant for use with the old mirror trick. It allows the robots to be colour coded and have
black shadows, on a ground plane, which serves to define it without needing to draw "scenery" on it. They are
still wire frame models making no claims to realism, but they are mesmerising and you can control their modes
of activity, so they do seem to acquire a modicum of personality. ROBOTSMIR.LZH
is now available for download as it contains only the .EXE file and a text file you can print out, to help
with the keystrokes to get the most out of the program. The C++ code differs mainly in the calculations for
the display; anyone interested in it is welcome to contact me.
Dramatis personae
By using Class objects in C++, we may have as many clones as we wish, but have settled for eight Robobugs,
eight Robobats and four Robopedes. As you may note, the Robobug is a six-legged, camel-like insect of
ungainly gait and peculiar habits, plodding doggedly around a circuit of eight targets - until you interrupt
him/her/it. You can make any of them do a double shuffle, reverse, divert to a different target or circle
around a single target. The 20-legged Robopede (twentipede) has a sinusoidally undulating motion on rippling
legs and is content to crawl around a circuit of the targets or, alternately, vainly try to follow one of the
Robobugs. Both will find their way through the gaps between the row of square obstacles.
The fundamental method of control is to nominate the target for each animal; this may be either a fixed
target or a moving one, i.e. another animal. As they approach a fixed target, they are switched to the next
one around the circuit. Now we come to the stars of the show, the Robobats, da-daah; they can be switched to
14 different modes of activity. They will happily cruise the circuit, swooping down on each target and
climbing to cruising altitude in between. When a Robobug is allotted as a target for a Robobat, it is
constantly hassled by swooping attacks and tight circling returns. If two, three or four bats are targeted on
each other in an endless loop, they settle down to a stable circle - which can be distorted by varying the
speeds of individuals. If the leading bat is given a fixed target on the ground, it will circle it and the
others will fall in neatly behind in echelon formation - rather unconventional behaviour for bats, you will
agree. By targeting all followers directly onto the leader, with various speed control and lateral
displacement regimes, we can get formation flying in Vee, diamond, broad arrow and Y (sharp arrow).
With variations
The action may be seen from two different viewpoints
- a fixed point whence all may be seen
- a point above and behind the leading bat; a single key toggles between
these at any time.
T he second is more fun, particularly when the bat is hassling a bug - the
tight circles will make you dizzy. Also it is better for viewing the formation flying. The speed of the
leader may be varied to make it fly sedately behind its bug; it can hover, or fly backwards if you insist.
Reducing its speed in formations will confuse the followers and break up the formation but they will
(usually) re-form if speed is restored.
There are a few other variables not mentioned here. With permutations and combinations, it could tempt you to
while away some of your valuable time. You may even be inspired to extend the code to your taste.
Using the mirror
To see the picture in true 3D, you need a mirror, held vertically, facing left with its left edge up the
centreline of the picture and the surface at right angles to the page. Put the tip of your nose on the far
(from page) edge of the mirror; your right eye looks past the back of the mirror at the right side of the
page; your left eye ignores the left of the page but looks at its reflection in the mirror - it, of course,
appears on the right side. The objects on the right will appear in 3D stereo since each eye is seeing the
view calculated for it. The left eye view was calculated for the right side but mirror-flipped and plotted on
the left - the mirror reflection returns it to its proper place.
Reprinted from the August 1997 issue of PC Update, the
magazine of Melbourne PC User Group, Australia
|