// Copyright (C) 2014 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 template class NzRay { public: NzRay() = default; NzRay(T X, T Y, T Z, T directionX, T directionY, T directionZ); NzRay(const T origin[3], const T direction[3]); NzRay(const NzPlane& planeOne, const NzPlane& planeTwo); NzRay(const NzVector3& origin, const NzVector3& direction); template explicit NzRay(const NzRay& ray); template explicit NzRay(const NzVector3& origin, const NzVector3& direction); NzRay(const NzRay& ray) = default; ~NzRay() = default; T ClosestPoint(const NzVector3& point) const; NzVector3 GetPoint(T lambda) const; //bool Intersect(const NzBoundingVolume& volume, T* closestHit = nullptr, T* farthestHit = nullptr) const; bool Intersect(const NzBox& box, T* closestHit = nullptr, T* farthestHit = nullptr) const; bool Intersect(const NzBox& box, const NzMatrix4& transform, T* closestHit = nullptr, T* farthestHit = nullptr) const; //bool Intersect(const NzOrientedBox& orientedBox, T* closestHit = nullptr, T* farthestHit = nullptr) const; bool Intersect(const NzPlane& plane, T* hit = nullptr) const; bool Intersect(const NzSphere& sphere, T* closestHit = nullptr, T* farthestHit = nullptr) const; NzRay& MakeAxisX(); NzRay& MakeAxisY(); NzRay& MakeAxisZ(); NzRay& Set(T X, T Y, T Z, T directionX, T directionY, T directionZ); NzRay& Set(const T origin[3], const T direction[3]); NzRay& Set(const NzPlane& planeOne, const NzPlane& planeTwo); NzRay& Set(const NzRay& ray); NzRay& Set(const NzVector3& origin, const NzVector3& direction); template NzRay& Set(const NzRay& ray); template NzRay& Set(const NzVector3& origin, const NzVector3& direction); NzString ToString() const; NzVector3 operator*(T lambda) const; static NzRay AxisX(); static NzRay AxisY(); static NzRay AxisZ(); static NzRay Lerp(const NzRay& from, const NzRay& to, T interpolation); NzVector3 direction, origin; }; template std::ostream& operator<<(std::ostream& out, const NzRay& vec); typedef NzRay NzRayd; typedef NzRay NzRayf; #include #endif // NAZARA_RAY_HPP