raylib-cpp
C++ object-oriented wrapper library for raylib.
BoundingBox.hpp
1 #ifndef RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
2 #define RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
3 
4 #include "./raylib.hpp"
5 #include "./raylib-cpp-utils.hpp"
6 
7 namespace raylib {
11 class BoundingBox : public ::BoundingBox {
12  public:
13  BoundingBox(const ::BoundingBox& box) {
14  set(box);
15  }
16 
20  BoundingBox(const ::Mesh& mesh) {
21  set(::MeshBoundingBox(mesh));
22  }
23 
24  BoundingBox(::Vector3 Min, ::Vector3 Max) {
25  min = Min;
26  max = Max;
27  }
28 
29  GETTERSETTER(::Vector3, Min, min)
30  GETTERSETTER(::Vector3, Max, max)
31 
32  BoundingBox& operator=(const ::BoundingBox& box) {
33  set(box);
34  return *this;
35  }
36 
40  inline BoundingBox& Draw(::Color color = {255, 255, 255, 255}) {
41  DrawBoundingBox(*this, color);
42  return *this;
43  }
44 
48  inline bool CheckCollision(const ::BoundingBox& box2) const {
49  return CheckCollisionBoxes(*this, box2);
50  }
51 
55  inline bool CheckCollision(::Vector3 center, float radius) const {
56  return CheckCollisionBoxSphere(*this, center, radius);
57  }
58 
62  inline bool CheckCollision(const ::Ray& ray) const {
63  return CheckCollisionRayBox(ray, *this);
64  }
65 
66  private:
67  inline void set(const ::BoundingBox& box) {
68  min = box.min;
69  max = box.max;
70  }
71 };
72 } // namespace raylib
73 
74 #endif // RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
raylib
All raylib-cpp classes and functions appear in the raylib namespace.
Definition: AudioDevice.hpp:7
raylib::BoundingBox::BoundingBox
BoundingBox(const ::Mesh &mesh)
Compute mesh bounding box limits.
Definition: BoundingBox.hpp:20
raylib::BoundingBox::Draw
BoundingBox & Draw(::Color color={255, 255, 255, 255})
Draw a bounding box with wires.
Definition: BoundingBox.hpp:40
raylib::Vector3
Vector3 type.
Definition: Vector3.hpp:16
raylib::BoundingBox::CheckCollision
bool CheckCollision(::Vector3 center, float radius) const
Detect collision between box and sphere.
Definition: BoundingBox.hpp:55
raylib::BoundingBox::CheckCollision
bool CheckCollision(const ::BoundingBox &box2) const
Detect collision between two boxes.
Definition: BoundingBox.hpp:48
raylib::Color
Color type, RGBA (32bit)
Definition: Color.hpp:14
raylib::BoundingBox
Bounding box type.
Definition: BoundingBox.hpp:11
raylib::BoundingBox::CheckCollision
bool CheckCollision(const ::Ray &ray) const
Detect collision between ray and bounding box.
Definition: BoundingBox.hpp:62