tavli

annotate src/geom.h @ 0:52e0dd47753b

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 21 Jun 2015 06:30:39 +0300
parents
children 94aff2ff1934
rev   line source
nuclear@0 1 #ifndef GEOMOBJ_H_
nuclear@0 2 #define GEOMOBJ_H_
nuclear@0 3
nuclear@0 4 #include "vmath/vmath.h"
nuclear@0 5
nuclear@0 6 class GeomObject;
nuclear@0 7
nuclear@0 8 struct HitPoint {
nuclear@0 9 float dist; //< parametric distance along the ray
nuclear@0 10 Vector3 pos; //< position of intersection (orig + dir * dist)
nuclear@0 11 Vector3 normal; //< normal at the point of intersection
nuclear@0 12 const void *obj; //< pointer to the intersected object
nuclear@0 13 };
nuclear@0 14
nuclear@0 15 class GeomObject {
nuclear@0 16 public:
nuclear@0 17 virtual ~GeomObject();
nuclear@0 18
nuclear@0 19 virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0;
nuclear@0 20 virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0;
nuclear@0 21
nuclear@0 22 virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0;
nuclear@0 23 };
nuclear@0 24
nuclear@0 25 class Sphere : public GeomObject {
nuclear@0 26 public:
nuclear@0 27 Vector3 center;
nuclear@0 28 float radius;
nuclear@0 29
nuclear@0 30 Sphere();
nuclear@0 31 Sphere(const Vector3 &center, float radius);
nuclear@0 32
nuclear@0 33 void set_union(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 34 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 35
nuclear@0 36 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
nuclear@0 37 };
nuclear@0 38
nuclear@0 39 class AABox : public GeomObject {
nuclear@0 40 public:
nuclear@0 41 Vector3 min, max;
nuclear@0 42
nuclear@0 43 AABox();
nuclear@0 44 AABox(const Vector3 &min, const Vector3 &max);
nuclear@0 45
nuclear@0 46 void set_union(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 47 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 48
nuclear@0 49 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
nuclear@0 50 };
nuclear@0 51
nuclear@0 52 class Plane : public GeomObject {
nuclear@0 53 public:
nuclear@0 54 Vector3 pt, normal;
nuclear@0 55
nuclear@0 56 Plane();
nuclear@0 57 Plane(const Vector3 &pt, const Vector3 &normal);
nuclear@0 58 Plane(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3);
nuclear@0 59 Plane(const Vector3 &normal, float dist);
nuclear@0 60
nuclear@0 61 void set_union(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 62 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 63
nuclear@0 64 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
nuclear@0 65 };
nuclear@0 66
nuclear@0 67 #endif // GEOMOBJ_H_