001package scene;
002
003import java.util.List;
004import java.util.LinkedList;
005
006/**
007   A Scene data structure is a list of Model data structures
008   and a Camera data structure.
009
010   Each Model object represents a distinct geometric object
011   in the scene.
012
013   The Camera object determines a "view volume", which
014   determines how much of the scene is actually visible
015   and gets rendered into the framebuffer.
016*/
017public class Scene
018{
019   public List<Model> modelList = new LinkedList<Model>();
020
021   public Camera camera;
022
023
024   /**
025      Construct a scene with a default camera object.
026   */
027   public Scene()
028   {
029      this.camera = new Camera();
030   }
031
032
033   /**
034      Construct a scene with the given camera object.
035
036      @param camera Camera object for this Scene
037   */
038   public Scene(Camera camera)
039   {
040      this.camera = camera;
041   }
042
043
044   /**
045      Change this scene's camera to the given camera object.
046
047      @param camera new Camera object for this Scene
048   */
049   public void setCamera(Camera camera)
050   {
051      this.camera = camera;
052   }
053
054
055   /**
056      Add a model (or models) to this scene.
057
058      @param mArray array of Models to add to this Scene
059   */
060   public void addModel(Model... mArray)
061   {
062      for (Model model : mArray)
063      {
064         modelList.add(model);
065      }
066   }
067
068
069   /**
070      For debugging.
071
072      @return String representation of this Scene object
073   */
074   public String toString()
075   {
076      String result = "";
077      result += camera.toString();
078      result += "This Scene has " + modelList.size() + " models\n";
079      int i = 0;
080      for (Model m : modelList)
081      {
082         result += "Model " + (i++) + "\n";
083         result += m.toString();
084      }
085      return result;
086   }
087}