tavli

annotate src/geom.h @ 14:283eb6e9f0a3

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