Class ExtrudeCmd

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

public class ExtrudeCmd extends Command implements KeyedStatefulCommand
A command to extrude a selected GTri (triangle) along its normal vector.

This command allows the user to interactively adjust the extrusion length and direction of a single selected triangle. A visual ghost of the extruded shape is displayed during the process.

Users can commit the extrusion with 'Enter' or cancel with 'Escape'. The extrusion length can be adjusted using the 'Up' and 'Down' arrow keys. The direction of extrusion (flipped along the normal) can be toggled using the 'Left' and 'Right' arrow keys. A "gear" system, activated by the 'R' key, controls the step size of length adjustments.

Typical Usage:

  // Select a single triangle first, then run the command
  extrude
  // Or specify the triangle directly by its UUID
  extrude a7e58b1c-2d3f-4a5b-6c7d-8e9f0a1b2c3d
  
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.
    • tri

      protected GTri tri
    • length

      double length
    • flipped

      boolean flipped
    • overlapId

      UUID overlapId
  • Constructor Details

    • ExtrudeCmd

      public ExtrudeCmd()
  • Method Details

    • 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.
    • ghost

      private void ghost(Graphics2D graphics2D)
    • getAllPoints

      private Pair<Triple<GPoint>,Triple<Vector3>> getAllPoints()
    • join

      private void join()
    • 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.