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.

50 lines
1.1 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #pragma once
  2. class Vector3 {
  3. public:
  4. union {
  5. float v[3];
  6. struct {
  7. float x, y, z;
  8. };
  9. };
  10. Vector3() {
  11. x = 0.0f;
  12. y = 0.0f;
  13. z = 0.0f;
  14. };
  15. Vector3(float x, float y, float z) {
  16. this->x = x;
  17. this->y = y;
  18. this->z = z;
  19. }
  20. Vector3(const Vector3& v) {
  21. x = v.x;
  22. y = v.y;
  23. z = v.z;
  24. }
  25. Vector3 operator+(const Vector3& v) const;
  26. Vector3 operator-(const Vector3& v) const;
  27. Vector3 operator*(const Vector3& v) const;
  28. void operator*=(float scale);
  29. Vector3 operator/(float scale) const;
  30. void operator/=(float scale);
  31. void operator=(const Vector3& v);
  32. float operator[](int index) {
  33. return v[index];
  34. }
  35. void Normalize();
  36. float Magnitude();
  37. };
  38. Vector3 operator*(float f, const Vector3& v);
  39. float Dot(const Vector3& l, const Vector3& r);
  40. Vector3 Cross(const Vector3& l, const Vector3& r);
  41. class Material;
  42. struct HitPoint {
  43. Vector3 mPosition;
  44. Vector3 mNormal;
  45. float mDistance;
  46. Material* mMaterial;
  47. };
  48. class Ray;
  49. class Geometry {
  50. virtual bool HitTest(const Ray& input_ray, float min_distance, float max_distance, HitPoint& hit_point) = 0;
  51. };