Small OpenGL based c++ rendering library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

geotypes.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef __GEOTYPES_H
  2. #define __GEOTYPES_H
  3. #include "punkt3d.h"
  4. namespace segl {
  5. class Ray;
  6. class Box;
  7. class Plane;
  8. class Sphere {
  9. public:
  10. Punkt3D pos;
  11. float radius;
  12. Sphere(Punkt3D _pos, float radius);
  13. Sphere();
  14. bool collision(const Sphere &s) const;
  15. bool collision(const Ray &r) const;
  16. bool collision(const Box & b) const;
  17. bool collision(const Plane &p) const;
  18. bool inSphere(Punkt3D p) const;
  19. Punkt3D getPos() const;
  20. };
  21. class Ray {
  22. public:
  23. Punkt3D pos;
  24. Punkt3D dir;
  25. Ray();
  26. Ray(Punkt3D _pos, Punkt3D _dir);
  27. void set(Punkt3D _pos, Punkt3D _dir);
  28. Punkt3D get(float x);
  29. bool onRay(Punkt3D p, int rnd=-1);
  30. float dist(Punkt3D p);
  31. float getParam(Punkt3D p, bool onray=false);
  32. bool collision(const Sphere &s) const;
  33. bool collision(const Ray &r) const;
  34. bool collision(const Box & b) const;
  35. bool collision(const Plane &p) const;
  36. };
  37. class Box {
  38. public:
  39. Punkt3D min;
  40. Punkt3D max;
  41. Box();
  42. Box(Punkt3D _min, Punkt3D _max);
  43. bool collision(const Sphere &s) const;
  44. bool collision(const Ray &r) const;
  45. bool collision(const Box & b) const;
  46. bool collision(const Plane &p) const;
  47. };
  48. class Plane {
  49. public:
  50. Punkt3D pos;
  51. Punkt3D norm;
  52. Plane();
  53. Plane(Punkt3D _pos, Punkt3D _norm);
  54. Plane(float x, float y, float z, float a);
  55. bool collision(const Sphere &s) const;
  56. bool collision(const Ray &r) const;
  57. bool collision(const Box & b) const;
  58. bool collision(const Plane &p) const;
  59. float dist(Punkt3D p) const;
  60. };
  61. } // namespace segl
  62. #endif