Cesium for Unreal 2.21.0
Loading...
Searching...
No Matches
Cesium3DTilesetLifecycleEventReceiver.h
Go to the documentation of this file.
1// Copyright 2020-2025 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "Cesium3DTilesSelection/TileID.h"
6#include "CesiumLoadedTile.h"
7#include "UObject/ObjectMacros.h"
8
9#include "Cesium3DTilesetLifecycleEventReceiver.generated.h"
10
11class UMaterialInstanceDynamic;
12class UMaterialInterface;
13enum EMaterialParameterAssociation : int;
14
18namespace CesiumGltf {
19struct Material;
21} // namespace CesiumGltf
22
23// Note: to allow implementation in Blueprints:
24// 1. remove this 'meta' flag, and make the interface methods below
25// compatible with a Blueprint implementation,
26// 2. remove the Cast<ICesium3DTilesetLifecycleEventReceiver> in
27// ACesium3DTileset::GetLifecycleEventReceiver, as it would return nullptr for a
28// BP implementation, and return the UObject pointer instead,
29// 3. use ICesium3DTilesetLifecycleEventReceiver::Execute_DoStuff wrappers
30// instead of DoStuff methods everywhere the event receiver is used in the
31// plugin's C++ code.
32UINTERFACE(meta = (CannotImplementInterfaceInBlueprint))
33class UCesium3DTilesetLifecycleEventReceiver : public UInterface {
34 GENERATED_BODY()
35};
36
37/**
38 * An interface that receives events about the lifecycle of tiles in a @ref
39 * Cesium3DTileset. Implement this interface and provide your implementation to
40 * the tileset by calling @ref SetLifecycleEventReceiver to receive callbacks
41 * when tiles are loaded, unloaded, hidden, or shown. This interface can also
42 * customize the Unreal material that is used to render each primitive in each
43 * tile.
44 *
45 * All methods are called from the game thread.*/
47 GENERATED_BODY()
48public:
49 /**
50 * Creates a material instance for a given tile primitive. The default
51 * implementation simply calls `UMaterialInstanceDynamic::Create` with the
52 * default base material. Overriding this method is useful when a different
53 * base material should be selected based on properties of the primitive.
54 *
55 * @param TilePrimitive Loaded tile primitive for which a material is needed.
56 * @param DefaultBaseMaterial Default chosen base material. May be ignored if
57 * the method chooses to create the mesh material based on a custom base
58 * material.
59 * @param Name The name for the new material, as used by creation functions
60 * like NewObject.
61 * @return Material instance created. Should not be `nullptr`.
62 */
63 virtual UMaterialInstanceDynamic* CreateMaterial(
64 ICesiumLoadedTilePrimitive& TilePrimitive,
65 UMaterialInterface* DefaultBaseMaterial,
66 const FName& Name);
67
68 /**
69 * Allows customization of the Unreal material instance used to render a
70 * tile's primitive. This is especially useful for modifying the material
71 * based on application-specific extensions to the glTF material definition.
72 *
73 * This method is called on the Material created by @ref CreateMaterial after
74 * all of the standard parameters have been set on it.
75 *
76 * @param TilePrimitive Loaded tile primitive to which the material applies.
77 * @param Material The Unreal material created for the primitive.
78 * @param CesiumData The list of the material's layer names. This can be used
79 * to map Unreal material layers to specific behavior.
80 * @param GltfMaterial The glTF material definition.
81 */
82 virtual void CustomizeMaterial(
83 ICesiumLoadedTilePrimitive& TilePrimitive,
84 UMaterialInstanceDynamic& Material,
85 const UCesiumMaterialUserData* CesiumData,
86 const CesiumGltf::Material& GltfMaterial);
87
88 /**
89 * Called after a `MeshPrimitive` in a tile's glTF is loaded. This method is
90 * called at the end of the load process, after construction of the static
91 * mesh component that will render the primitive.
92 *
93 * @param TilePrimitive Tile primitive that has just been loaded.
94 */
95 virtual void
97
98 /**
99 * Called after a new tile has been loaded. This method is called after
100 * `OnTileMeshPrimitiveLoaded` has been called for all of the tile's
101 * primitives.
102 *
103 * @param Tile The tile that has just been loaded
104 */
105 virtual void OnTileLoaded(ICesiumLoadedTile& Tile);
106
107 /**
108 * Called when a tile is shown or hidden. This may be called zero or more
109 * times per tile.
110 *
111 * @param Tile The tile for which visibility is being toggled.
112 * @param bVisible New visibility flag being applied.
113 */
114 virtual void OnTileVisibilityChanged(ICesiumLoadedTile& Tile, bool bVisible);
115
116 /**
117 * Called before a tile is unloaded.
118 *
119 * @param Tile The tile that is about to be unloaded.
120 */
122};
An interface that receives events about the lifecycle of tiles in a Cesium3DTileset.
virtual void OnTileLoaded(ICesiumLoadedTile &Tile)
Called after a new tile has been loaded.
virtual void OnTileUnloading(ICesiumLoadedTile &Tile)
Called before a tile is unloaded.
virtual void OnTileVisibilityChanged(ICesiumLoadedTile &Tile, bool bVisible)
Called when a tile is shown or hidden.
virtual void CustomizeMaterial(ICesiumLoadedTilePrimitive &TilePrimitive, UMaterialInstanceDynamic &Material, const UCesiumMaterialUserData *CesiumData, const CesiumGltf::Material &GltfMaterial)
Allows customization of the Unreal material instance used to render a tile's primitive.
virtual UMaterialInstanceDynamic * CreateMaterial(ICesiumLoadedTilePrimitive &TilePrimitive, UMaterialInterface *DefaultBaseMaterial, const FName &Name)
Creates a material instance for a given tile primitive.
virtual void OnTileMeshPrimitiveLoaded(ICesiumLoadedTilePrimitive &TilePrimitive)
Called after a MeshPrimitive in a tile's glTF is loaded.
Provides access to the details of a glTF MeshPrimitive loaded by the Cesium3DTileset.
Provides access to the details of a tile loaded by the Cesium3DTileset.
Instances of this user data class are automatically attached to all materials that are used by Cesium...