goat3dgfx

annotate 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
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@15 6 namespace goatgfx {
nuclear@15 7
nuclear@0 8 class GeomObject;
nuclear@0 9
nuclear@0 10 struct HitPoint {
nuclear@0 11 float dist; //< parametric distance along the ray
nuclear@0 12 Vector3 pos; //< position of intersection (orig + dir * dist)
nuclear@0 13 Vector3 normal; //< normal at the point of intersection
nuclear@0 14 const void *obj; //< pointer to the intersected object
nuclear@0 15 };
nuclear@0 16
nuclear@0 17 class GeomObject {
nuclear@0 18 public:
nuclear@0 19 virtual ~GeomObject();
nuclear@0 20
nuclear@0 21 virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0;
nuclear@0 22 virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0;
nuclear@0 23
nuclear@0 24 virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0;
nuclear@0 25 };
nuclear@0 26
nuclear@0 27 class Sphere : public GeomObject {
nuclear@0 28 public:
nuclear@0 29 Vector3 center;
nuclear@0 30 float radius;
nuclear@0 31
nuclear@0 32 Sphere();
nuclear@0 33 Sphere(const Vector3 &center, float radius);
nuclear@0 34
nuclear@0 35 void set_union(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 36 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 37
nuclear@0 38 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
nuclear@0 39 };
nuclear@0 40
nuclear@0 41 class AABox : public GeomObject {
nuclear@0 42 public:
nuclear@0 43 Vector3 min, max;
nuclear@0 44
nuclear@0 45 AABox();
nuclear@0 46 AABox(const Vector3 &min, const Vector3 &max);
nuclear@0 47
nuclear@0 48 void set_union(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 49 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 50
nuclear@0 51 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
nuclear@0 52 };
nuclear@0 53
nuclear@0 54 class Plane : public GeomObject {
nuclear@0 55 public:
nuclear@0 56 Vector3 pt, normal;
nuclear@0 57
nuclear@0 58 Plane();
nuclear@0 59 Plane(const Vector3 &pt, const Vector3 &normal);
nuclear@0 60 Plane(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3);
nuclear@0 61 Plane(const Vector3 &normal, float dist);
nuclear@0 62
nuclear@0 63 void set_union(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 64 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
nuclear@0 65
nuclear@0 66 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
nuclear@0 67 };
nuclear@0 68
nuclear@15 69 } // namespace goatgfx
nuclear@15 70
nuclear@0 71 #endif // GEOMOBJ_H_