// Copyright (C) 2017 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 namespace Nz { struct SerializationContext; template class Box { public: Box() = default; Box(T Width, T Height, T Depth); Box(T X, T Y, T Z, T Width, T Height, T Depth); Box(const T box[6]); Box(const Rect& rect); Box(const Vector3& lengths); Box(const Vector3& vec1, const Vector3& vec2); template explicit Box(const Box& box); Box(const Box& box) = default; ~Box() = default; bool Contains(T X, T Y, T Z) const; bool Contains(const Box& box) const; bool Contains(const Vector3& point) const; Box& ExtendTo(T X, T Y, T Z); Box& ExtendTo(const Box& box); Box& ExtendTo(const Vector3& point); Sphere GetBoundingSphere() const; Vector3 GetCenter() const; Vector3 GetCorner(BoxCorner corner) const; Vector3 GetLengths() const; Vector3 GetMaximum() const; Vector3 GetMinimum() const; Vector3 GetNegativeVertex(const Vector3& normal) const; Vector3 GetPosition() const; Vector3 GetPositiveVertex(const Vector3& normal) const; T GetRadius() const; Sphere GetSquaredBoundingSphere() const; T GetSquaredRadius() const; bool Intersect(const Box& box, Box* intersection = nullptr) const; bool IsValid() const; Box& MakeZero(); Box& Set(T Width, T Height, T Depth); Box& Set(T X, T Y, T Z, T Width, T Height, T Depth); Box& Set(const T box[6]); Box& Set(const Box& box); Box& Set(const Rect& rect); Box& Set(const Vector3& lengths); Box& Set(const Vector3& vec1, const Vector3& vec2); template Box& Set(const Box& box); String ToString() const; Box& Transform(const Matrix4& matrix, bool applyTranslation = true); Box& Translate(const Vector3& translation); T& operator[](std::size_t i); T operator[](std::size_t i) const; Box operator*(T scalar) const; Box operator*(const Vector3& vec) const; Box& operator=(const Box& other) = default; Box& operator*=(T scalar); Box& operator*=(const Vector3& vec); bool operator==(const Box& box) const; bool operator!=(const Box& box) const; static Box Lerp(const Box& from, const Box& to, T interpolation); static Box Zero(); T x, y, z, width, height, depth; }; using Boxd = Box; using Boxf = Box; using Boxi = Box; using Boxui = Box; using Boxi32 = Box; using Boxui32 = Box; template bool Serialize(SerializationContext& context, const Box& box, TypeTag>); template bool Unserialize(SerializationContext& context, Box* box, TypeTag>); } template std::ostream& operator<<(std::ostream& out, const Nz::Box& box); #include #endif // NAZARA_BOX_HPP