VR-Engage  2.2
Loading...
Searching...
No Matches
surfaceToVxMaterialMapper.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file surfaceToVxMaterialMapper.h
7//! \brief Provides mapping functionality between VR-Forces terrain surface types and Vortex physics materials
8//! \ingroup vreVrfVortex
9
10#pragma once
11
12#include "vreVrfVortex/export.h"
13
14#include <geometry/surface.h>
15
16namespace Vx
17{
18class VxMaterial;
19class VxMaterialTable;
20} // namespace Vx
21
22namespace makVre
23{
24//! \brief Structure that holds information about a Vortex surface material mapping
25//!
26//! Stores the Vortex material associated with a terrain surface type as well as
27//! various flags that control how the surface is handled in the physics simulation.
29{
30 //! \brief Default constructor
31 //!
32 //! Initializes a surface info with no material and all flags set to false.
34 : material(nullptr)
35 , isFiltered(false)
37 , isUsingDefault(false)
38 {
39 }
40
41 Vx::VxMaterial* material; //!< Pointer to the Vortex material
42 bool isFiltered; //!< Flag indicating if this surface should be filtered out in triangle generation
43 bool shouldUseRoughnessMap; //!< Flag indicating if roughness mapping should be used for this surface
44 bool isUsingDefault; //!< Flag indicating if this surface is using the default material
45 std::string surfaceTypeString; //!< String representation of the surface type
46 std::string surfaceTypeMapping; //!< The material mapping string from configuration
47};
48
49//! \brief Class for mapping VR-Forces terrain surface types to Vortex physics materials
50//!
51//! This class provides the functionality to translate between VR-Forces terrain surface types
52//! (soil, water, cultural features, etc.) and Vortex physics materials. It maintains lookup
53//! tables for different surface type categories and provides methods to retrieve the appropriate
54//! Vortex material for a given surface.
56{
57public:
58 //! \brief Default constructor
59 //!
60 //! Initializes an empty material mapper with no default material.
62
63 //! \brief Destructor
64 //!
65 //! Cleans up all allocated surface info objects in the mapping tables.
67
68 //! \brief Initialize the material mapper with a Vortex material table
69 //!
70 //! Sets up the mapping between VR-Forces surface types and Vortex materials
71 //! based on configuration settings in vortexConfig.lua. This includes setting
72 //! up the default material, material mapping tables, and filter lists.
73 //!
74 //! \param val Pointer to the Vortex material table containing available materials
75 virtual void init(const Vx::VxMaterialTable* val);
76
77 //! \brief Get the Vortex material for a specific terrain surface
78 //!
79 //! Determines the appropriate Vortex material based on the surface type.
80 //! For water surfaces, it uses the body of water type mapping.
81 //! For cultural features, it uses the cultural feature type mapping.
82 //! For ground or flimsy surfaces, it uses the soil type mapping.
83 //! Otherwise, it uses the roughness soil type mapping.
84 //!
85 //! \param surf The terrain surface to get the material for
86 //! \return Pointer to the corresponding Vortex material
87 Vx::VxMaterial* getVortexMaterial(const DtSurface& surf);
88
89 //! \brief Get the default Vortex material
90 //!
91 //! Returns the default material that is used when a specific mapping
92 //! is not found or when explicitly configured to use the default.
93 //!
94 //! \return Pointer to the default Vortex material
95 Vx::VxMaterial* getDefaultVortexMaterial();
96
97 //! \brief Check if a surface should be filtered out
98 //!
99 //! Determines if a given surface should be excluded from triangle generation
100 //! based on configuration settings.
101 //!
102 //! \param surf The terrain surface to check
103 //! \return True if the surface should be filtered out, false otherwise
104 bool isFiltered(const DtSurface& surf);
105
106 //! \brief Get the surface info for a specific terrain surface
107 //!
108 //! Retrieves the VortexSurfaceInfo object containing material and flags
109 //! for the given terrain surface. The appropriate info is selected based on
110 //! the surface type (water, cultural feature, ground, or roughness).
111 //!
112 //! \param surf The terrain surface to get the info for
113 //! \return Pointer to the corresponding VortexSurfaceInfo
114 VortexSurfaceInfo* getSurfaceInfo(const DtSurface& surf) const;
115
116protected:
117 Vx::VxMaterial* myDefaultMaterial; //!< The default Vortex material to use when no specific mapping is found
118
119 std::vector<VortexSurfaceInfo*> mySoilTypeToMaterialMap; //!< Mapping from soil types to Vortex materials
120 std::vector<VortexSurfaceInfo*>
121 myBodyOfWaterTypeToMaterialMap; //!< Mapping from body of water types to Vortex materials
122 std::vector<VortexSurfaceInfo*>
123 myCulturalFeatureTypeToMaterialMap; //!< Mapping from cultural feature types to Vortex materials
124 std::vector<VortexSurfaceInfo*>
125 myRoughnessSoilTypeToMaterialMap; //!< Mapping from roughness soil types to Vortex materials
126};
127} // namespace makVre
std::vector< VortexSurfaceInfo * > mySoilTypeToMaterialMap
Mapping from soil types to Vortex materials.
Definition surfaceToVxMaterialMapper.h:119
std::vector< VortexSurfaceInfo * > myCulturalFeatureTypeToMaterialMap
Mapping from cultural feature types to Vortex materials.
Definition surfaceToVxMaterialMapper.h:123
std::vector< VortexSurfaceInfo * > myRoughnessSoilTypeToMaterialMap
Mapping from roughness soil types to Vortex materials.
Definition surfaceToVxMaterialMapper.h:125
bool isFiltered(const DtSurface &surf)
Check if a surface should be filtered out.
virtual ~DtSurfaceToVxMaterialMapper()
Destructor.
Vx::VxMaterial * getDefaultVortexMaterial()
Get the default Vortex material.
Vx::VxMaterial * myDefaultMaterial
The default Vortex material to use when no specific mapping is found.
Definition surfaceToVxMaterialMapper.h:117
VortexSurfaceInfo * getSurfaceInfo(const DtSurface &surf) const
Get the surface info for a specific terrain surface.
std::vector< VortexSurfaceInfo * > myBodyOfWaterTypeToMaterialMap
Mapping from body of water types to Vortex materials.
Definition surfaceToVxMaterialMapper.h:121
DtSurfaceToVxMaterialMapper()
Default constructor.
virtual void init(const Vx::VxMaterialTable *val)
Initialize the material mapper with a Vortex material table.
Vx::VxMaterial * getVortexMaterial(const DtSurface &surf)
Get the Vortex material for a specific terrain surface.
Export macros for the VR-Forces Vortex extension library.
#define VREVRFVORTEX_DLL
Export macro for non-Windows platforms.
Definition export.h:30
Wheel articulated part IDs used in the system.
Definition surfaceToVxMaterialMapper.h:17
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
Structure that holds information about a Vortex surface material mapping.
Definition surfaceToVxMaterialMapper.h:29
bool isFiltered
Flag indicating if this surface should be filtered out in triangle generation.
Definition surfaceToVxMaterialMapper.h:42
VortexSurfaceInfo()
Default constructor.
Definition surfaceToVxMaterialMapper.h:33
Vx::VxMaterial * material
Pointer to the Vortex material.
Definition surfaceToVxMaterialMapper.h:41
std::string surfaceTypeString
String representation of the surface type.
Definition surfaceToVxMaterialMapper.h:45
bool isUsingDefault
Flag indicating if this surface is using the default material.
Definition surfaceToVxMaterialMapper.h:44
std::string surfaceTypeMapping
The material mapping string from configuration.
Definition surfaceToVxMaterialMapper.h:46
bool shouldUseRoughnessMap
Flag indicating if roughness mapping should be used for this surface.
Definition surfaceToVxMaterialMapper.h:43