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 minMax) {
25  min = minMax;
26  max = minMax;
27  }
28 
29  BoundingBox(::Vector3 Min, ::Vector3 Max) {
30  min = Min;
31  max = Max;
32  }
33 
34  GETTERSETTER(::Vector3, Min, min)
35  GETTERSETTER(::Vector3, Max, max)
36 
37  BoundingBox& operator=(const ::BoundingBox& box) {
38  set(box);
39  return *this;
40  }
41 
45  inline BoundingBox& Draw(::Color color = {255, 255, 255, 255}) {
46  DrawBoundingBox(*this, color);
47  return *this;
48  }
49 
53  inline bool CheckCollision(const ::BoundingBox& box2) const {
54  return CheckCollisionBoxes(*this, box2);
55  }
56 
60  inline bool CheckCollision(::Vector3 center, float radius) const {
61  return CheckCollisionBoxSphere(*this, center, radius);
62  }
63 
67  inline bool CheckCollision(const ::Ray& ray) const {
68  return CheckCollisionRayBox(ray, *this);
69  }
70 
71  private:
72  inline void set(const ::BoundingBox& box) {
73  min = box.min;
74  max = box.max;
75  }
76 };
77 } // namespace raylib
78 
79 #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:45
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:60
raylib::BoundingBox::CheckCollision
bool CheckCollision(const ::BoundingBox &box2) const
Detect collision between two boxes.
Definition: BoundingBox.hpp:53
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:67