added Color::yellow, finished shapes/Box, added a couple boxes to sample scene

git-svn-id: svn://anubis/fart/trunk@121 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-02-17 05:36:48 +00:00
parent 13fedccf4c
commit 4b0f506522
5 changed files with 29 additions and 4 deletions

View File

@ -79,7 +79,7 @@ void Scene::load(const char * filename)
refptr<Shape> plane = new Plane(0, 0, 1, -2); refptr<Shape> plane = new Plane(0, 0, 1, -2);
m_shapes.push_back(plane); m_shapes.push_back(plane);
Material * m = new Material(); refptr<Material> m = new Material();
m->setDiffuseColor(Color::red); m->setDiffuseColor(Color::red);
m->setAmbientColor(Color::red); m->setAmbientColor(Color::red);
@ -89,6 +89,28 @@ void Scene::load(const char * filename)
shape->setMaterial(m); shape->setMaterial(m);
m_shapes.push_back(shape); m_shapes.push_back(shape);
m = new Material();
m->setDiffuseColor(Color::blue);
m->setAmbientColor(Color::blue);
shape = new Box(new Vector(1.8, 1.8, 0.5));
m_transform.translate(0, 0, -2.0);
shape->setTransform(m_transform);
shape->setMaterial(m);
m_shapes.push_back(shape);
m = new Material();
m->setDiffuseColor(Color::yellow);
m->setAmbientColor(Color::yellow);
shape = new Box(new Vector(1, 1, 1));
m_transform.translate(-3, 1, 0.5);
m_transform.rotate(45, 0, 0, 1);
m_transform.rotate(45, 1, 0, 0);
shape->setTransform(m_transform);
shape->setMaterial(m);
m_shapes.push_back(shape);
refptr<Light> light = new PointLight(); refptr<Light> light = new PointLight();
light->setPosition(Vector(2, -1, 2)); light->setPosition(Vector(2, -1, 2));
m_lights.push_back(light); m_lights.push_back(light);

View File

@ -10,9 +10,9 @@ using namespace std;
Box::Box(refptr<Vector> size) Box::Box(refptr<Vector> size)
{ {
m_size = *size; m_size = *size;
m_size[0] = fabs(m_size[0]); m_size[0] = fabs(m_size[0]) / 2.0;
m_size[1] = fabs(m_size[1]); m_size[1] = fabs(m_size[1]) / 2.0;
m_size[2] = fabs(m_size[2]); m_size[2] = fabs(m_size[2]) / 2.0;
} }
Shape::IntersectList Box::intersect(const Ray & ray) Shape::IntersectList Box::intersect(const Ray & ray)

View File

@ -42,6 +42,7 @@ class Shape
#include "Sphere.h" #include "Sphere.h"
#include "Plane.h" #include "Plane.h"
#include "Box.h"
#endif #endif

View File

@ -6,6 +6,7 @@ const Color Color::white = Color(1, 1, 1);
const Color Color::red = Color(1, 0, 0); const Color Color::red = Color(1, 0, 0);
const Color Color::green = Color(0, 1, 0); const Color Color::green = Color(0, 1, 0);
const Color Color::blue = Color(0, 0, 1); const Color Color::blue = Color(0, 0, 1);
const Color Color::yellow = Color(1, 1, 0);
Color::Color() Color::Color()
{ {

View File

@ -25,6 +25,7 @@ class Color
static const Color red; static const Color red;
static const Color green; static const Color green;
static const Color blue; static const Color blue;
static const Color yellow;
}; };
Color operator+(const Color & c1, const Color & c2); Color operator+(const Color & c1, const Color & c2);