rayzor
view src/vmathray.h @ 17:79609d482762
the renderer renders, also fixed an unnoticed matrix conversion problem between scenegraph and min3d
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 14 Apr 2014 07:34:45 +0300 |
parents | 964f8ea5f095 |
children |
line source
1 #ifndef VMATH_RAY_H_
2 #define VMATH_RAY_H_
4 #include "vmath.h"
5 #include "vmathmat.h"
7 class Ray {
8 public:
9 Vector3 origin, dir;
11 Ray() {}
12 Ray(const Vector3 &p, const Vector3 &d) : origin(p), dir(d) {}
13 };
15 inline Ray transform(const Matrix4x4 &m, const Ray &r)
16 {
17 Matrix4x4 rmat = m;
18 rmat[0][3] = rmat[1][3] = rmat[2][3] = rmat[3][0] = rmat[3][1] = rmat[3][2] = 0.0;
19 rmat[3][3] = 1.0;
21 return Ray(transform(m, r.origin), transform(rmat, r.dir));
22 }
24 #endif // VMATH_RAY_H_