added shapes/shapes.h, shapes/BoolShape, made Intersect, Union, and Subtract derive from BoolShape, made BoolShape::setMaterial() call setMaterial() on sub-shapes so that materials applied to boolean objects will be applied to all sub-objects
git-svn-id: svn://anubis/fart/trunk@212 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
86888fa461
commit
91e490b65a
1
.todo
1
.todo
@ -10,7 +10,6 @@ FART To-Do List
|
|||||||
- Scene file pre-parser to allow includes, macros, and comments
|
- Scene file pre-parser to allow includes, macros, and comments
|
||||||
- Vim syntax file
|
- Vim syntax file
|
||||||
- Add jitter parameter to lights to effect soft shadow edges
|
- Add jitter parameter to lights to effect soft shadow edges
|
||||||
- Do something with materials applied to boolean objects
|
|
||||||
|
|
||||||
Low Priority:
|
Low Priority:
|
||||||
- Refraction
|
- Refraction
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "util/Ray.h"
|
#include "util/Ray.h"
|
||||||
#include "util/Color.h"
|
#include "util/Color.h"
|
||||||
#include "util/Material.h"
|
#include "util/Material.h"
|
||||||
#include "shapes/Shape.h"
|
#include "shapes/shapes.h"
|
||||||
#include "Light.h"
|
#include "Light.h"
|
||||||
|
|
||||||
#include "parser/parser.h"
|
#include "parser/parser.h"
|
||||||
|
19
shapes/BoolShape.cc
Normal file
19
shapes/BoolShape.cc
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
#include "BoolShape.h"
|
||||||
|
|
||||||
|
BoolShape::BoolShape(refptr<Shape> shape1, refptr<Shape> shape2)
|
||||||
|
{
|
||||||
|
m_shape1 = shape1;
|
||||||
|
m_shape2 = shape2;
|
||||||
|
}
|
||||||
|
|
||||||
|
BoolShape::~BoolShape()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoolShape::setMaterial(refptr<Material> material)
|
||||||
|
{
|
||||||
|
m_material = material;
|
||||||
|
m_shape1->setMaterial(material);
|
||||||
|
m_shape2->setMaterial(material);
|
||||||
|
}
|
20
shapes/BoolShape.h
Normal file
20
shapes/BoolShape.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
#ifndef BOOLSHAPE_H
|
||||||
|
#define BOOLSHAPE_H BOOLSHAPE_H
|
||||||
|
|
||||||
|
#include "Shape.h"
|
||||||
|
|
||||||
|
class BoolShape : public Shape
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BoolShape(refptr<Shape> shape1, refptr<Shape> shape2);
|
||||||
|
~BoolShape();
|
||||||
|
virtual IntersectionList intersect(refptr<Shape> _this, const Ray & ray) = 0;
|
||||||
|
virtual void setMaterial(refptr<Material> material);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
refptr<Shape> m_shape1;
|
||||||
|
refptr<Shape> m_shape2;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -4,9 +4,8 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Intersect::Intersect(refptr<Shape> shape1, refptr<Shape> shape2)
|
Intersect::Intersect(refptr<Shape> shape1, refptr<Shape> shape2)
|
||||||
|
: BoolShape(shape1, shape2)
|
||||||
{
|
{
|
||||||
m_shape1 = shape1;
|
|
||||||
m_shape2 = shape2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Shape::IntersectionList Intersect::intersect(refptr<Shape> _this, const Ray & ray)
|
Shape::IntersectionList Intersect::intersect(refptr<Shape> _this, const Ray & ray)
|
||||||
|
@ -2,17 +2,13 @@
|
|||||||
#ifndef INTERSECT_H
|
#ifndef INTERSECT_H
|
||||||
#define INTERSECT_H INTERSECT_H
|
#define INTERSECT_H INTERSECT_H
|
||||||
|
|
||||||
#include "Shape.h"
|
#include "BoolShape.h"
|
||||||
|
|
||||||
class Intersect : public Shape
|
class Intersect : public BoolShape
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Intersect(refptr<Shape> shape1, refptr<Shape> shape2);
|
Intersect(refptr<Shape> shape1, refptr<Shape> shape2);
|
||||||
IntersectionList intersect(refptr<Shape> _this, const Ray & ray);
|
IntersectionList intersect(refptr<Shape> _this, const Ray & ray);
|
||||||
|
|
||||||
protected:
|
|
||||||
refptr<Shape> m_shape1;
|
|
||||||
refptr<Shape> m_shape2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,6 +22,11 @@ Shape::~Shape()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Shape::setMaterial(refptr<Material> material)
|
||||||
|
{
|
||||||
|
m_material = material;
|
||||||
|
}
|
||||||
|
|
||||||
class BoolIntersectionComparator
|
class BoolIntersectionComparator
|
||||||
: public std::binary_function<Shape::BoolIntersection,
|
: public std::binary_function<Shape::BoolIntersection,
|
||||||
Shape::BoolIntersection,
|
Shape::BoolIntersection,
|
||||||
|
@ -109,7 +109,7 @@ class Shape
|
|||||||
}
|
}
|
||||||
Transform & getTransform() { return m_transform; }
|
Transform & getTransform() { return m_transform; }
|
||||||
|
|
||||||
void setMaterial(refptr<Material> material) { m_material = material; }
|
virtual void setMaterial(refptr<Material> material);
|
||||||
refptr<Material> getMaterial() const { return m_material; }
|
refptr<Material> getMaterial() const { return m_material; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -118,13 +118,6 @@ class Shape
|
|||||||
refptr<Material> m_material;
|
refptr<Material> m_material;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "Box.h"
|
|
||||||
#include "Cyl.h"
|
|
||||||
#include "Intersect.h"
|
|
||||||
#include "Plane.h"
|
|
||||||
#include "Sphere.h"
|
|
||||||
#include "Subtract.h"
|
|
||||||
#include "Union.h"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Subtract::Subtract(refptr<Shape> shape1, refptr<Shape> shape2)
|
Subtract::Subtract(refptr<Shape> shape1, refptr<Shape> shape2)
|
||||||
|
: BoolShape(shape1, shape2)
|
||||||
{
|
{
|
||||||
m_shape1 = shape1;
|
|
||||||
m_shape2 = shape2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Shape::IntersectionList Subtract::intersect(refptr<Shape> _this, const Ray & ray)
|
Shape::IntersectionList Subtract::intersect(refptr<Shape> _this, const Ray & ray)
|
||||||
|
@ -2,17 +2,13 @@
|
|||||||
#ifndef SUBTRACT_H
|
#ifndef SUBTRACT_H
|
||||||
#define SUBTRACT_H SUBTRACT_H
|
#define SUBTRACT_H SUBTRACT_H
|
||||||
|
|
||||||
#include "Shape.h"
|
#include "BoolShape.h"
|
||||||
|
|
||||||
class Subtract : public Shape
|
class Subtract : public BoolShape
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Subtract(refptr<Shape> shape1, refptr<Shape> shape2);
|
Subtract(refptr<Shape> shape1, refptr<Shape> shape2);
|
||||||
IntersectionList intersect(refptr<Shape> _this, const Ray & ray);
|
IntersectionList intersect(refptr<Shape> _this, const Ray & ray);
|
||||||
|
|
||||||
protected:
|
|
||||||
refptr<Shape> m_shape1;
|
|
||||||
refptr<Shape> m_shape2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Union::Union(refptr<Shape> shape1, refptr<Shape> shape2)
|
Union::Union(refptr<Shape> shape1, refptr<Shape> shape2)
|
||||||
|
: BoolShape(shape1, shape2)
|
||||||
{
|
{
|
||||||
m_shape1 = shape1;
|
|
||||||
m_shape2 = shape2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Shape::IntersectionList Union::intersect(refptr<Shape> _this, const Ray & ray)
|
Shape::IntersectionList Union::intersect(refptr<Shape> _this, const Ray & ray)
|
||||||
|
@ -2,17 +2,13 @@
|
|||||||
#ifndef UNION_H
|
#ifndef UNION_H
|
||||||
#define UNION_H UNION_H
|
#define UNION_H UNION_H
|
||||||
|
|
||||||
#include "Shape.h"
|
#include "BoolShape.h"
|
||||||
|
|
||||||
class Union : public Shape
|
class Union : public BoolShape
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Union(refptr<Shape> shape1, refptr<Shape> shape2);
|
Union(refptr<Shape> shape1, refptr<Shape> shape2);
|
||||||
IntersectionList intersect(refptr<Shape> _this, const Ray & ray);
|
IntersectionList intersect(refptr<Shape> _this, const Ray & ray);
|
||||||
|
|
||||||
protected:
|
|
||||||
refptr<Shape> m_shape1;
|
|
||||||
refptr<Shape> m_shape2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
9
shapes/shapes.h
Normal file
9
shapes/shapes.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
#include "BoolShape.h"
|
||||||
|
#include "Box.h"
|
||||||
|
#include "Cyl.h"
|
||||||
|
#include "Intersect.h"
|
||||||
|
#include "Plane.h"
|
||||||
|
#include "Sphere.h"
|
||||||
|
#include "Subtract.h"
|
||||||
|
#include "Union.h"
|
Loading…
x
Reference in New Issue
Block a user