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.cpp 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include "geotypes.h"
  2. namespace segl {
  3. Sphere::Sphere(Punkt3D _pos, float _radius) {
  4. pos = _pos;
  5. radius = _radius;
  6. }
  7. Sphere::Sphere() {
  8. radius = 1.0f;
  9. }
  10. bool Sphere::collision(const Sphere &s) {
  11. }
  12. bool Sphere::collision(const Ray &r) {
  13. }
  14. bool Sphere::collision(const Box & b) {
  15. }
  16. bool Sphere::collision(const Plane &p) {
  17. }
  18. Ray::Ray() {
  19. dir.set(0.0f, 1.0f, 0.0f);
  20. }
  21. Ray::Ray(Punkt3D _pos, Punkt3D _dir) {
  22. pos = _pos;
  23. dir = _dir;
  24. }
  25. bool Ray::collision(const Sphere &s) {
  26. return s.collision(*this);
  27. }
  28. bool Ray::collision(const Ray &r);
  29. bool Ray::collision(const Box & b);
  30. bool Ray::collision(const Plane &p);
  31. Box::Box() {
  32. max.set(1.0f, 1.0f, 1.0f);
  33. }
  34. Box::Box(Punkt3D _min, Punkt3D _max) {
  35. min = _min;
  36. max = _max;
  37. }
  38. bool Box::collision(const Sphere &s) {
  39. return s.collision(*this);
  40. }
  41. bool Box::collision(const Ray &r) {
  42. return r.collision(*this);
  43. }
  44. bool Box::collision(const Box & b) {
  45. }
  46. bool Box::collision(const Plane &p) {
  47. }
  48. Plane::Plane() {
  49. norm.set(0.0f, 1.0f, 0.0f);
  50. }
  51. Plane::Plane(Punkt3D _pos, Punkt3D _norm) {
  52. pos = _pos;
  53. norm = _norm;
  54. }
  55. Plane::Plane(float x, float y, float z, float a) {
  56. // TODO: Implementation (if not too lazy)
  57. norm.set(x, y, z);
  58. norm.normalize();
  59. }
  60. bool Plane::collision(const Sphere &s) {
  61. return s.collision(*this);
  62. }
  63. bool Plane::collision(const Ray &r) {
  64. return r.collision(*this);
  65. }
  66. bool Plane::collision(const Box & b) {
  67. return b.collision(*this);
  68. }
  69. bool Plane::collision(const Plane &p) {
  70. }
  71. } // namespace segl