goat3d

view libs/vmath/ray.cc @ 34:8471225a460c

merged
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 05 Oct 2013 03:08:22 +0300
parents
children
line source
1 #include "ray.h"
2 #include "vector.h"
4 scalar_t Ray::env_ior = 1.0;
6 Ray::Ray()
7 {
8 ior = env_ior;
9 energy = 1.0;
10 time = 0;
11 iter = 0;
12 }
14 Ray::Ray(const Vector3 &origin, const Vector3 &dir)
15 {
16 this->origin = origin;
17 this->dir = dir;
18 ior = env_ior;
19 energy = 1.0;
20 time = 0;
21 iter = 0;
22 }
24 void Ray::transform(const Matrix4x4 &xform)
25 {
26 Matrix4x4 upper = xform;
27 upper[0][3] = upper[1][3] = upper[2][3] = upper[3][0] = upper[3][1] = upper[3][2] = 0.0;
28 upper[3][3] = 1.0;
30 dir.transform(upper);
31 origin.transform(xform);
32 }
34 Ray Ray::transformed(const Matrix4x4 &xform) const
35 {
36 Ray foo = *this;
37 foo.transform(xform);
38 return foo;
39 }