VR-Engage  2.2
Loading...
Searching...
No Matches
intersector.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file intersector.h
7//! \brief Defines the DtIntersector interface for ray casting and intersection testing
8//!
9//! This file contains the DtIntersector abstract base class which provides an interface
10//! for performing ray intersection tests with the 3D environment. This includes tests
11//! against terrain, entities, and other scene elements. The interface supports various
12//! forms of intersection testing needed for player interaction, targeting, and navigation.
13
14#pragma once
15
17
18#include <vrvCore/DtUniqueID.h>
19
20#include <matrix/vlVector.h>
21#include <matrix/vlTaitBryan.h>
22
23namespace makVre
24{
25//! \brief Abstract base class for performing intersection tests in 3D space
26//!
27//! DtIntersector provides an interface for performing various types of intersection
28//! tests within the 3D environment. This includes ray casting against terrain and
29//! entities, elevation queries, and screen-to-world coordinate conversion. These
30//! capabilities are essential for features like targeting, navigation, and object
31//! selection through clicking or pointing.
32//!
33//! Concrete implementations of this interface are typically provided by display
34//! systems like OpenSceneGraph that have access to the full scene graph and can
35//! perform efficient intersection tests.
37{
38public:
39 //! \brief Constructor
40 //!
41 //! Creates a new intersector instance with default values.
43
44 //! \brief Virtual destructor
45 //!
46 //! Ensures proper cleanup of derived intersector classes.
47 virtual ~DtIntersector();
48
49 //! \brief Gets the elevation at a specific point
50 //! \param point 3D position to query for elevation
51 //! \param result Output parameter to receive the elevation value
52 //! \return True if the elevation was successfully determined, false otherwise
53 //!
54 //! Determines the terrain elevation at the specified horizontal position.
55 //! The result is the height above mean sea level in meters. This is useful
56 //! for determining the ground level for placement of objects.
57 virtual bool elevationAt(DtVector point, double& result) = 0;
58
59 //! \brief Gets the terrain intersection point at a specific location
60 //! \param point 3D position to project onto the terrain
61 //! \param result Output parameter to receive the intersection point
62 //! \return True if the intersection was successfully determined, false otherwise
63 //!
64 //! Projects the given point onto the terrain surface along the vertical axis.
65 //! The result is the 3D position on the terrain surface. This differs from
66 //! elevationAt by returning a complete 3D point rather than just the height.
67 virtual bool terrainIntersectionAt(DtVector point, DtVector& result) = 0;
68
69 //! \brief Performs a ray intersection test between two points
70 //! \param start Starting point of the ray
71 //! \param end Ending point of the ray
72 //! \param result Output parameter to receive the intersection point
73 //! \param ignoreId Optional list of entity IDs to ignore in the test
74 //! \return True if an intersection was found, false otherwise
75 //!
76 //! Tests for intersection of a finite ray from start to end with any objects
77 //! in the scene. If an intersection is found, the result parameter is set to
78 //! the intersection point. The optional ignoreId parameter allows specific
79 //! entities to be excluded from the test.
80 virtual bool getIntersection(
81 DtVector start, DtVector end, DtVector& result, std::vector<makVrv::DtElementID>* ignoreId = 0) = 0;
82
83 //! \brief Performs a ray intersection test from a point in a direction
84 //! \param start Starting point of the ray
85 //! \param ori Orientation defining the ray direction
86 //! \param result Output parameter to receive the intersection point
87 //! \param ignoreId Optional list of entity IDs to ignore in the test
88 //! \return True if an intersection was found, false otherwise
89 //!
90 //! Tests for intersection of a ray starting at the specified point and
91 //! extending in the direction defined by the orientation. If an intersection
92 //! is found, the result parameter is set to the intersection point. The optional
93 //! ignoreId parameter allows specific entities to be excluded from the test.
94 virtual bool getIntersection(
95 DtVector start, DtTaitBryan ori, DtVector& result, std::vector<makVrv::DtElementID>* ignoreId = 0) = 0;
96
97 //! \brief Performs a ray cast from screen coordinates
98 //! \param x Horizontal screen coordinate (in pixels)
99 //! \param y Vertical screen coordinate (in pixels)
100 //! \param result Output parameter to receive the intersection point
101 //! \return True if an intersection was found, false otherwise
102 //!
103 //! Projects a ray from the camera through the specified screen coordinates
104 //! and finds the first intersection with objects in the scene. This is typically
105 //! used for mouse picking operations, converting a 2D screen click to a 3D
106 //! position in the world.
107 virtual bool screenRayCast(float x, float y, DtVector& result) = 0;
108
109protected:
110};
111} // namespace makVre
virtual bool getIntersection(DtVector start, DtVector end, DtVector &result, std::vector< makVrv::DtElementID > *ignoreId=0)=0
Performs a ray intersection test between two points.
virtual bool getIntersection(DtVector start, DtTaitBryan ori, DtVector &result, std::vector< makVrv::DtElementID > *ignoreId=0)=0
Performs a ray intersection test from a point in a direction.
virtual bool terrainIntersectionAt(DtVector point, DtVector &result)=0
Gets the terrain intersection point at a specific location.
virtual ~DtIntersector()
Virtual destructor.
virtual bool screenRayCast(float x, float y, DtVector &result)=0
Performs a ray cast from screen coordinates.
DtIntersector()
Constructor.
virtual bool elevationAt(DtVector point, double &result)=0
Gets the elevation at a specific point.
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49