goat3dgfx
view src/geom.h @ 17:f2da87b02fcd
fixes mostly visual studio stuff
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 01 Dec 2013 02:25:29 +0200 |
parents | 1873dfd13f2d |
children | 0ac499409edd |
line source
1 #ifndef GEOMOBJ_H_
2 #define GEOMOBJ_H_
4 #include "vmath/vmath.h"
6 namespace goatgfx {
8 class GeomObject;
10 struct HitPoint {
11 float dist; //< parametric distance along the ray
12 Vector3 pos; //< position of intersection (orig + dir * dist)
13 Vector3 normal; //< normal at the point of intersection
14 const void *obj; //< pointer to the intersected object
15 };
17 class GeomObject {
18 public:
19 virtual ~GeomObject();
21 virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0;
22 virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0;
24 virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0;
25 };
27 class Sphere : public GeomObject {
28 public:
29 Vector3 center;
30 float radius;
32 Sphere();
33 Sphere(const Vector3 ¢er, float radius);
35 void set_union(const GeomObject *obj1, const GeomObject *obj2);
36 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
38 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
39 };
41 class AABox : public GeomObject {
42 public:
43 Vector3 min, max;
45 AABox();
46 AABox(const Vector3 &min, const Vector3 &max);
48 void set_union(const GeomObject *obj1, const GeomObject *obj2);
49 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
51 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
52 };
54 class Plane : public GeomObject {
55 public:
56 Vector3 pt, normal;
58 Plane();
59 Plane(const Vector3 &pt, const Vector3 &normal);
60 Plane(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3);
61 Plane(const Vector3 &normal, float dist);
63 void set_union(const GeomObject *obj1, const GeomObject *obj2);
64 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
66 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
67 };
69 } // namespace goatgfx
71 #endif // GEOMOBJ_H_