rayzor
annotate src/vmathray.h @ 20:6b11a3f8706e
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 15 Apr 2014 01:36:03 +0300 |
parents | 964f8ea5f095 |
children |
rev | line source |
---|---|
nuclear@13 | 1 #ifndef VMATH_RAY_H_ |
nuclear@13 | 2 #define VMATH_RAY_H_ |
nuclear@13 | 3 |
nuclear@13 | 4 #include "vmath.h" |
nuclear@13 | 5 #include "vmathmat.h" |
nuclear@13 | 6 |
nuclear@13 | 7 class Ray { |
nuclear@13 | 8 public: |
nuclear@14 | 9 Vector3 origin, dir; |
nuclear@13 | 10 |
nuclear@13 | 11 Ray() {} |
nuclear@14 | 12 Ray(const Vector3 &p, const Vector3 &d) : origin(p), dir(d) {} |
nuclear@13 | 13 }; |
nuclear@13 | 14 |
nuclear@13 | 15 inline Ray transform(const Matrix4x4 &m, const Ray &r) |
nuclear@13 | 16 { |
nuclear@13 | 17 Matrix4x4 rmat = m; |
nuclear@13 | 18 rmat[0][3] = rmat[1][3] = rmat[2][3] = rmat[3][0] = rmat[3][1] = rmat[3][2] = 0.0; |
nuclear@13 | 19 rmat[3][3] = 1.0; |
nuclear@13 | 20 |
nuclear@14 | 21 return Ray(transform(m, r.origin), transform(rmat, r.dir)); |
nuclear@13 | 22 } |
nuclear@13 | 23 |
nuclear@13 | 24 #endif // VMATH_RAY_H_ |