3dphotoshoot
diff src/geom.h @ 25:ac80210d5fbe
preparing a pc version for easier development of non-android-specifics
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 18 Jun 2015 03:12:30 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/geom.h Thu Jun 18 03:12:30 2015 +0300 1.3 @@ -0,0 +1,67 @@ 1.4 +#ifndef GEOMOBJ_H_ 1.5 +#define GEOMOBJ_H_ 1.6 + 1.7 +#include "vmath/vmath.h" 1.8 + 1.9 +class GeomObject; 1.10 + 1.11 +struct HitPoint { 1.12 + float dist; //< parametric distance along the ray 1.13 + Vector3 pos; //< position of intersection (orig + dir * dist) 1.14 + Vector3 normal; //< normal at the point of intersection 1.15 + const void *obj; //< pointer to the intersected object 1.16 +}; 1.17 + 1.18 +class GeomObject { 1.19 +public: 1.20 + virtual ~GeomObject(); 1.21 + 1.22 + virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0; 1.23 + virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0; 1.24 + 1.25 + virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0; 1.26 +}; 1.27 + 1.28 +class Sphere : public GeomObject { 1.29 +public: 1.30 + Vector3 center; 1.31 + float radius; 1.32 + 1.33 + Sphere(); 1.34 + Sphere(const Vector3 ¢er, float radius); 1.35 + 1.36 + void set_union(const GeomObject *obj1, const GeomObject *obj2); 1.37 + void set_intersection(const GeomObject *obj1, const GeomObject *obj2); 1.38 + 1.39 + bool intersect(const Ray &ray, HitPoint *hit = 0) const; 1.40 +}; 1.41 + 1.42 +class AABox : public GeomObject { 1.43 +public: 1.44 + Vector3 min, max; 1.45 + 1.46 + AABox(); 1.47 + AABox(const Vector3 &min, const Vector3 &max); 1.48 + 1.49 + void set_union(const GeomObject *obj1, const GeomObject *obj2); 1.50 + void set_intersection(const GeomObject *obj1, const GeomObject *obj2); 1.51 + 1.52 + bool intersect(const Ray &ray, HitPoint *hit = 0) const; 1.53 +}; 1.54 + 1.55 +class Plane : public GeomObject { 1.56 +public: 1.57 + Vector3 pt, normal; 1.58 + 1.59 + Plane(); 1.60 + Plane(const Vector3 &pt, const Vector3 &normal); 1.61 + Plane(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3); 1.62 + Plane(const Vector3 &normal, float dist); 1.63 + 1.64 + void set_union(const GeomObject *obj1, const GeomObject *obj2); 1.65 + void set_intersection(const GeomObject *obj1, const GeomObject *obj2); 1.66 + 1.67 + bool intersect(const Ray &ray, HitPoint *hit = 0) const; 1.68 +}; 1.69 + 1.70 +#endif // GEOMOBJ_H_