Cumulia Illustrator Rendering Engine v1.1.0
A Rendering engine for industrial CAD/CAE model and optimized for greatest performance
 
Loading...
Searching...
No Matches
ray.h
1//##################################################################################################
2//
3// Copyright (c) 2024 Beijing Qiongqi Tech Co.,Ltd. All rights reserved.
4
5// This source code is confidential and proprietary to Beijing Qiongqi Tech Co.,Ltd(The Holder).
6// Any unauthorized use, copying, modification, or distribution of the code is strictly prohibited.
7// Any user shall obtain authorizaition from the Holder before modifying the source code. And the user shall not
8// sublicense, sell, distribute, or transfer the source code, whether in original or modified form, to any third party
9// without the prior written consent of the Holder.
10
11// This copyright notice and permission grant shall be included in all copies or substantial portions of the source code.
12
13// Author Cumulia Illustrator
14// Date 2024-10-31
15// Version V1.1.0
16//##################################################################################################
17
18#pragma once
19
20#include "tuple.h"
21
22namespace cil
23{
24 class Vector3f;
25 class Matrix4f;
26 class BoundingBox;
27 class Plane;
30 class Ray : public Tuple<float>
31 {
32 public:
33 Ray();
34 Ray(const Ray& other);
35 Ray(const Vector3f& origin, const Vector3f& normal);
36
38 const float& operator[](int index) const;
40 float& operator[](int index);
41
43 void set(const Vector3f& origin, const Vector3f& direction);
52
54 Vector3f project(const Vector3f& point) const;
56 void transform(const Matrix4f& other);
57
59 bool triangleIntersect(const Vector3f& v1, const Vector3f& v2, const Vector3f& v3, Vector3f* intersectionPoint = nullptr, Vector3f* intersectionPointNormal = nullptr) const;
61 bool quadIntersect(const Vector3f& v1, const Vector3f& v2, const Vector3f& v3, const Vector3f& v4, Vector3f* intersectionPoint = nullptr) const;
63 bool lineIntersect(const Vector3f& v1, const Vector3f& v2, float radius, Vector3f* intersectionPoint = nullptr) const;
65 bool pointIntersect(const Vector3f& v1, float radius) const;
67 bool boxIntersect(const BoundingBox& box, Vector3f* intersectionPoint = nullptr) const;
69 bool planeIntersect(const Plane& plane, Vector3f* intersectionPoint = nullptr) const;
70 };
71
72 using ray = Ray;
73}
The BoundingBox class inherits from Box3, specilizing the template parameters to float for element ty...
Definition box.h:224
The Matrix4f class is 4 X 4 matrix.
Definition matrix.h:226
The Plane class inherits from the Tuple class, specilizing the templated parameter to float for eleme...
Definition plane.h:30
The Ray class inherits from the Tuple class, specilizing the templated parameter to float for element...
Definition ray.h:31
Ray()
Constructs a Ray object, all elements initialized to 0.
Vector3f direction() const
Gets a Vector3f object that is the direction of the current Ray.
bool planeIntersect(const Plane &plane, Vector3f *intersectionPoint=nullptr) const
Returns true if the ray intersects the plane.
void transform(const Matrix4f &other)
Transform the current Ray object using the other transformation matrix.
bool boxIntersect(const BoundingBox &box, Vector3f *intersectionPoint=nullptr) const
Returns true if the ray intersects the bounding box.
Ray(const Vector3f &origin, const Vector3f &normal)
Constructs a Ray object using the origin point and the direction.
Vector3f project(const Vector3f &point) const
Gets the projected point of the other point on the current Ray.
bool pointIntersect(const Vector3f &v1, float radius) const
Returns true if the ray intersects the point.
float & operator[](int index)
Provides read-write access to the element at a specific index(position) within the Ray object.
Vector3f origin() const
Gets a Vector3f object that is the origin of the current Ray.
void set(const Vector3f &origin, const Vector3f &direction)
Sets the origin point and direction of the Ray object.
bool lineIntersect(const Vector3f &v1, const Vector3f &v2, float radius, Vector3f *intersectionPoint=nullptr) const
Returns true if the ray intersects the line.
bool triangleIntersect(const Vector3f &v1, const Vector3f &v2, const Vector3f &v3, Vector3f *intersectionPoint=nullptr, Vector3f *intersectionPointNormal=nullptr) const
Returns true if the ray intersects the triangle.
void setDirection(const Vector3f &direction)
Sets the direction ot the current Ray.
const float & operator[](int index) const
Provides read-only access to the element at a specific index(position) within the Ray object.
Ray(const Ray &other)
void setOrigin(const Vector3f &origin)
Sets the origin of the current Ray.
bool quadIntersect(const Vector3f &v1, const Vector3f &v2, const Vector3f &v3, const Vector3f &v4, Vector3f *intersectionPoint=nullptr) const
Returns true if the ray intersects the quad.
The Tuple is a templated class inheriting from the most basic class Variant.
Definition tuple.h:27
The class Vector3f inherits from the templated class of Vector3, and the template parameters are spec...
Definition vector.h:322
Definition decal.h:23