Class SceneManager

java.lang.Object
com.j3d.engine.scene.SceneManager

public class SceneManager extends Object
SceneManager is the class. The main class that handles the rendering of 3D objects onto a 2D screen.
See Also:
  • Field Details

    • screenSize

      public Dim screenSize
      The dimensions of the window.
    • layers

      public LayerList layers
      An Array of Layers
    • points

      public ArrayDeque<GPoint> points
    • unparented

      private final HashSet<HasParents<? extends GObject>> unparented
    • clipboard

      private ArrayList<GObject> clipboard
    • finder

      private final Finder finder
    • renderer

      private final SceneRenderer renderer
    • currentSelection

      private SelectionManager currentSelection
      The current selection made by the user.
    • overlaps

      private HashMap<UUID,Consumer<Graphics2D>> overlaps
      A list of overlap Runnables to be executed after rendering such that it's on top of everything else. This is not for UI but mainly for debugging purposes.
    • history

      public static final History history
      The history manager for undo/redo functionality.
    • usable

      private final String usable
      See Also:
  • Constructor Details

    • SceneManager

      public SceneManager(Dim dim)
      Default Constructor
      Parameters:
      dim - The dimensions of the screen
  • Method Details

    • finder

      public Finder finder()
    • getRenderer

      public SceneRenderer getRenderer()
    • usableLayer

      public Layer usableLayer()
    • axisGrid

      public void axisGrid(Graphics2D g, Camera camera)
    • axis

      public void axis(Graphics2D g, Camera camera)
      Draws the 3D Cartesian axes (X, Y, Z) in the scene, relative to the camera's position. The length of the axes is scaled based on the camera's distance from the origin.
      Parameters:
      g - The Graphics2D object to draw on.
      camera - The camera instance used for perspective transformation.
    • drawLine3D

      public void drawLine3D(Graphics2D g, Vector3 start, Vector3 end, Camera cam)
    • drawText3D

      public void drawText3D(Graphics2D g, Vector3 location, String text, Camera cam)
      Draws 3D text at a specified location in the scene.
      Parameters:
      g - The Graphics2D object to draw on.
      location - The 3D Vector3 coordinates where the text should be drawn.
      text - The string to be drawn.
      cam - The Camera instance used for perspective transformation.
    • drawText3D

      public void drawText3D(Graphics2D g, Vector3 location, String text, Camera cam, Color bgColor, Color fgColor)
      Draws 3D text at a specified location in the scene with custom background and foreground colors.
      Parameters:
      g - The Graphics2D object to draw on.
      location - The 3D Vector3 coordinates where the text should be drawn.
      text - The string to be drawn.
      cam - The Camera instance used for perspective transformation.
      bgColor - The background color for the text box.
      fgColor - The foreground color for the text.
    • drawPoly3D

      public void drawPoly3D(Graphics2D g, ArrayList<Vector3> points)
    • clear

      public void clear(Graphics2D graphics)
      "Clears" the screen by drawing a white box over it.
    • draw

      public void draw(Graphics2D graphics)
      Draws all objects in all layers to the screen.
      Parameters:
      graphics - The Graphics2D object to draw on.
    • scheduleOverlap

      public void scheduleOverlap(UUID id, Consumer<Graphics2D> r)
      Schedules an overlap Runnable to be executed after rendering.
      Parameters:
      r - The Runnable to execute.
    • removeOverlap

      public void removeOverlap(UUID id)
    • removeThing

      public void removeThing(Thing thing)
      Removes a Thing from its containing Layer.
      Parameters:
      thing - The Thing to be removed.
    • select

      public SelectionManager select(SelectionQuery selectionQuery)
      Updates the current selection based on the provided SelectionQuery.

      This method modifies the current selection according to the type specified in the selectionQuery:

      Parameters:
      selectionQuery - The SelectionQuery defining the selection criteria and type.
    • select

      public SelectionManager select(Thing[]... things)
    • select

      public SelectionManager select(Thing thing)
    • select

      public SelectionManager select(ArrayList<GObject> objects)
    • selectAll

      public void selectAll()
    • getSelected

      public HashSet<GObject> getSelected()
    • deselectAll

      public void deselectAll()
    • select

      public void select(GObject gobject)
    • getUnparented

      public HashSet<HasParents<? extends GObject>> getUnparented()
    • hasNoParent

      public void hasNoParent(HasParents<? extends GObject> g)
    • hasParent

      public void hasParent(HasParents<? extends GObject> gObject)
    • setClipboard

      public void setClipboard(ArrayList<GObject> clipboard)
    • getClipboard

      public ArrayList<GObject> getClipboard()
    • clearClipboard

      public void clearClipboard()
    • findThing

      public Thing findThing(String name)
      Finds a Thing within the scene by its name.
      Parameters:
      name - The name of the Thing to find.
      Returns:
      The Thing with the specified name.
    • findObjectParent

      public Thing findObjectParent(GObject o)
      Finds the parent Thing of a given GObject.
      Parameters:
      o - The GObject whose parent Thing is to be found.
      Returns:
      The Thing that contains the specified GObject.
    • findThingLayer

      public Layer findThingLayer(Thing objectParent)
      Finds the Layer that contains a given Thing.
      Parameters:
      objectParent - The Thing whose containing Layer is to be found.
      Returns:
      The Layer that contains the specified Thing.
    • resetScene

      public void resetScene()
      Resets the entire scene by clearing all layers, selections, and unregistering all triangles from the SceneRenderer. This effectively returns the sceneManager to an empty state, ready for a new project or scene.
    • drawTriangle3D

      public void drawTriangle3D(Graphics2D graphics2D, Vector3 pos1, Vector3 pos2, Vector3 pos3)
    • removeFromParent

      public void removeFromParent(GObject o, Thing t)