Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
CesiumPrimitiveFeatures.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
6#include "Kismet/BlueprintFunctionLibrary.h"
7#include "UObject/ObjectMacros.h"
8#include <CesiumGltf/AccessorUtility.h>
9
10#include "CesiumPrimitiveFeatures.generated.h"
11
12namespace CesiumGltf {
13struct ExtensionExtMeshFeatures;
14struct ExtensionExtInstanceFeatures;
15} // namespace CesiumGltf
16
17/**
18 * A Blueprint-accessible wrapper for a glTF Primitive's mesh features. It holds
19 * views of the feature ID sets associated with this primitive. The collection
20 * of features in the EXT_instance_features is very similar to that in
21 * EXT_mesh_features, so FCesiumPrimitiveFeatures can be used to handle those
22 * features too.
23 */
24USTRUCT(BlueprintType)
25struct CESIUMRUNTIME_API FCesiumPrimitiveFeatures {
26 GENERATED_USTRUCT_BODY()
27
28public:
29 /**
30 * Constructs an empty primitive features instance.
31 */
32 FCesiumPrimitiveFeatures() : _vertexCount(0) {}
33
34 /**
35 * Constructs a primitive features instance.
36 *
37 * @param Model The model that contains the EXT_mesh_features extension
38 * @param Primitive The mesh primitive that stores EXT_mesh_features
39 * extension
40 * @param Features The EXT_mesh_features of the glTF mesh primitive
41 */
43 const CesiumGltf::Model& Model,
44 const CesiumGltf::MeshPrimitive& Primitive,
46
47 /**
48 * Constructs an instance feature object.
49 *
50 * @param Model The model that contains the EXT_instance_features extension
51 * @param Node The node that stores EXT_instance_features
52 * extension
53 * @param InstanceFeatures The EXT_Instance_features of the glTF mesh
54 * primitive
55 */
57 const CesiumGltf::Model& Model,
58 const CesiumGltf::Node& Node,
59 const CesiumGltf::ExtensionExtInstanceFeatures& InstanceFeatures);
60
61private:
62 TArray<FCesiumFeatureIdSet> _featureIdSets;
63 CesiumGltf::IndexAccessorType _indexAccessor;
64 // Vertex count = 0 and _primitiveMode = -1 indicates instance features
65 int64_t _vertexCount;
66 int32_t _primitiveMode;
67
69};
70
71UCLASS()
73 : public UBlueprintFunctionLibrary {
74 GENERATED_BODY()
75
76public:
77 /**
78 * Gets the primitive features of a glTF primitive component. If `component`
79 * is not a Cesium glTF primitive component, the returned features are empty.
80 *
81 * @param component The component to get the features of.
82 */
83 UFUNCTION(
84 BlueprintCallable,
85 BlueprintPure,
86 Category = "Cesium|Primitive|Features")
87 static const FCesiumPrimitiveFeatures&
88 GetPrimitiveFeatures(const UPrimitiveComponent* component);
89
90 /**
91 * Gets all the feature ID sets that are associated with the
92 * primitive.
93 *
94 * @param PrimitiveFeatures The primitive.
95 */
96 UFUNCTION(
97 BlueprintCallable,
98 BlueprintPure,
99 Category = "Cesium|Primitive|Features")
100 static const TArray<FCesiumFeatureIdSet>&
102 const FCesiumPrimitiveFeatures& PrimitiveFeatures);
103
104 /**
105 * Gets all the feature ID sets of the given type.
106 *
107 * @param PrimitiveFeatures The primitive.
108 * @param Type The type of feature ID set to obtain. If the primitive has no
109 * sets of that type, the returned array will be empty.
110 */
111 UFUNCTION(
112 BlueprintCallable,
113 BlueprintPure,
114 Category = "Cesium|Primitive|Features")
116 UPARAM(ref) const FCesiumPrimitiveFeatures& PrimitiveFeatures,
118
119 /**
120 * Get the number of vertices in the primitive.
121 *
122 * @param PrimitiveFeatures The primitive.
123 */
124 UFUNCTION(
125 BlueprintCallable,
126 BlueprintPure,
127 Category = "Cesium|Primitive|Features")
128 static int64
129 GetVertexCount(UPARAM(ref) const FCesiumPrimitiveFeatures& PrimitiveFeatures);
130
131 /**
132 * Gets the index of the first vertex that makes up a given face of this
133 * primitive.
134 *
135 * @param PrimitiveFeatures The primitive.
136 * @param FaceIndex The index of the face.
137 */
138 UFUNCTION(
139 BlueprintCallable,
140 BlueprintPure,
141 Category = "Cesium|Primitive|Features")
143 UPARAM(ref) const FCesiumPrimitiveFeatures& PrimitiveFeatures,
144 int64 FaceIndex);
145
146 /**
147 * Gets the feature ID associated with the given face.
148 *
149 * @param PrimitiveFeatures The primitive.
150 * @param FaceIndex The index of the face to obtain the feature ID of.
151 * @param FeatureIDSetIndex A primitive may have multiple feature ID sets, so
152 * this allows a feature ID set to be specified by index. This value should
153 * index into the array of CesiumFeatureIdSets in the CesiumPrimitiveFeatures.
154 * If the specified feature ID set index is invalid, this returns -1.
155 */
156 UFUNCTION(
157 BlueprintCallable,
158 BlueprintPure,
159 Category = "Cesium|Primitive|Features")
161 UPARAM(ref) const FCesiumPrimitiveFeatures& PrimitiveFeatures,
162 int64 FaceIndex,
163 int64 FeatureIDSetIndex = 0);
164
165 /**
166 * Gets the feature ID associated with the instance at the given index.
167 */
168 UFUNCTION(
169 BlueprintCallable,
170 BlueprintPure,
171 Category = "Cesium|Primitive|Features")
173 UPARAM(ref) const FCesiumPrimitiveFeatures& InstanceFeatures,
174 int64 InstanceIndex,
175 int64 FeatureIDSetIndex = 0);
176
177 /**
178 * Gets the feature ID from the given line trace hit, assuming it
179 * has hit a glTF primitive component containing this CesiumPrimitiveFeatures.
180 *
181 * @param PrimitiveFeatures The primitive.
182 * @param Hit The line trace hit to try to obtain a feature ID from.
183 * @param FeatureIDSetIndex A primitive may have multiple feature ID sets, so
184 * this allows a feature ID set to be specified by index. This value should
185 * index into the array of CesiumFeatureIdSets in the CesiumPrimitiveFeatures.
186 * If the specified feature ID set index is invalid, this returns -1.
187 */
188 UFUNCTION(
189 BlueprintCallable,
190 BlueprintPure,
191 Category = "Cesium|Primitive|Features")
193 UPARAM(ref) const FCesiumPrimitiveFeatures& PrimitiveFeatures,
194 const FHitResult& Hit,
195 int64 FeatureIDSetIndex = 0);
196};
ECesiumFeatureIdSetType
The type of a feature ID set.
static int64 GetFeatureIDFromFace(UPARAM(ref) const FCesiumPrimitiveFeatures &PrimitiveFeatures, int64 FaceIndex, int64 FeatureIDSetIndex=0)
Gets the feature ID associated with the given face.
static const FCesiumPrimitiveFeatures & GetPrimitiveFeatures(const UPrimitiveComponent *component)
Gets the primitive features of a glTF primitive component.
static int64 GetVertexCount(UPARAM(ref) const FCesiumPrimitiveFeatures &PrimitiveFeatures)
Get the number of vertices in the primitive.
static const TArray< FCesiumFeatureIdSet > & GetFeatureIDSets(UPARAM(ref) const FCesiumPrimitiveFeatures &PrimitiveFeatures)
Gets all the feature ID sets that are associated with the primitive.
static int64 GetFeatureIDFromInstance(UPARAM(ref) const FCesiumPrimitiveFeatures &InstanceFeatures, int64 InstanceIndex, int64 FeatureIDSetIndex=0)
Gets the feature ID associated with the instance at the given index.
static const TArray< FCesiumFeatureIdSet > GetFeatureIDSetsOfType(UPARAM(ref) const FCesiumPrimitiveFeatures &PrimitiveFeatures, ECesiumFeatureIdSetType Type)
Gets all the feature ID sets of the given type.
static int64 GetFirstVertexFromFace(UPARAM(ref) const FCesiumPrimitiveFeatures &PrimitiveFeatures, int64 FaceIndex)
Gets the index of the first vertex that makes up a given face of this primitive.
static int64 GetFeatureIDFromHit(UPARAM(ref) const FCesiumPrimitiveFeatures &PrimitiveFeatures, const FHitResult &Hit, int64 FeatureIDSetIndex=0)
Gets the feature ID from the given line trace hit, assuming it has hit a glTF primitive component con...
std::variant< std::monostate, AccessorView< uint8_t >, AccessorView< uint16_t >, AccessorView< uint32_t > > IndexAccessorType
A blueprint-accessible wrapper for a feature ID set from a glTF primitive.
A Blueprint-accessible wrapper for a glTF Primitive's mesh features.
FCesiumPrimitiveFeatures(const CesiumGltf::Model &Model, const CesiumGltf::MeshPrimitive &Primitive, const CesiumGltf::ExtensionExtMeshFeatures &Features)
Constructs a primitive features instance.
FCesiumPrimitiveFeatures()
Constructs an empty primitive features instance.
FCesiumPrimitiveFeatures(const CesiumGltf::Model &Model, const CesiumGltf::Node &Node, const CesiumGltf::ExtensionExtInstanceFeatures &InstanceFeatures)
Constructs an instance feature object.