// Copyright (C) 2014 Rémi Bèges - 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 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 NzVector3& origin, const NzVector3& direction); NzRay(const NzPlane& planeOne, const NzPlane& planeTwo); template explicit NzRay(const NzVector3& origin, const NzVector3& direction); template explicit NzRay(const NzRay& ray); NzRay(const NzRay& ray) = default; ~NzRay() = default; NzVector3 GetClosestPoint(const NzVector3& point) const; NzVector3 GetDirection() const; NzVector3 GetOrigin() const; NzVector3 GetPoint(T lambda) const; bool Intersect(const NzBox& box, NzVector3 * hitPoint = nullptr, NzVector3 * hitSecondPoint = nullptr) const; bool Intersect(const NzOrientedBox& orientedBox, const NzMatrix4& matrix, NzVector3 * hitPoint = nullptr, NzVector3 * hitSecondPoint = nullptr) const; bool Intersect(const NzPlane& plane, NzVector3 * hitPoint = nullptr) const; bool Intersect(const NzSphere& sphere, NzVector3 * hitPoint = nullptr, NzVector3 * hitSecondPoint = nullptr) const; NzVector3 operator*(T lambda) const; 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 NzVector3& origin, const NzVector3& direction); NzRay& Set(const NzPlane& planeOne, const NzPlane& planeTwo); template NzRay& Set(const NzVector3& origin, const NzVector3& direction); template NzRay& Set(const NzRay& ray); NzRay& Set(const NzRay& ray); NzRay& SetDirection(const NzVector3& direction); NzRay& SetOrigin(const NzVector3& origin); NzString ToString() const; static NzRay Lerp(const NzRay& from, const NzRay& to, T interpolation); static NzRay UnitX(); static NzRay UnitY(); static NzRay UnitZ(); NzVector3 direction, origin; }; template std::ostream& operator<<(std::ostream& out, const NzRay& vec); typedef NzRay NzRayd; typedef NzRay NzRayf; #include #endif // NAZARA_RAY_HPP