dungeon_crawler

view prototype/vmath/ray.h @ 72:a27528035e20

- re-organized the renderer classes a bit wrt final render-target - implemented identity color-grading palette for now - broke particle systems.... - removed multipass renderer
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 19 Oct 2012 02:45:57 +0300
parents
children
line source
1 /*
2 libvmath - a vector math library
3 Copyright (C) 2004-2011 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
19 #ifndef VMATH_RAY_H_
20 #define VMATH_RAY_H_
22 #include "matrix.h"
23 #include "vector.h"
25 typedef struct {
26 vec3_t origin, dir;
27 } ray_t;
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
33 static inline ray_t ray_cons(vec3_t origin, vec3_t dir);
34 ray_t ray_transform(ray_t r, mat4_t m);
36 #ifdef __cplusplus
37 } /* __cplusplus */
39 #include <stack>
41 class Ray {
42 private:
43 std::stack<scalar_t> ior_stack;
45 public:
46 /* enviornmental index of refraction, normally 1.0 */
47 static scalar_t env_ior;
49 Vector3 origin, dir;
50 scalar_t energy;
51 int iter;
52 scalar_t ior;
53 long time;
55 Ray();
56 Ray(const Vector3 &origin, const Vector3 &dir);
58 void transform(const Matrix4x4 &xform);
59 Ray transformed(const Matrix4x4 &xform) const;
61 void enter(scalar_t new_ior);
62 void leave();
64 scalar_t calc_ior(bool entering, scalar_t mat_ior = 1.0) const;
65 };
67 inline Ray reflect_ray(const Ray &inray, const Vector3 &norm);
68 inline Ray refract_ray(const Ray &inray, const Vector3 &norm, scalar_t ior, bool entering, scalar_t ray_mag = -1.0);
69 #endif /* __cplusplus */
71 #include "ray.inl"
73 #endif /* VMATH_RAY_H_ */