istereo
annotate libs/vmath/ray.h @ 33:33e9eedad390
ah.. blunder
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Fri, 09 Sep 2011 00:03:37 +0300 |
parents | |
children | ff055bff6a15 |
rev | line source |
---|---|
nuclear@28 | 1 #ifndef VMATH_RAY_H_ |
nuclear@28 | 2 #define VMATH_RAY_H_ |
nuclear@28 | 3 |
nuclear@28 | 4 #include "matrix.h" |
nuclear@28 | 5 #include "vector.h" |
nuclear@28 | 6 |
nuclear@28 | 7 typedef struct { |
nuclear@28 | 8 vec3_t origin, dir; |
nuclear@28 | 9 } ray_t; |
nuclear@28 | 10 |
nuclear@28 | 11 #ifdef __cplusplus |
nuclear@28 | 12 extern "C" { |
nuclear@28 | 13 #endif /* __cplusplus */ |
nuclear@28 | 14 |
nuclear@28 | 15 static inline ray_t ray_cons(vec3_t origin, vec3_t dir); |
nuclear@28 | 16 ray_t ray_transform(ray_t r, mat4_t m); |
nuclear@28 | 17 |
nuclear@28 | 18 #ifdef __cplusplus |
nuclear@28 | 19 } /* __cplusplus */ |
nuclear@28 | 20 |
nuclear@28 | 21 #include <stack> |
nuclear@28 | 22 |
nuclear@28 | 23 class Ray { |
nuclear@28 | 24 private: |
nuclear@28 | 25 std::stack<scalar_t> ior_stack; |
nuclear@28 | 26 |
nuclear@28 | 27 public: |
nuclear@28 | 28 /* enviornmental index of refraction, normally 1.0 */ |
nuclear@28 | 29 static scalar_t env_ior; |
nuclear@28 | 30 |
nuclear@28 | 31 Vector3 origin, dir; |
nuclear@28 | 32 scalar_t energy; |
nuclear@28 | 33 int iter; |
nuclear@28 | 34 scalar_t ior; |
nuclear@28 | 35 long time; |
nuclear@28 | 36 |
nuclear@28 | 37 Ray(); |
nuclear@28 | 38 Ray(const Vector3 &origin, const Vector3 &dir); |
nuclear@28 | 39 |
nuclear@28 | 40 void transform(const Matrix4x4 &xform); |
nuclear@28 | 41 Ray transformed(const Matrix4x4 &xform) const; |
nuclear@28 | 42 |
nuclear@28 | 43 void enter(scalar_t new_ior); |
nuclear@28 | 44 void leave(); |
nuclear@28 | 45 |
nuclear@28 | 46 scalar_t calc_ior(bool entering, scalar_t mat_ior = 1.0) const; |
nuclear@28 | 47 }; |
nuclear@28 | 48 |
nuclear@28 | 49 inline Ray reflect_ray(const Ray &inray, const Vector3 &norm); |
nuclear@28 | 50 inline Ray refract_ray(const Ray &inray, const Vector3 &norm, scalar_t ior, bool entering, scalar_t ray_mag = -1.0); |
nuclear@28 | 51 #endif /* __cplusplus */ |
nuclear@28 | 52 |
nuclear@28 | 53 #include "ray.inl" |
nuclear@28 | 54 |
nuclear@28 | 55 #endif /* VMATH_RAY_H_ */ |