Class Scene

java.lang.Object
rayrangers.raytracer.world.Scene
All Implemented Interfaces:
Hittable

public class Scene extends Object implements Hittable
Represents the scene to be rendered.
  • Constructor Details

    • Scene

      public Scene(Color backgroundColor)
      Constructs a scene with the specified background color.
      Parameters:
      backgroundColor - background color
  • Method Details

    • addEntity

      public void addEntity(Entity entity)
      Adds a new entity to the map of entities.
      Parameters:
      entity - entity to add
    • getEntityByUuid

      public Entity getEntityByUuid(UUID uuid)
      Returns the entity from the map with the given UUID.
      Parameters:
      uuid - UUID to search for
      Returns:
      associated entity
    • getBackgroundColor

      public Color getBackgroundColor()
      Returns the background color of the scene.
      Returns:
      background color
    • getEntities

      public Map<UUID,Entity> getEntities()
      Returns a map of all entites in the scene.
      Returns:
      map of entities
    • getCameras

      public Map<UUID,Camera> getCameras()
      Returns a map of all cameras in the scene.
      Returns:
      map of cameras
    • getLightSources

      public Map<UUID,LightSource> getLightSources()
      Returns a map of all light sources in the scene.
      Returns:
      map of light sources
    • addCamera

      public boolean addCamera(Camera camera)
      Adds a camera with a unique UUID if it has not been added yet.
      Parameters:
      camera - camera to add
      Returns:
      true if camera has not been added yet, otherwise false
    • addLightSource

      public boolean addLightSource(LightSource lightSource)
      Adds a light source with a unique UUID if it has not been added yet.
      Parameters:
      lightSource - light source to add
      Returns:
      true if light source has not been added yet, otherwise false.
    • hit

      public boolean hit(Ray ray, double t0, double t1, HitRecord record)
      Description copied from interface: Hittable
      Checks if a ray has a hit in the specified interval [t0;t1].
      Specified by:
      hit in interface Hittable
      Parameters:
      ray - ray to check for a hit
      t0 - minimum ray parameter
      t1 - maximum ray parameter
      record - hit record
      Returns:
      true if a hit occurred in the interval, otherwise false
      See Also: