// Copyright (C) 2014 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_BOX_HPP #define NAZARA_BOX_HPP #include #include #include #include #include #include template class NzBox { public: NzBox() = default; NzBox(T Width, T Height, T Depth); NzBox(T X, T Y, T Z, T Width, T Height, T Depth); NzBox(const T box[6]); NzBox(const NzRect& rect); NzBox(const NzVector3& lengths); NzBox(const NzVector3& vec1, const NzVector3& vec2); template explicit NzBox(const NzBox& box); NzBox(const NzBox& box) = default; ~NzBox() = default; bool Contains(T X, T Y, T Z) const; bool Contains(const NzBox& box) const; bool Contains(const NzVector3& point) const; NzBox& ExtendTo(T X, T Y, T Z); NzBox& ExtendTo(const NzBox& box); NzBox& ExtendTo(const NzVector3& point); NzSphere GetBoundingSphere() const; NzVector3 GetCorner(nzCorner corner) const; NzVector3 GetCenter() const; NzVector3 GetLengths() const; NzVector3 GetMaximum() const; NzVector3 GetMinimum() const; NzVector3 GetNegativeVertex(const NzVector3& normal) const; NzVector3 GetPosition() const; NzVector3 GetPositiveVertex(const NzVector3& normal) const; T GetRadius() const; NzSphere GetSquaredBoundingSphere() const; T GetSquaredRadius() const; bool Intersect(const NzBox& box, NzBox* intersection = nullptr) const; bool IsValid() const; NzBox& MakeZero(); NzBox& Set(T Width, T Height, T Depth); NzBox& Set(T X, T Y, T Z, T Width, T Height, T Depth); NzBox& Set(const T box[6]); NzBox& Set(const NzBox& box); NzBox& Set(const NzRect& rect); NzBox& Set(const NzVector3& lengths); NzBox& Set(const NzVector3& vec1, const NzVector3& vec2); template NzBox& Set(const NzBox& box); NzString ToString() const; NzBox& Transform(const NzMatrix4& matrix, bool applyTranslation = true); NzBox& Translate(const NzVector3& translation); T& operator[](unsigned int i); T operator[](unsigned int i) const; NzBox operator*(T scalar) const; NzBox operator*(const NzVector3& vec) const; NzBox& operator*=(T scalar); NzBox& operator*=(const NzVector3& vec); bool operator==(const NzBox& box) const; bool operator!=(const NzBox& box) const; static NzBox Lerp(const NzBox& from, const NzBox& to, T interpolation); static NzBox Zero(); T x, y, z, width, height, depth; }; template std::ostream& operator<<(std::ostream& out, const NzBox& box); typedef NzBox NzBoxd; typedef NzBox NzBoxf; typedef NzBox NzBoxi; typedef NzBox NzBoxui; typedef NzBox NzBoxi32; typedef NzBox NzBoxui32; #include #endif // NAZARA_BOX_HPP