--- a/include/scene.h Wed Mar 19 17:18:59 2008 +0100
+++ b/include/scene.h Wed Mar 26 00:52:27 2008 +0100
@@ -55,6 +55,65 @@
o(ao), dir(adir) {};
};
+/**
+ * sample
+ */
+class Sample
+{
+public:
+ Float x,y;
+};
+
+/**
+ * A abstract sampler.
+ * It generates screen samples in coordinates between [-1..1] for height
+ * and [-w/h..w/h] for width. It works in phases: initSampleSet returns
+ * number of samples for each phase, then samples can be generated using
+ * nextSample method. The resulting colour of each sample should be returned
+ * via saveSample method. The sampler should save the results to given buffer
+ * and decide if other phase is needed. When the picture is complete,
+ * initSampleSet returns zero and picture can be read from buffer.
+ */
+class Sampler
+{
+public:
+ Float *buffer;
+ int w,h;
+
+ Sampler(Float *abuffer, int &aw, int &ah): buffer(abuffer), w(aw), h(ah) {};
+ void resetBuffer(Float *abuffer, int &aw, int &ah) { buffer = abuffer; w = aw; h = ah; };
+ virtual void init() = 0;
+ virtual int initSampleSet() = 0;
+ virtual Sample *nextSample(Sample *prev) = 0;
+ virtual void saveSample(Sample *samp, Colour &col) = 0;
+};
+
+/**
+ * default sample
+ */
+class DefaultSample: public Sample
+{
+ friend class DefaultSampler;
+ int sx,sy;
+};
+
+/**
+ * Default sampler.
+ */
+class DefaultSampler: public Sampler
+{
+ int phase;
+public:
+ DefaultSampler(Float *abuffer, int &aw, int &ah): Sampler(abuffer, aw, ah), phase(-1) {};
+ void init() { phase = 0; };
+ int initSampleSet();
+ Sample *nextSample(Sample *prev);
+ void saveSample(Sample *samp, Colour &col);
+};
+
+/**
+ * a camera
+ */
class Camera
{
public:
@@ -68,9 +127,13 @@
void setFocalLength(const Float af) { f = af; };
void rotate(const Quaternion &q);
void move(const Float fw, const Float left, const Float up);
+
+ Ray makeRay(Sample *samp);
};
-/* axis-aligned bounding box */
+/**
+ * axis-aligned bounding box
+ */
class BBox
{
public:
@@ -84,6 +147,9 @@
bool intersect(const Ray &ray, Float &a, Float &b);
};
+/**
+ * light object
+ */
class Light
{
public:
@@ -98,12 +164,18 @@
void castShadows(bool cast) { cast_shadows = cast; };
};
+/**
+ * texture
+ */
class Texture
{
public:
virtual Colour evaluate(Vector3 point) = 0;
};
+/**
+ * material
+ */
class Material
{
public:
@@ -131,6 +203,9 @@
{ transmissivity = trans; refract_index = rindex; };
};
+/**
+ * shape
+ */
class Shape
{
public:
@@ -153,10 +228,16 @@
virtual BBox get_bbox() const = 0;
};
+/**
+ * list of shapes
+ */
class ShapeList: public vector<Shape*>
{
};
+/**
+ * sphere shape
+ */
class Sphere: public Shape
{
Float sqr_radius;
@@ -175,6 +256,9 @@
BBox get_bbox() const;
};
+/**
+ * box shape
+ */
class Box: public Shape
{
Vector3 L;
@@ -194,6 +278,9 @@
BBox get_bbox() const { return BBox(L, H); };
};
+/**
+ * triangle vertex
+ */
class Vertex
{
public:
@@ -201,6 +288,9 @@
Vertex(const Vector3 &aP): P(aP) {};
};
+/**
+ * triangle vertex with normal
+ */
class NormalVertex: public Vertex
{
public:
@@ -211,7 +301,9 @@
void setNormal(const Vector3 &aN) { N = aN; };
};
-
+/**
+ * triangle shape
+ */
class Triangle: public Shape
{
#ifdef TRI_BARI_PRE