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