17 #ifndef GZ_RENDERING_BASE_BASERAYQUERY_HH_
18 #define GZ_RENDERING_BASE_BASERAYQUERY_HH_
20 #include <gz/math/Matrix4.hh>
21 #include <gz/math/Vector3.hh>
30 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
47 public:
virtual void SetOrigin(
const math::Vector3d &_origin)
override;
53 public:
virtual void SetDirection(
const math::Vector3d &_dir)
override;
59 public:
virtual void SetFromCamera(
const CameraPtr &_camera,
64 bool _forceSceneUpdate =
true)
override;
89 this->origin = _origin;
103 this->direction = _dir;
110 return this->direction;
122 math::Matrix4d viewProjInv = (projectionMatrix * viewMatrix).Inverse();
127 double startw = viewProjInv(3, 0) * start[0] +
128 viewProjInv(3, 1) * start[1] +
129 viewProjInv(3, 2) * start[2] + viewProjInv(3, 3);
130 double endw = viewProjInv(3, 0) * end[0] +
131 viewProjInv(3, 1) * end[1] +
132 viewProjInv(3, 2) * end[2] + viewProjInv(3, 3);
133 start = viewProjInv * start;
134 end = viewProjInv * end;
136 start = start / startw;
140 this->origin = start;
141 this->direction = dir;