--- a/src/scene.cc Wed Mar 19 17:18:59 2008 +0100
+++ b/src/scene.cc Wed Mar 26 00:52:27 2008 +0100
@@ -29,6 +29,56 @@
#include "common.h"
#include "scene.h"
+int DefaultSampler::initSampleSet()
+{
+ if ( phase == 0 )
+ {
+ phase++;
+ return w*h;
+ }
+ else return 0;
+}
+
+Sample* DefaultSampler::nextSample(Sample *prev)
+{
+ DefaultSample *s = new DefaultSample;
+ if (prev)
+ {
+ DefaultSample *sp = static_cast<DefaultSample*>(prev);
+ s->sx = sp->sx + 1;
+ s->sy = sp->sy;
+ if (s->sx >= w)
+ {
+ s->sx = 0;
+ s->sy++;
+ }
+ if (s->sy >= h)
+ {
+ delete s;
+ return NULL;
+ }
+ s->x = (Float)s->sx/h - (Float)w/h/2.0;
+ s->y = (Float)s->sy/h - 0.5;
+ }
+ else
+ {
+ s->x = -(Float)w/h/2.0;
+ s->y = -0.5;
+ s->sx = 0;
+ s->sy = 0;
+ }
+ return s;
+}
+
+void DefaultSampler::saveSample(Sample *samp, Colour &col)
+{
+ DefaultSample *sp = static_cast<DefaultSample*>(samp);
+ Float *buf = buffer + 3*(sp->sy*w + sp->sx);
+ *(buf++) = col.r;
+ *(buf++) = col.g;
+ *(buf++) = col.b;
+}
+
void Camera::rotate(const Quaternion &q)
{
/*
@@ -75,6 +125,13 @@
eye = eye + fw*p + left*u + up*v;
}
+Ray Camera::makeRay(Sample *samp)
+{
+ Vector3 dir = p + u*(0.5/f)*samp->x + v*(-0.5/f)*samp->y;
+ dir.normalize();
+ return Ray(eye, dir);
+}
+
/* http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter3.htm */
bool BBox::intersect(const Ray &ray, Float &a, Float &b)
{