The Commands Panel

CommandsPanel creates the panel at the bottom of the GUI containing the text field and Reset button. Much of the code deals with the parsing of the input from the text field, which takes two forms. A limb command has the following format:

    ( <limbName> | <limbNo> ) (fwd | f | turn | t | side | s) [ angleChg ]

A figure command has this format:

    (fwd | f | back | b | left | l | right | r | up | u | down | d | clock | c | cclock | cc)

Each moveable limb is assigned a name and number, and either one can be used to refer to the limb. As a convenience, the name/number mappings are printed to standard output when Mover3D is started.

The principal difference between the limb and figure commands is that a limb command needs to refer to a particular limb, and a figure command applies to the entire figure. A limb command can include a rotation value (angleChg).

The rotation operations refer to the three axes:

fwd (or f )

Rotation around x-axis

turn (or t )

Rotation around y-axis

side (or s )

Rotation around z-axis

Tip

If an angleChg value isn't included, a rotation of +5 degrees will be carried out.

Each limb has a predefined maximum positive and negative rotation, and a rotation command will only move a limb to the prescribed limit.

An advantage of text field input is the ability to group several limb and/or figure commands together, separated by commas. These are processed before the figure is redrawn. By pressing Enter, a complex sequence of commands is repeated. This can be seen ...

Get Killer Game Programming in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.