Cocos2d-x  v3.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
Ray Class Reference

Ray is a line with a start point. More...

Public Member Functions

 Ray ()
 Constructor.
 
 Ray (const Ray &ray)
 Copy Constructor.
 
 Ray (const Vec3 &origin, const Vec3 &direction)
 Constructs a new ray initialized to the specified origin and direction. More...
 
 ~Ray ()
 Destructor.
 
bool intersects (const AABB &aabb, float *distance=nullptr) const
 Check whether this ray intersects with the specified AABB. More...
 
local intersects ( local aabb, local nullptr)
 Check whether this ray intersects with the specified AABB. More...
 
bool intersects (const OBB &obb, float *distance=nullptr) const
 Check whether this ray intersects with the specified OBB. More...
 
float dist (const Plane &plane) const
 Get the distance to the plane. More...
 
Vec3 intersects (const Plane &plane) const
 Check whether this ray intersects with the specified Plane. More...
 
void set (const Vec3 &origin, const Vec3 &direction)
 Sets this ray to the specified origin and direction. More...
 
local set ( local origin, local direction)
 Sets this ray to the specified origin and direction. More...
 
void transform (const Mat4 &matrix)
 Transforms this ray by the given transformation matrix. More...
 
local transform ( local matrix)
 Transforms this ray by the given transformation matrix. More...
 

Public Attributes

Vec3 _origin
 The ray origin position.
 
local _origin
 The ray origin position.
 
Vec3 _direction
 The ray direction vector.
 
local _direction
 The ray direction vector.
 

Detailed Description

Ray is a line with a start point.

usually use it to check intersects with some object,such as Plane, OBB, AABB

Constructor & Destructor Documentation

Ray ( const Vec3 origin,
const Vec3 direction 
)

Constructs a new ray initialized to the specified origin and direction.

The ray's origin. The ray's direction.

local new ( local  origin,
local  direction 
)

Constructs a new ray initialized to the specified origin and direction.

The ray's origin. The ray's direction.

Member Function Documentation

bool intersects ( const AABB aabb,
float *  distance = nullptr 
) const

Check whether this ray intersects with the specified AABB.

Parameters
aabbThe AABB object.
distanceThe distance between the orign to the intersection point.
Returns
Return true if the AABB intersect with the ray, otherwise return false.
local intersects ( local  aabb,
local  distance = nullptr 
)

Check whether this ray intersects with the specified AABB.

Parameters
aabbThe AABB object.
distanceThe distance between the orign to the intersection point.
Returns
Return true if the AABB intersect with the ray, otherwise return false.
bool intersects ( const OBB obb,
float *  distance = nullptr 
) const

Check whether this ray intersects with the specified OBB.

The OBB object. The distance between the orign to the intersection point. Return true if the OBB intersect with the ray, otherwise return false.

local intersects ( local  obb,
local  distance = nullptr 
)

Check whether this ray intersects with the specified OBB.

The OBB object. The distance between the orign to the intersection point. Return true if the OBB intersect with the ray, otherwise return false.

float dist ( const Plane plane) const

Get the distance to the plane.

The specified plane. The distance to the plane.

local dist ( local  plane)

Get the distance to the plane.

The specified plane. The distance to the plane.

Vec3 intersects ( const Plane plane) const

Check whether this ray intersects with the specified Plane.

The Plane object. The intersection point.

local intersects ( local  plane)

Check whether this ray intersects with the specified Plane.

The Plane object. The intersection point.

void set ( const Vec3 origin,
const Vec3 direction 
)

Sets this ray to the specified origin and direction.

The ray's origin. The ray's direction.

local set ( local  origin,
local  direction 
)

Sets this ray to the specified origin and direction.

The ray's origin. The ray's direction.

void transform ( const Mat4 matrix)

Transforms this ray by the given transformation matrix.

The transformation matrix to transform by.

local transform ( local  matrix)

Transforms this ray by the given transformation matrix.

The transformation matrix to transform by.


The documentation for this class was generated from the following file: