153 lines
4.9 KiB
C++
153 lines
4.9 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Components/ActorComponent.h"
|
|
#include "SplatterMapSystem.generated.h"
|
|
|
|
/**
|
|
* Wound property channels for splatter maps
|
|
*/
|
|
UENUM(BlueprintType)
|
|
enum class ESplatterMapChannel : uint8
|
|
{
|
|
Depth UMETA(DisplayName = "Depth"),
|
|
Bloodiness UMETA(DisplayName = "Bloodiness"),
|
|
Bruising UMETA(DisplayName = "Bruising"),
|
|
Dilation UMETA(DisplayName = "Dilation Mask"),
|
|
DrippingBlood UMETA(DisplayName = "Dripping Blood"),
|
|
BurntAreas UMETA(DisplayName = "Burnt Areas"),
|
|
Water UMETA(DisplayName = "Water"),
|
|
Fuel UMETA(DisplayName = "Fuel")
|
|
};
|
|
|
|
/**
|
|
* Body region for splatter maps
|
|
*/
|
|
UENUM(BlueprintType)
|
|
enum class EBodyRegion : uint8
|
|
{
|
|
LowerBody UMETA(DisplayName = "Lower Body"),
|
|
UpperBody UMETA(DisplayName = "Upper Body"),
|
|
Head UMETA(DisplayName = "Head"),
|
|
Hair UMETA(DisplayName = "Hair"),
|
|
Clothing UMETA(DisplayName = "Clothing")
|
|
};
|
|
|
|
/**
|
|
* Splatter map data structure
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct FSplatterMapData
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
// Diffuse texture (1024x1024)
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH|Gore")
|
|
TObjectPtr<UTexture2D> DiffuseMap;
|
|
|
|
// Splatter texture (128x128)
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH|Gore")
|
|
TObjectPtr<UTexture2D> SplatterMap;
|
|
|
|
// Body region this splatter map applies to
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FLESH|Gore")
|
|
EBodyRegion BodyRegion;
|
|
|
|
// Constructor
|
|
FSplatterMapData()
|
|
: DiffuseMap(nullptr)
|
|
, SplatterMap(nullptr)
|
|
, BodyRegion(EBodyRegion::UpperBody)
|
|
{
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Splatter map system component for the FLESH plugin
|
|
* Handles wound visualization using splatter maps
|
|
*/
|
|
UCLASS(ClassGroup=(FLESH), meta=(BlueprintSpawnableComponent))
|
|
class FLESH_API USplatterMapSystem : public UActorComponent
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
// Sets default values for this component's properties
|
|
USplatterMapSystem();
|
|
|
|
protected:
|
|
// Called when the game starts
|
|
virtual void BeginPlay() override;
|
|
|
|
public:
|
|
// Called every frame
|
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
|
|
|
/**
|
|
* Apply wound effect to splatter map at world location
|
|
* @param Location - World location of the wound
|
|
* @param Normal - Surface normal at the wound location
|
|
* @param Size - Size of the wound
|
|
* @param Channels - Map of channels to values to apply
|
|
* @param BodyRegion - Body region to apply the wound to
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "FLESH|Gore")
|
|
void ApplyWoundToSplatterMap(const FVector& Location, const FVector& Normal, float Size,
|
|
const TMap<ESplatterMapChannel, float>& Channels, EBodyRegion BodyRegion = EBodyRegion::UpperBody);
|
|
|
|
/**
|
|
* Apply decal to splatter map
|
|
* @param DecalTexture - Decal texture to apply
|
|
* @param Location - World location of the decal
|
|
* @param Normal - Surface normal at the decal location
|
|
* @param Size - Size of the decal
|
|
* @param Rotation - Rotation of the decal
|
|
* @param BodyRegion - Body region to apply the decal to
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "FLESH|Gore")
|
|
void ApplyDecalToSplatterMap(UTexture2D* DecalTexture, const FVector& Location, const FVector& Normal,
|
|
float Size, float Rotation, EBodyRegion BodyRegion = EBodyRegion::UpperBody);
|
|
|
|
/**
|
|
* Get splatter map data for a specific body region
|
|
* @param BodyRegion - Body region to get splatter map data for
|
|
* @return Splatter map data for the specified body region
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "FLESH|Gore")
|
|
FSplatterMapData GetSplatterMapData(EBodyRegion BodyRegion) const;
|
|
|
|
/**
|
|
* Set splatter map data for a specific body region
|
|
* @param BodyRegion - Body region to set splatter map data for
|
|
* @param SplatterMapData - Splatter map data to set
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "FLESH|Gore")
|
|
void SetSplatterMapData(EBodyRegion BodyRegion, const FSplatterMapData& SplatterMapData);
|
|
|
|
/**
|
|
* Clear all splatter maps
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "FLESH|Gore")
|
|
void ClearSplatterMaps();
|
|
|
|
private:
|
|
// Splatter map data for each body region
|
|
UPROPERTY(EditAnywhere, Category = "FLESH|Gore", meta = (AllowPrivateAccess = "true"))
|
|
TMap<EBodyRegion, FSplatterMapData> SplatterMaps;
|
|
|
|
// Decal textures for different wound types
|
|
UPROPERTY(EditAnywhere, Category = "FLESH|Gore", meta = (AllowPrivateAccess = "true"))
|
|
TMap<FName, TObjectPtr<UTexture2D>> WoundDecals;
|
|
|
|
// Material for rendering to splatter maps
|
|
UPROPERTY(EditAnywhere, Category = "FLESH|Gore", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<UMaterialInterface> SplatterRenderMaterial;
|
|
|
|
// Convert world location to UV coordinates on the character
|
|
FVector2D WorldLocationToUV(const FVector& Location, const FVector& Normal, EBodyRegion BodyRegion) const;
|
|
|
|
// Render decal to splatter map
|
|
void RenderToSplatterMap(UTexture2D* TargetTexture, UTexture2D* DecalTexture, const FVector2D& UV,
|
|
float Size, float Rotation, const TMap<ESplatterMapChannel, float>& Channels);
|
|
};
|