Class Scene

java.lang.Object
com.ijurnove.cpu3d.Scene

public final class Scene extends Object
A Scene consists of a set of Shape3ds, a set of Lights, and a Camera. Scenes have two sets of flags, one which can be modified at any time, and one which can only be set at initialization. These are stored as a SceneFlags object and a SceneInitFlags object respectively.

To render a Scene, use the render() method.

  • Constructor Details

    • Scene

      public Scene(SceneInitFlags initFlags)
      Constructs an empty Scene with the specified SceneInitFlags.
      Parameters:
      initFlags - the specified SceneInitFlags
    • Scene

      public Scene(SceneInitFlags initFlags, Shape3d[] shapes, Light[] lights, Camera viewCamera)
      Constructs a Scene with a specified SceneInitFlags, Shape3d[], Light[], and Camera.
      Parameters:
      initFlags - the specified SceneInitFlags
      shapes - the specified Shape3d[]
      lights - the specified Light[]
      viewCamera - the specified Camera from which the Scene will be rendered
  • Method Details

    • getShape

      public Shape3d getShape(int index)
      Returns the Shape3d at a specified index.
      Parameters:
      index - the index of the Shape3d
      Returns:
      the Shape3d at the specified index
    • getLight

      public Light getLight(int index)
      Returns the Light at a specified index.
      Parameters:
      index - the index of the Light
      Returns:
      the Light at the specified index
    • getViewCamera

      public Camera getViewCamera()
      Returns the Camera that this Scene is rendered from.
      Returns:
      the Camera that this Scene is rendered from
    • getInitFlag

      public final double getInitFlag(SceneInitFlag flag)
      Returns the value of a specified SceneInitFlag.
      Parameters:
      flag - the specified SceneInitFlag
      Returns:
      the value of the specified SceneInitFlag
    • shapeCount

      public int shapeCount()
      Returns the number of Shape3ds in this Scene.
      Returns:
      the number of Shape3ds in this Scene
    • lightCount

      public int lightCount()
      Returns the number of Lights in this Scene.
      Returns:
      the number of Lights in this Scene
    • getColorMap

      protected com.ijurnove.cpu3d.ColorMap getColorMap()
    • getPixelWidth

      protected int getPixelWidth()
    • getPixelHeight

      protected int getPixelHeight()
    • getShapes

      protected List<Shape3d> getShapes()
    • getLights

      protected List<Light> getLights()
    • addLight

      public void addLight(Light light)
      Adds a specified Light to this Scene.
      Parameters:
      light - the specified Light
    • addShape

      public void addShape(Shape3d shape)
      Adds a specified Shape3d to this Scene.
      Parameters:
      shape - the specified Shape3d
    • setViewCamera

      public void setViewCamera(Camera viewCamera)
      Sets the Camera of this Scene.
      Parameters:
      viewCamera - the specified Camera
    • setFlag

      public void setFlag(SceneFlag flag, double value)
      Sets a SceneFlag to a given value.
      Parameters:
      flag - the specified SceneFlag
      value - the new value
    • getFlag

      public double getFlag(SceneFlag flag)
      Returns the value of a specified SceneFlag.
      Parameters:
      flag - the specified SceneFlag
      Returns:
      the value of the specified SceneFlag
    • setBackground

      public void setBackground(int[] rgb)
      Sets the background color of this Scene.
      Parameters:
      rgb - the RGB color values to set. values range from 0-255
    • project

      protected void project(Camera perspectiveCam)
    • perspProjectionForPointShadowMap

      protected void perspProjectionForPointShadowMap(Camera perspCam)
    • orthoProjection

      protected void orthoProjection(Camera orthoCam)
    • updateShadows

      protected void updateShadows()
    • render

      public BufferedImage render()
      Renders this Scene from the perspective of its Camera. Returns a BufferedImage with dimensions specified in the SceneInitFlags.
      Returns:
      the rendered Scene as a BufferedImage