// Copyright (C) 2015 Gawaboumga (https://github.com/Gawaboumga) - Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_RAY_HPP #define NAZARA_RAY_HPP #include #include #include #include #include #include #include #include namespace Nz { struct SerializationContext; template class Ray { public: Ray() = default; Ray(T X, T Y, T Z, T directionX, T directionY, T directionZ); Ray(const Vector3& origin, const Vector3& direction); Ray(const T origin[3], const T direction[3]); Ray(const Plane& planeOne, const Plane& planeTwo); template explicit Ray(const Ray& ray); template explicit Ray(const Vector3& origin, const Vector3& direction); Ray(const Ray& ray) = default; ~Ray() = default; T ClosestPoint(const Vector3& point) const; Vector3 GetPoint(T lambda) const; bool Intersect(const BoundingVolume& volume, T* closestHit = nullptr, T* furthestHit = nullptr) const; bool Intersect(const Box& box, T* closestHit = nullptr, T* furthestHit = nullptr) const; bool Intersect(const Box& box, const Matrix4& transform, T* closestHit = nullptr, T* furthestHit = nullptr) const; bool Intersect(const OrientedBox& orientedBox, T* closestHit = nullptr, T* furthestHit = nullptr) const; bool Intersect(const Plane& plane, T* hit = nullptr) const; bool Intersect(const Sphere& sphere, T* closestHit = nullptr, T* furthestHit = nullptr) const; bool Intersect(const Vector3& firstPoint, const Vector3& secondPoint, const Vector3& thirdPoint, T* hit = nullptr) const; Ray& MakeAxisX(); Ray& MakeAxisY(); Ray& MakeAxisZ(); Ray& Set(T X, T Y, T Z, T directionX, T directionY, T directionZ); Ray& Set(const Vector3& origin, const Vector3& direction); Ray& Set(const T origin[3], const T direction[3]); Ray& Set(const Plane& planeOne, const Plane& planeTwo); Ray& Set(const Ray& ray); template Ray& Set(const Ray& ray); template Ray& Set(const Vector3& origin, const Vector3& direction); String ToString() const; Vector3 operator*(T lambda) const; bool operator==(const Ray& ray) const; bool operator!=(const Ray& ray) const; static Ray AxisX(); static Ray AxisY(); static Ray AxisZ(); static Ray Lerp(const Ray& from, const Ray& to, T interpolation); Vector3 direction, origin; }; typedef Ray Rayd; typedef Ray Rayf; template bool Serialize(SerializationContext& context, const Ray& ray); template bool Unserialize(SerializationContext& context, Ray* ray); } template std::ostream& operator<<(std::ostream& out, const Nz::Ray& vec); #include #endif // NAZARA_RAY_HPP