From 81c84a38992ce8e38106d86ce85ac3e88ed91a31 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 7 Jul 2009 04:23:05 +0000 Subject: Add shallow copy semantics to Camera's, Object's, and Scene's. --- tests/glxx.cpp | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) (limited to 'tests/glxx.cpp') diff --git a/tests/glxx.cpp b/tests/glxx.cpp index eb74209..aaf7b7b 100644 --- a/tests/glxx.cpp +++ b/tests/glxx.cpp @@ -26,37 +26,24 @@ int main() { using namespace Dimension; - // Set the resilience low for tests - resilience(SEVERITY_LOW); - - // Background color - Color background = sRGB(0.0, 0.1, 0.25); - background.filter(0.1); - - // Canvas - Canvas canvas(768, 480); - - // Camera - Perspective_Camera camera( - Matrix::rotation(Vector(0.0, 1.0, 0.0)) - * Matrix::translation(Vector(0.0, 0.0, -4.0)) - * Matrix::scale( - Vector(static_cast(canvas.width())/canvas.height(), 1.0, 1.0) - ) - ); + Scene scene = default_scene(); - // Scene - Scene scene(background, camera, canvas); + Perspective_Camera& camera + = dynamic_cast(scene.camera()); - // Objects in scene - - Sphere sphere; - sphere.trans(inverse(Matrix::scale(Vector(1.25, 1.25, 1.25)))); - scene.push_object(sphere); + Cube* cube; + for (Scene::Iterator i = scene.begin(); i != scene.end(); ++i) { + cube = dynamic_cast(&*i); + if (cube) { + break; + } + } + if (!cube) { + throw Dimension_Error("Couldn't find a cube in the default scene."); + } - Cube cube; - cube.trans(inverse(Matrix::rotation(Vector(0.75, 0.0, 0.0)))); - scene.push_object(cube); + // Set the resilience low for tests + resilience(SEVERITY_LOW); Raytracer raytracer(scene); GL_Drawer drawer(scene.canvas()); @@ -71,7 +58,7 @@ main() { drawer.draw(); display.flush(); - cube.trans(inverse(Matrix::rotation(Vector(0.025, 0.0, 0.0)))*cube.trans()); + cube->trans(inverse(Matrix::rotation(Vector(0.025, 0.0, 0.0)))*cube->trans()); camera.trans(Matrix::rotation(Vector(0.0, -0.05, 0.0))*camera.trans()); } -- cgit v1.2.3