Class PrismCmd

java.lang.Object
com.j3d.engine.interact.cmd.base.Command
com.j3d.engine.interact.cmd.commands.PrismCmd
All Implemented Interfaces:
KeyedStatefulCommand, SemiStatefulCommand, StatefulCommand<Void>

public class PrismCmd extends Command implements KeyedStatefulCommand
A command to create a prism.

This command allows the user to define a prism by specifying the centre points and defining planes for its top and bottom faces. It als allows interactive adjustment of the prism's radius and number of sides using arrow keys, and provides a "gear" system to control the step size of radius adjustments.

The command operates in a stateful manner, displaying a visual ghost of the prism as it's being defined. Users can commit the prism creation with 'Enter' or cancel with 'Escape'.

Typical Usage:

  prism (0,0,0) (0,10,0) (1,0,0) (0,0,1) - Creates a 3-sided prism (triangle) with radius 5,
                                            bottom center at (0,0,0), top center at (0,10,0),
                                            and faces aligned with the XZ plane.
  p (1,1,1) (1,5,1) (1,0,0) (0,1,0) (1,0,0) (0,1,0) - Creates a prism with custom top and bottom plane definitions.
  p plane:"xy" (0, 1, 0) (0, 10, 0)       - Creates a prism who's faces lie on the XY plane using unordered
                                          tagged arguments
  p (0, 1, 0) (0, 10, 0)                  - Creates a prism who's faces are aligned with the XZ plane.
  
Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • gearTrain

      protected double[] gearTrain
      An array of step sizes (e.g., 1, 5, 20) that the user can cycle through.
    • currentIndex

      protected int currentIndex
      The index of the currently active step size in the gearTrain.
    • gear

      protected J3Key gear
      The keybinding used to cycle through the gearTrain step sizes.
    • keys

      protected ArrayList<J3Key> keys
      A list of temporary keybindings (e.g., arrow keys) active during this state.
    • bottomFaceCenter

      Vector3 bottomFaceCenter
    • topFaceCenter

      Vector3 topFaceCenter
    • bottom

      AxisPlane bottom
    • top

    • radius

      int radius
    • sides

      int sides
    • overlapId

      UUID overlapId
  • Constructor Details

    • PrismCmd

      public PrismCmd()
  • Method Details

    • editRadius

      private void editRadius(boolean add)
    • editSides

      private void editSides(boolean add)
    • run

      public void run(Invoker invoker, SafeJLabel logLabel, String aliasUsed, Object[] args, ArrayList<TaggedArgValue<?>> taggedArgs)
      Description copied from class: Command
      The method to be overridden by subclasses to implement command functionality.
      Overrides:
      run in class Command
      Parameters:
      invoker - The invoker of this command
      logLabel - The JLabel to display log messages.
      aliasUsed - The alias of the command that was used to invoke it.
      args - The arguments passed to the command.
      taggedArgs - Tagged arguments passed to the command.
    • onStart

      public void onStart(Void object, SafeJLabel label)
      Description copied from interface: StatefulCommand
      Called when the command is first started.
      Specified by:
      onStart in interface StatefulCommand<Void>
      Parameters:
      object - The object that the command operates on.
      label - The SafeJLabel instance.
    • onEnter

      public void onEnter(Void object, SafeJLabel label)
      Description copied from interface: StatefulCommand
      Called when the 'Enter' key is pressed.
      Specified by:
      onEnter in interface StatefulCommand<Void>
      Parameters:
      object - The object that the command operates on.
      label - The SafeJLabel instance.
    • onEsc

      public void onEsc(Void object, SafeJLabel label)
      Description copied from interface: StatefulCommand
      Called when the 'Escape' key is pressed.
      Specified by:
      onEsc in interface StatefulCommand<Void>
      Parameters:
      object - The object that the command operates on.
      label - The SafeJLabel instance.
    • finished

      public void finished(boolean success, SafeJLabel label)
      Description copied from interface: KeyedStatefulCommand
      Method which clears all state related to this which can be
      • keys
      • ghost previews
      • temporary listeners
      • ...
      Specified by:
      finished in interface KeyedStatefulCommand
      Parameters:
      success - Whether the command finished successfully or not. if the user had clicked escape or an error occurred that counts as an unsuccessful invocation
      label - The label.
    • getKeys

      public ArrayList<J3Key> getKeys()
      Description copied from interface: KeyedStatefulCommand
      Gets the list of temporary J3Keys that are active during this command's state.
      Specified by:
      getKeys in interface KeyedStatefulCommand
      Returns:
      An ArrayList of active keys.
    • selfName

      public String selfName()
      Description copied from interface: KeyedStatefulCommand
      Returns the name of the specific command instance, used for creating unique key IDs.
      Specified by:
      selfName in interface KeyedStatefulCommand
      Returns:
      The name of the command.
    • getGearTrain

      public double[] getGearTrain()
      Description copied from interface: KeyedStatefulCommand
      Gets the array of available step sizes for the transformation (the "gear train").
      Specified by:
      getGearTrain in interface KeyedStatefulCommand
      Returns:
      An array of doubles representing different step magnitudes.
    • getGearIndex

      public int getGearIndex()
      Description copied from interface: KeyedStatefulCommand
      Gets the index of the currently active step size in the gear train.
      Specified by:
      getGearIndex in interface KeyedStatefulCommand
      Returns:
      The current gear index.
    • setGearIndex

      public void setGearIndex(int index)
      Description copied from interface: KeyedStatefulCommand
      Sets the current gear index, allowing the command to cycle through step sizes.
      Specified by:
      setGearIndex in interface KeyedStatefulCommand
      Parameters:
      index - The new gear index.