cubemapper

view src/geom.h @ 1:d7a29cb7ac8d

resize to the final cubemap face size
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 28 Jul 2017 07:44:35 +0300
parents
children 2bfafdced01a
line source
1 #ifndef GEOMOBJ_H_
2 #define GEOMOBJ_H_
4 #include <gmath/gmath.h>
6 class GeomObject;
7 class SceneNode;
9 struct HitPoint {
10 float dist; //< parametric distance along the ray
11 Vec3 pos; //< position of intersection (orig + dir * dist)
12 Vec3 normal; //< normal at the point of intersection
13 const void *obj; //< pointer to the intersected object
14 const SceneNode *node;
15 Ray ray;
16 };
18 class GeomObject {
19 public:
20 virtual ~GeomObject();
22 virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0;
23 virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0;
25 virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0;
26 };
28 class Sphere : public GeomObject {
29 public:
30 Vec3 center;
31 float radius;
33 Sphere();
34 Sphere(const Vec3 &center, float radius);
36 void set_union(const GeomObject *obj1, const GeomObject *obj2);
37 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
39 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
40 };
42 class AABox : public GeomObject {
43 public:
44 Vec3 min, max;
46 AABox();
47 AABox(const Vec3 &min, const Vec3 &max);
49 void set_union(const GeomObject *obj1, const GeomObject *obj2);
50 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
52 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
53 };
55 class Plane : public GeomObject {
56 public:
57 Vec3 pt, normal;
59 Plane();
60 Plane(const Vec3 &pt, const Vec3 &normal);
61 Plane(const Vec3 &p1, const Vec3 &p2, const Vec3 &p3);
62 Plane(const Vec3 &normal, float dist);
64 void set_union(const GeomObject *obj1, const GeomObject *obj2);
65 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
67 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
68 };
70 float sphere_distance(const Vec3 &cent, float rad, const Vec3 &pt);
71 float capsule_distance(const Vec3 &a, float ra, const Vec3 &b, float rb, const Vec3 &pt);
73 #endif // GEOMOBJ_H_