Advertisement
malice936

ESMDataMapper.h

Apr 17th, 2025
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.60 KB | Gaming | 0 0
  1. // Warning! Experimental! No guarantees on functionality! Use at your own risk!!!!!
  2. #pragma once
  3.  
  4. #include "CoreMinimal.h"
  5. #include "Kismet/BlueprintFunctionLibrary.h"
  6. #include "Landscape.h"
  7. #include "Plugin.h"
  8. #include "ESMDataMapper.generated.h"
  9.  
  10. UCLASS()
  11. class UESMDataMapper : public UBlueprintFunctionLibrary
  12. {
  13.     GENERATED_BODY()
  14. public:
  15.     /** Extracts height data from a single LAND record. Returns false if the record is not a LAND record or lacks VHGT data. */
  16.     UFUNCTION(BlueprintCallable, Category = "ESM Mapping")
  17.     static bool ExtractHeightDataFromRecord(const FRecord& Record, int32 CellX, int32 CellY, TArray<float>& OutHeightData, float& OutHeightOffset);
  18.  
  19.     /** Extracts height data from an array of records for a specific cell (X, Y). Returns false if no matching LAND record is found. */
  20.     UFUNCTION(BlueprintCallable, Category = "ESM Mapping")
  21.     static bool ExtractHeightDataFromRecords(const TArray<FRecord>& Records, int32 CellX, int32 CellY, TArray<float>& OutHeights, float& OutHeightOffset);
  22.  
  23.     /** Extracts height data from LAND records in the plugin for a specific cell (X, Y). Returns false if no matching LAND record is found. */
  24.     UFUNCTION(BlueprintCallable, Category = "ESM Mapping")
  25.     static bool ExtractLandHeightDataFromPlugin(const FPlugin& Plugin, int32 CellX, int32 CellY, TArray<float>& OutHeights, float& OutHeightOffset);
  26.  
  27.     /** Handles individual LAND record processing, extracting CellX, CellY, and height data. */
  28.     UFUNCTION(BlueprintCallable, Category = "ESM Mapping")
  29.     static bool LANDHandler(const FRecord& Record, int32& CellX, int32& CellY, TArray<float>& OutHeightData, float& OutHeightOffset);
  30.  
  31.     /** Converts raw height data to a heightmap represented as bytes (legacy method). */
  32.     UFUNCTION(BlueprintCallable, Category = "ESM Mapping")
  33.     static TArray<uint8> ConvertESMHeightToHeightmapBytes(const TArray<float>& Heights, float MinHeight, float MaxHeight);
  34.  
  35.     /** Creates a landscape actor from a heightmap stored as bytes (legacy method). */
  36.     UFUNCTION(BlueprintCallable, Category = "ESM Mapping")
  37.     static ALandscape* CreateLandscapeFromHeightmapBytes(UWorld* World, const TArray<uint8>& HeightmapBytes, int32 Width, int32 Height, float ScaleX, float ScaleY, float ScaleZ);
  38.  
  39.     /** Creates a landscape actor using a modern Unreal Engine 5 approach with raw height data. */
  40.     UFUNCTION(BlueprintCallable, Category = "ESM Mapping")
  41.     static ALandscape* CreateLandscapeModern(UWorld* World, const TArray<float>& Heights, int32 CellX, int32 CellY, int32 Width, int32 Height, float ScaleX, float ScaleY, float ScaleZ);
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement