raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
raylib::Ray Class Reference

Ray type (useful for raycast) More...

#include <Ray.hpp>

Public Member Functions

 Ray (::Vector2 mousePosition, const ::Camera &camera)
 
 Ray (::Vector3 position={0.0f, 0.0f, 0.0f}, ::Vector3 direction={0.0f, 0.0f, 0.0f})
 
 Ray (const ::Ray &ray)
 
void Draw (::Color color) const
 Draw a ray line. More...
 
RayCollision GetCollision (::Vector3 center, float radius) const
 Get collision information between ray and sphere. More...
 
RayCollision GetCollision (::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const
 Get collision info between ray and triangle. More...
 
RayCollision GetCollision (::Vector3 p1, ::Vector3 p2, ::Vector3 p3, ::Vector3 p4) const
 Get collision info between ray and quad. More...
 
RayCollision GetCollision (const ::BoundingBox &box) const
 Detect collision between ray and box. More...
 
RayCollision GetCollision (const ::Mesh &mesh, const ::Matrix &transform) const
 Get collision information between ray and mesh. More...
 
::Vector3 GetDirection () const
 Retrieves the direction value for the object. More...
 
::Vector3 GetPosition () const
 Retrieves the position value for the object. More...
 
Rayoperator= (const ::Ray &ray)
 
void SetDirection (::Vector3 value)
 Sets the direction value for the object. More...
 
void SetPosition (::Vector3 value)
 Sets the position value for the object. More...
 

Static Public Member Functions

static Ray GetMouse (::Vector2 mousePosition, const ::Camera &camera)
 Get a ray trace from mouse position. More...
 
static Ray GetMouse (const ::Camera &camera)
 Get a ray trace from mouse position. More...
 

Protected Member Functions

void set (const ::Ray &ray)
 

Detailed Description

Ray type (useful for raycast)

Definition at line 12 of file Ray.hpp.

Constructor & Destructor Documentation

◆ Ray() [1/3]

raylib::Ray::Ray ( const ::Ray &  ray)
inline

Definition at line 14 of file Ray.hpp.

◆ Ray() [2/3]

raylib::Ray::Ray ( ::Vector3  position = {0.0f, 0.0f, 0.0f},
::Vector3  direction = {0.0f, 0.0f, 0.0f} 
)
inline

Definition at line 18 of file Ray.hpp.

◆ Ray() [3/3]

raylib::Ray::Ray ( ::Vector2  mousePosition,
const ::Camera &  camera 
)
inline

Definition at line 23 of file Ray.hpp.

Member Function Documentation

◆ Draw()

void raylib::Ray::Draw ( ::Color  color) const
inline

Draw a ray line.

Definition at line 38 of file Ray.hpp.

◆ GetCollision() [1/5]

RayCollision raylib::Ray::GetCollision ( ::Vector3  center,
float  radius 
) const
inline

Get collision information between ray and sphere.

Definition at line 45 of file Ray.hpp.

◆ GetCollision() [2/5]

RayCollision raylib::Ray::GetCollision ( ::Vector3  p1,
::Vector3  p2,
::Vector3  p3 
) const
inline

Get collision info between ray and triangle.

Definition at line 66 of file Ray.hpp.

◆ GetCollision() [3/5]

RayCollision raylib::Ray::GetCollision ( ::Vector3  p1,
::Vector3  p2,
::Vector3  p3,
::Vector3  p4 
) const
inline

Get collision info between ray and quad.

Definition at line 73 of file Ray.hpp.

◆ GetCollision() [4/5]

RayCollision raylib::Ray::GetCollision ( const ::BoundingBox &  box) const
inline

Detect collision between ray and box.

Definition at line 52 of file Ray.hpp.

◆ GetCollision() [5/5]

RayCollision raylib::Ray::GetCollision ( const ::Mesh &  mesh,
const ::Matrix &  transform 
) const
inline

Get collision information between ray and mesh.

Definition at line 59 of file Ray.hpp.

◆ GetDirection()

::Vector3 raylib::Ray::GetDirection ( ) const
inline

Retrieves the direction value for the object.

Returns
The direction value of the object.

Definition at line 33 of file Ray.hpp.

◆ GetMouse() [1/2]

static Ray raylib::Ray::GetMouse ( ::Vector2  mousePosition,
const ::Camera &  camera 
)
inlinestatic

Get a ray trace from mouse position.

Definition at line 80 of file Ray.hpp.

◆ GetMouse() [2/2]

static Ray raylib::Ray::GetMouse ( const ::Camera &  camera)
inlinestatic

Get a ray trace from mouse position.

Definition at line 87 of file Ray.hpp.

◆ GetPosition()

::Vector3 raylib::Ray::GetPosition ( ) const
inline

Retrieves the position value for the object.

Returns
The position value of the object.

Definition at line 32 of file Ray.hpp.

◆ operator=()

Ray & raylib::Ray::operator= ( const ::Ray &  ray)
inline

Definition at line 27 of file Ray.hpp.

◆ set()

void raylib::Ray::set ( const ::Ray &  ray)
inlineprotected

Definition at line 92 of file Ray.hpp.

◆ SetDirection()

void raylib::Ray::SetDirection ( ::Vector3  value)
inline

Sets the direction value for the object.

Parameters
valueThe value of which to set direction to.

Definition at line 33 of file Ray.hpp.

◆ SetPosition()

void raylib::Ray::SetPosition ( ::Vector3  value)
inline

Sets the position value for the object.

Parameters
valueThe value of which to set position to.

Definition at line 32 of file Ray.hpp.