raylib-cpp
C++ object-oriented wrapper library for raylib.
RayHitInfo.hpp
1 /*
2 * LICENSE: zlib/libpng
3 *
4 * raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
5 * BSD-like license that allows static linking with closed source software:
6 *
7 * Copyright (c) 2020 Rob Loach (@RobLoach)
8 *
9 * This software is provided "as-is", without any express or implied warranty. In no event
10 * will the authors be held liable for any damages arising from the use of this software.
11 *
12 * Permission is granted to anyone to use this software for any purpose, including commercial
13 * applications, and to alter it and redistribute it freely, subject to the following restrictions:
14 *
15 * 1. The origin of this software must not be misrepresented; you must not claim that you
16 * wrote the original software. If you use this software in a product, an acknowledgment
17 * in the product documentation would be appreciated but is not required.
18 *
19 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
20 * as being the original software.
21 *
22 * 3. This notice may not be removed or altered from any source distribution.
23 */
24 
25 #ifndef RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
26 #define RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
27 
28 #include "./raylib.hpp"
29 #include "./raylib-cpp-utils.hpp"
30 
31 namespace raylib {
35 class RayHitInfo : public ::RayHitInfo {
36  public:
37  RayHitInfo(const ::RayHitInfo& ray) {
38  set(ray);
39  }
40 
41  RayHitInfo(bool Hit, float Distance, ::Vector3 Position, ::Vector3 Normal) {
42  hit = Hit;
43  distance = Distance;
44  position = Position;
45  normal = Normal;
46  }
47 
51  RayHitInfo(const ::Ray& ray, const ::Model& model) {
52  set(::GetCollisionRayModel(ray, model));
53  }
54 
58  RayHitInfo(const ::Ray& ray, ::Vector3 p1, ::Vector3 p2, ::Vector3 p3) {
59  set(::GetCollisionRayTriangle(ray, p1, p2, p3));
60  }
61 
65  RayHitInfo(const ::Ray& ray, float groundHeight) {
66  set(::GetCollisionRayGround(ray, groundHeight));
67  }
68 
69  RayHitInfo& operator=(const ::RayHitInfo& ray) {
70  set(ray);
71  return *this;
72  }
73 
74  GETTERSETTER(bool, Hit, hit)
75  GETTERSETTER(float, Distance, distance)
76  GETTERSETTER(::Vector3, Position, position)
77  GETTERSETTER(::Vector3, Normal, normal)
78 
79  protected:
80  inline void set(const ::RayHitInfo& ray) {
81  hit = ray.hit;
82  distance = ray.distance;
83  position = ray.position;
84  normal = ray.normal;
85  }
86 };
87 } // namespace raylib
88 
89 #endif // RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:31
raylib::RayHitInfo::RayHitInfo
RayHitInfo(const ::RayHitInfo &ray)
Definition: RayHitInfo.hpp:37
raylib::RayHitInfo::RayHitInfo
RayHitInfo(const ::Ray &ray, ::Vector3 p1, ::Vector3 p2, ::Vector3 p3)
Get collision info between ray and triangle.
Definition: RayHitInfo.hpp:58
raylib::Vector3
Definition: Vector3.hpp:37
raylib::RayHitInfo::set
void set(const ::RayHitInfo &ray)
Definition: RayHitInfo.hpp:80
raylib::RayHitInfo::operator=
RayHitInfo & operator=(const ::RayHitInfo &ray)
Definition: RayHitInfo.hpp:69
raylib::RayHitInfo::RayHitInfo
RayHitInfo(const ::Ray &ray, float groundHeight)
Get collision info between ray and ground plane (Y-normal plane)
Definition: RayHitInfo.hpp:65
raylib::RayHitInfo
Raycast hit information.
Definition: RayHitInfo.hpp:35
raylib::RayHitInfo::RayHitInfo
RayHitInfo(const ::Ray &ray, const ::Model &model)
Get collision info between ray and model.
Definition: RayHitInfo.hpp:51
raylib::RayHitInfo::RayHitInfo
RayHitInfo(bool Hit, float Distance, ::Vector3 Position, ::Vector3 Normal)
Definition: RayHitInfo.hpp:41