gpuray_glsl
annotate vmath/ray.cc @ 3:297dbc5080c4
cone intersection
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 09 Nov 2014 20:13:33 +0200 |
parents | |
children |
rev | line source |
---|---|
nuclear@0 | 1 #include "ray.h" |
nuclear@0 | 2 #include "vector.h" |
nuclear@0 | 3 |
nuclear@0 | 4 scalar_t Ray::env_ior = 1.0; |
nuclear@0 | 5 |
nuclear@0 | 6 Ray::Ray() |
nuclear@0 | 7 { |
nuclear@0 | 8 ior = env_ior; |
nuclear@0 | 9 energy = 1.0; |
nuclear@0 | 10 time = 0; |
nuclear@0 | 11 iter = 0; |
nuclear@0 | 12 } |
nuclear@0 | 13 |
nuclear@0 | 14 Ray::Ray(const Vector3 &origin, const Vector3 &dir) |
nuclear@0 | 15 { |
nuclear@0 | 16 this->origin = origin; |
nuclear@0 | 17 this->dir = dir; |
nuclear@0 | 18 ior = env_ior; |
nuclear@0 | 19 energy = 1.0; |
nuclear@0 | 20 time = 0; |
nuclear@0 | 21 iter = 0; |
nuclear@0 | 22 } |
nuclear@0 | 23 |
nuclear@0 | 24 void Ray::transform(const Matrix4x4 &xform) |
nuclear@0 | 25 { |
nuclear@0 | 26 Matrix4x4 upper = xform; |
nuclear@0 | 27 upper[0][3] = upper[1][3] = upper[2][3] = upper[3][0] = upper[3][1] = upper[3][2] = 0.0; |
nuclear@0 | 28 upper[3][3] = 1.0; |
nuclear@0 | 29 |
nuclear@0 | 30 dir.transform(upper); |
nuclear@0 | 31 origin.transform(xform); |
nuclear@0 | 32 } |
nuclear@0 | 33 |
nuclear@0 | 34 Ray Ray::transformed(const Matrix4x4 &xform) const |
nuclear@0 | 35 { |
nuclear@0 | 36 Ray foo = *this; |
nuclear@0 | 37 foo.transform(xform); |
nuclear@0 | 38 return foo; |
nuclear@0 | 39 } |