Scene::CalcBounds(), including Box::Extend(Box&), Box::Clear()
[MicroTrace.git] / Ray.cxx
diff --git a/Ray.cxx b/Ray.cxx
index be4a4f4..84617d1 100644 (file)
--- a/Ray.cxx
+++ b/Ray.cxx
@@ -1,12 +1,27 @@
+#include <limits>
+
 #include "Ray.hxx"
 
 Ray::Ray()
+  : m_org(Vec3f()),
+    m_dir(Vec3f()),
+    m_level(0),
+    m_density(1.0),
+    m_hit(0)
 {
+  m_t = std::numeric_limits<float>::max();
 }
 
 Ray::Ray(const Vec3f& org, 
-        const Vec3f& dir)
+        const Vec3f& dir,
+        unsigned int recursion_level)
+  : m_org(org),
+    m_dir(dir),
+    m_level(recursion_level),
+    m_density(1.0),
+    m_hit(0)
 {
+  m_t = std::numeric_limits<float>::max();
 }
 
 Ray::~Ray()
@@ -15,28 +30,97 @@ Ray::~Ray()
 
 Ray::Ray(const Ray& r)
 {
+  m_org = r.m_org;
+  m_dir = r.m_dir;
+  m_t = r.m_t;
+  m_hit = r.m_hit;
+  m_level = r.m_level;
+  m_density = r.m_density;
 }
 
 Ray&
 Ray::operator=(const Ray& r)
 {
+  if(this != &r)
+    {
+      m_org = r.m_org;
+      m_dir = r.m_dir;
+      m_t = r.m_t;
+      m_hit = r.m_hit;
+      m_level = r.m_level;
+      m_density = r.m_density;
+    }
   return *this;
 }
 
 const Vec3f&
 Ray::origin() const
 {
-  return Vec3f();
+  return m_org;
 }
 
 const Vec3f&
 Ray::direction() const
 {
-  return Vec3f();
+  return m_dir;
 }
 
 float
 Ray::t() const
 {
-  return 0.0f;
+  return m_t;
+}
+
+void
+Ray::setOrigin(const Vec3f& o)
+{
+  m_org = o;
+}
+
+void
+Ray::setDir(const Vec3f& d)
+{
+  m_dir = d;
+}
+
+void
+Ray::setT(float t)
+{
+  m_t = t;
+}
+
+Primitive*
+Ray::hit()
+{
+  return m_hit;
+}
+
+void
+Ray::setHit(Primitive* p)
+{
+  m_hit = p;
+}
+
+unsigned int 
+Ray::recursionDepth() const
+{
+  return m_level;
+}
+
+void
+Ray::setRecursionDepth(unsigned int i)
+{
+  m_level = i;
+}
+
+float
+Ray::indexOfRefraction() const
+{
+  return m_density;
+}
+
+void
+Ray::setIndexOfRefraction(float d)
+{
+  m_density = d;
 }
This page took 0.02618 seconds and 4 git commands to generate.