Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
CesiumFeatureIdAttribute.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "Kismet/BlueprintFunctionLibrary.h"
6#include <CesiumGltf/AccessorUtility.h>
7#include "CesiumFeatureIdAttribute.generated.h"
8
9namespace CesiumGltf {
10struct Model;
11struct Accessor;
12struct Node;
13} // namespace CesiumGltf
14
15/**
16 * @brief Reports the status of a FCesiumFeatureIdAttribute. If the feature ID
17 * attribute cannot be accessed, this briefly indicates why.
18 */
19UENUM(BlueprintType)
21 /* The feature ID attribute is valid. */
22 Valid = 0,
23 /* The feature ID attribute does not exist in the glTF primitive. */
25 /* The feature ID attribute uses an invalid accessor in the glTF. */
27};
28
29/**
30 * @brief A blueprint-accessible wrapper for a feature ID attribute from a glTF
31 * model. Provides access to feature IDs which can be used with the
32 * corresponding {@link FCesiumPropertyTable} to access metadata. These feature
33 * IDs may be defined per-vertex or per-instance.
34 */
35USTRUCT(BlueprintType)
36struct CESIUMRUNTIME_API FCesiumFeatureIdAttribute {
37 GENERATED_USTRUCT_BODY()
38
39public:
40 /**
41 * @brief Constructs an empty feature ID attribute instance. Empty feature ID
42 * attributes can be constructed while trying to convert a FCesiumFeatureIdSet
43 * that is not an attribute. In this case, the status reports it is an invalid
44 * attribute.
45 */
48 _featureIdAccessor(),
49 _attributeIndex(-1) {}
50
51 /**
52 * @brief Constructs a feature ID attribute instance.
53 *
54 * @param Model The model.
55 * @param Primitive The mesh primitive containing the feature ID attribute.
56 * @param FeatureIDAttribute The attribute index specified by the FeatureId.
57 * @param PropertyTableName The name of the property table this attribute
58 * corresponds to, if one exists, for backwards compatibility.
59 */
61 const CesiumGltf::Model& Model,
62 const CesiumGltf::MeshPrimitive& Primitive,
63 const int64 FeatureIDAttribute,
64 const FString& PropertyTableName);
65
66 /**
67 * @brief Constructs a feature ID attribute instance from
68 * EXT_instance_features data.
69 *
70 * @param Model The model.
71 * @param Node The node containing the feature ID attribute.
72 * @param FeatureIDAttribute The attribute index specified by the FeatureId.
73 * @param PropertyTableName The name of the property table this attribute
74 * corresponds to, if one exists, for backwards compatibility.
75 */
77 const CesiumGltf::Model& Model,
78 const CesiumGltf::Node& Node,
79 const int64 FeatureIDAttribute,
80 const FString& PropertyTableName);
81
82 /**
83 * Gets the index of this feature ID attribute in the glTF primitive.
84 */
85 int64 getAttributeIndex() const { return this->_attributeIndex; }
86
87private:
89 CesiumGltf::FeatureIdAccessorType _featureIdAccessor;
90 int64 _attributeIndex;
91
92 // For backwards compatibility.
93 FString _propertyTableName;
94
96};
97
98UCLASS()
100 : public UBlueprintFunctionLibrary {
101 GENERATED_BODY()
102
103public:
104 PRAGMA_DISABLE_DEPRECATION_WARNINGS
105 /**
106 * Get the name of the feature table corresponding to this feature ID
107 * attribute. The name can be used to fetch the appropriate
108 * FCesiumFeatureTable from the FCesiumMetadataModel.
109 */
110 UFUNCTION(
111 BlueprintCallable,
112 BlueprintPure,
113 Meta =
114 (DeprecatedFunction,
115 DeprecationMessage =
116 "Use GetPropertyTableIndex on a CesiumFeatureIdSet instead."))
117 static const FString&
119 const FCesiumFeatureIdAttribute& FeatureIDAttribute);
120 PRAGMA_ENABLE_DEPRECATION_WARNINGS
121
122 /**
123 * Gets the status of the feature ID attribute. If this attribute is
124 * invalid in any way, this will briefly indicate why.
125 */
126 UFUNCTION(
127 BlueprintCallable,
128 BlueprintPure,
129 Category = "Cesium|Features|FeatureIDAttribute")
131 UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute);
132
133 /**
134 * Gets the number of elements in the attribute. This is distinct from the
135 * number of unique feature IDs within the attribute.
136 *
137 * For a feature ID attribute of a regular mesh, this is the number of
138 * vertices. For a per-instance feature ID, this is the number of instances.
139 *
140 * If the feature ID attribute is invalid, this returns 0.
141 */
142 UFUNCTION(
143 BlueprintCallable,
144 BlueprintPure,
145 Category = "Cesium|Features|FeatureIDAttribute")
146 static int64
147 GetCount(UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute);
148
149 /**
150 * Gets the feature ID at the given index. A feature ID can be used with a
151 * FCesiumPropertyTable to retrieve the metadata for that ID. If the feature
152 * ID attribute is invalid, this returns -1.
153 *
154 * For a feature ID attribute of a regular mesh, the provided Index is the
155 * index of a vertex within the mesh. For a per-instance feature ID, the
156 * provided Index is the index of the instance.
157 */
158 UFUNCTION(
159 BlueprintCallable,
160 BlueprintPure,
161 Category = "Cesium|Features|FeatureIDAttribute")
162 static int64 GetFeatureID(
163 UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute,
164 int64 Index);
165};
ECesiumFeatureIdAttributeStatus
Reports the status of a FCesiumFeatureIdAttribute.
static int64 GetFeatureID(UPARAM(ref) const FCesiumFeatureIdAttribute &FeatureIDAttribute, int64 Index)
Gets the feature ID at the given index.
static PRAGMA_ENABLE_DEPRECATION_WARNINGS ECesiumFeatureIdAttributeStatus GetFeatureIDAttributeStatus(UPARAM(ref) const FCesiumFeatureIdAttribute &FeatureIDAttribute)
Gets the status of the feature ID attribute.
static int64 GetCount(UPARAM(ref) const FCesiumFeatureIdAttribute &FeatureIDAttribute)
Gets the number of elements in the attribute.
static PRAGMA_DISABLE_DEPRECATION_WARNINGS const FString & GetFeatureTableName(UPARAM(ref) const FCesiumFeatureIdAttribute &FeatureIDAttribute)
Get the name of the feature table corresponding to this feature ID attribute.
std::variant< AccessorView< int8_t >, AccessorView< uint8_t >, AccessorView< int16_t >, AccessorView< uint16_t >, AccessorView< uint32_t >, AccessorView< float > > FeatureIdAccessorType
A blueprint-accessible wrapper for a feature ID attribute from a glTF model.
int64 getAttributeIndex() const
Gets the index of this feature ID attribute in the glTF primitive.
FCesiumFeatureIdAttribute(const CesiumGltf::Model &Model, const CesiumGltf::MeshPrimitive &Primitive, const int64 FeatureIDAttribute, const FString &PropertyTableName)
Constructs a feature ID attribute instance.
FCesiumFeatureIdAttribute(const CesiumGltf::Model &Model, const CesiumGltf::Node &Node, const int64 FeatureIDAttribute, const FString &PropertyTableName)
Constructs a feature ID attribute instance from EXT_instance_features data.
FCesiumFeatureIdAttribute()
Constructs an empty feature ID attribute instance.