World - package raytracer.world; import...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: package raytracer.world; import raytracer.utility.*; import raytracer.geometricObjects.*; import raytracer.tracers.*; import raytracer.cameras.Camera; import raytracer.cameras.Pinhole; import java.util.Vector; import java.awt.*; //This file contains the declaration of the class World //The World class does not have a copy constructor or an assignment operator, for the following reasons: //1 There's no need to copy construct or assign the World //2 We wouldn't want to do this anyway, because the world can contain an arbitrary amount of data //3 These operations wouldn't work because the world is self-referencing: // the Tracer base class contains a pointer to the world. If we wrote a correct copy constructor for the // Tracer class, the World copy constructor would call itself recursively until we ran out of memory. public class World { public ViewPlane vp; public RGBColor background_color; public Tracer tracer; public Sphere sphere; // for Chapter 3 only public Vector<GeometricObject> objects; public Camera camera; private Graphics g; // connection to RayTracerGUI private static final int ROWS = 512, COLS = 512; // -------------------------------------------------------------------- default constructor // tracer is set to NULL because the build functions will always construct the appropriate tracer // ambient is set to a default ambient light because this will do for most scenes // camera is set to NULL because the build functions will always have to construct a camera // and set its parameters public World(){ vp = new ViewPlane(); background_color = RGBColor.black; tracer= null; sphere = new Sphere(); objects = new Vector<GeometricObject>(); camera = null; } public void setGraphics(Graphics gr) { g = gr; } // ------------------------------------------------------------------ add_object public void add_object(GeometricObject object) { objects.add(object); } // ------------------------------------------------------------------ set_camera public void set_camera(Camera c_ptr) { camera = c_ptr; } // ------------------------------------------------------------------ build /* * change this method if you want to build different items */ public int build() { vp.set_hres(COLS); vp.set_vres(ROWS); vp.set_pixel_size(.01f); vp.set_gamma(1.f); Pinhole pinhole_ptr = new Pinhole(); pinhole_ptr.set_eye(12.f, 10.f, 8.f); //pinhole_ptr.set_eye(0.f, 0.f, 16.f); pinhole_ptr.set_lookat(0.f, 0.f, 0.f); //pinhole_ptr.set_lookat(3.f, 3.f, 0.f); //pinhole_ptr.set_up_vector(1, 0, 0); pinhole_ptr.set_view_distance(16.f); pinhole_ptr.compute_uvw(); Sphere sphere = new Sphere(); sphere.set_center(0, 0, 1.5); sphere.set_radius(1); sphere.set_color(0.65f, 0.3f, 1f); // light purple add_object(sphere); set_camera(pinhole_ptr); tracer = new MultipleObjects(this); background_color = RGBColor.black; Compound compoundObject = new Compound(); compoundObject.read_smf_file("Models/sprtrd.smf"); add_object(compoundObject); // buildSingleSphere(); // buildMultipleObjects(); // buildBBCoverPic();...
View Full Document

This note was uploaded on 02/19/2010 for the course CS 390 taught by Professor Hu during the Spring '10 term at Westminster UT.

Page1 / 10

World - package raytracer.world; import...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online