Class Generator

java.lang.Object
camera3D.generators.Generator
Direct Known Subclasses:
ChromaDepthGenerator, DepthMapGenerator, Monoscopic360Generator, RegularRenderer, SplitDepthGenerator, StereoscopicGenerator

public abstract class Generator extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static interface 
    Functional Interface for Passing Pixel Copy Instructions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    cleanup(processing.core.PApplet parent)
    This is called after the last call to the user's draw method and before the user's postDraw method.
    protected float
    clip(float x)
    Simple utility function that is used in a couple of places.
    protected float
    clip(float x, float min, float max)
    Simple utility function that is used in a couple of places.
    abstract void
    completedDraw(int frameNum, processing.core.PApplet parent)
    This is called once after each call to the user's draw method.
    boolean
    copyFrameNumber(int frameNum)
    Communicate to Camera3D instance if frame pixels should be copied to pixelStorage.
    protected void
    Divide up pixels and execute groups in parallel
    abstract void
    generateCompositeFrame(int[] pixelDest, int[][] pixelStorage)
    Combine the component frames into one composite frame.
    void
    generateCompositeFrameAndSaveComponents(int[] pixelDest, int[][] pixelStorage, processing.core.PApplet parent, String parentClassName, String saveFrameLocation)
    Call generateCompositeFrame several times with pixelStorage setup as empty (black) images for all but one of the pixel arrays.
    abstract int
    The number of components in the composite image, ie, the number of times to call the draw method.
    abstract String
    getComponentFrameName(int frameNum)
    Give each component a name, such as "left" and "right" for anaglyph images.
    protected void
    initExecutor(int threadCount)
    Initialize Parallel Executor for pixel copying.
    insertFrame(String what, int frameCount)
    Copied from PApplet
    void
    Notify renderer that something about the camera changed.
    abstract void
    prepareForDraw(int frameNum, processing.core.PApplet parent)
    This is called once before each call to the user's draw method.
    protected abstract void
    Perform renderer recalculations due to camera config change.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • getComponentCount

      public abstract int getComponentCount()
      The number of components in the composite image, ie, the number of times to call the draw method.
      Returns:
      int
    • getComponentFrameName

      public abstract String getComponentFrameName(int frameNum)
      Give each component a name, such as "left" and "right" for anaglyph images.
      Parameters:
      frameNum -
      Returns:
    • copyFrameNumber

      public boolean copyFrameNumber(int frameNum)
      Communicate to Camera3D instance if frame pixels should be copied to pixelStorage. This will almost always be true but some Generators can improve performance by skipping the loadPixels() call and the System.arraycopy()
      Parameters:
      frameNum -
      Returns:
    • notifyCameraConfigChange

      public void notifyCameraConfigChange(CameraConfiguration config)
      Notify renderer that something about the camera changed. For example, the stereoscopic generators need to do some recalculations when the camera moves.
      Parameters:
      config -
    • recalculateCameraSettings

      protected abstract void recalculateCameraSettings()
      Perform renderer recalculations due to camera config change.
    • prepareForDraw

      public abstract void prepareForDraw(int frameNum, processing.core.PApplet parent)
      This is called once before each call to the user's draw method. Typically the generators need to move the camera around or change some settings.
      Parameters:
      frameNum -
      parent -
    • generateCompositeFrame

      public abstract void generateCompositeFrame(int[] pixelDest, int[][] pixelStorage)
      Combine the component frames into one composite frame.
      Parameters:
      pixels -
      pixelsAlt -
    • generateCompositeFrameAndSaveComponents

      public void generateCompositeFrameAndSaveComponents(int[] pixelDest, int[][] pixelStorage, processing.core.PApplet parent, String parentClassName, String saveFrameLocation)
      Call generateCompositeFrame several times with pixelStorage setup as empty (black) images for all but one of the pixel arrays. This lets us see how the generator is modifying each of the components. This is super helpful for debugging a new generator. For most generators this will work as intended. If for some reason it does not work for your custom generator, override this method and write something that works correctly.
      Parameters:
      pixelDest -
      pixelStorage -
      parent -
      parentClassName -
      saveFrameLocation -
    • completedDraw

      public abstract void completedDraw(int frameNum, processing.core.PApplet parent)
      This is called once after each call to the user's draw method. Typically this is not needed.
      Parameters:
      frameNum -
      parent -
    • cleanup

      public abstract void cleanup(processing.core.PApplet parent)
      This is called after the last call to the user's draw method and before the user's postDraw method. This should put the camera back so other libraries like ControlP5 can function correctly.
      Parameters:
      parent -
    • initExecutor

      protected void initExecutor(int threadCount)
      Initialize Parallel Executor for pixel copying.
      Parameters:
      threadCount -
    • executeTask

      protected void executeTask(int length, Generator.PixelCopyTask task)
      Divide up pixels and execute groups in parallel
      Parameters:
      length -
      task -
    • clip

      protected float clip(float x)
      Simple utility function that is used in a couple of places.
      Parameters:
      x -
      Returns:
    • clip

      protected float clip(float x, float min, float max)
      Simple utility function that is used in a couple of places.
      Parameters:
      x -
      min -
      max -
      Returns:
    • insertFrame

      public String insertFrame(String what, int frameCount)
      Copied from PApplet
      Parameters:
      what -
      frameCount -
      Returns: