14. Post-Process Highlight
And alot more...
This commit is contained in:
6
Project/Source/Gasa/Characters/EnemyCharacter.cpp
Normal file
6
Project/Source/Gasa/Characters/EnemyCharacter.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "EnemyCharacter.h"
|
||||
|
||||
AEnemyCharacter::AEnemyCharacter()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
}
|
13
Project/Source/Gasa/Characters/EnemyCharacter.h
Normal file
13
Project/Source/Gasa/Characters/EnemyCharacter.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "GasaCharacter.h"
|
||||
|
||||
#include "EnemyCharacter.generated.h"
|
||||
|
||||
UCLASS(Blueprintable)
|
||||
class GASA_API AEnemyCharacter : public AGasaCharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
AEnemyCharacter();
|
||||
};
|
87
Project/Source/Gasa/Characters/GasaCharacter.cpp
Normal file
87
Project/Source/Gasa/Characters/GasaCharacter.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
#include "GasaCharacter.h"
|
||||
|
||||
#include "GasaLevelScriptActor.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
|
||||
void AGasaCharacter::SetHighlight(EHighlight Desired)
|
||||
{
|
||||
HighlightState = Desired;
|
||||
}
|
||||
|
||||
AGasaCharacter::AGasaCharacter()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = false;
|
||||
|
||||
HighlightColor = FLinearColor(0.8, 0.32, 0.05f, 1.f);
|
||||
|
||||
UCharacterMovementComponent*
|
||||
Movement = GetCharacterMovement();
|
||||
Movement->bOrientRotationToMovement = true;
|
||||
Movement->bConstrainToPlane = true;
|
||||
Movement->bSnapToPlaneAtStart = true;
|
||||
Movement->RotationRate = FRotator(0.0, 400.f, 0.0);
|
||||
|
||||
bUseControllerRotationPitch = false;
|
||||
bUseControllerRotationRoll = false;
|
||||
bUseControllerRotationYaw = false;
|
||||
|
||||
USceneComponent* root_component = GetRootComponent();
|
||||
USkeletalMeshComponent* mesh = GetMesh();
|
||||
|
||||
Weapon = CreateDefaultSubobject<USkeletalMeshComponent>("Weapon");
|
||||
Weapon->SetupAttachment(mesh, FName("WeaponAttach"));
|
||||
Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
}
|
||||
|
||||
void AGasaCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
void AGasaCharacter::Tick(float DeltaSeconds)
|
||||
{
|
||||
Super::Tick(DeltaSeconds);
|
||||
|
||||
USkeletalMeshComponent* mesh = GetMesh();
|
||||
switch (HighlightState)
|
||||
{
|
||||
case EHighlight::Disabled:
|
||||
{
|
||||
mesh->SetRenderCustomDepth(false);
|
||||
mesh->SetCustomDepthStencilValue(0.f);
|
||||
Weapon->SetRenderCustomDepth(false);
|
||||
Weapon->SetCustomDepthStencilValue(0.f);
|
||||
}
|
||||
break;
|
||||
case EHighlight::Enabled:
|
||||
{
|
||||
mesh->SetRenderCustomDepth(true);
|
||||
mesh->SetCustomDepthStencilValue(HighlightStencilDepth);
|
||||
Weapon->SetRenderCustomDepth(true);
|
||||
Weapon->SetCustomDepthStencilValue(HighlightStencilDepth);
|
||||
|
||||
APostProcessVolume* PPV = Gasa::GetLevelActor(this)->GlobalPPV;
|
||||
TObjectPtr<UObject> Blendable = PPV->Settings.WeightedBlendables.Array[0].Object;
|
||||
UMaterialInstanceDynamic*
|
||||
MID = Cast<UMaterialInstanceDynamic>(Blendable);
|
||||
MID->SetVectorParameterValue("Depth Highlight Color", HighlightColor);
|
||||
#if 0
|
||||
UCapsuleComponent* Capsule = GetCapsuleComponent();
|
||||
UKismetSystemLibrary::DrawDebugCapsule(this
|
||||
, Capsule->GetComponentLocation()
|
||||
, Capsule->GetScaledCapsuleHalfHeight()^
|
||||
, Capsule->GetScaledCapsuleRadius()
|
||||
, Capsule->GetComponentRotation()
|
||||
, HighlightColor
|
||||
, 0.f
|
||||
, 1.f
|
||||
);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
51
Project/Source/Gasa/Characters/GasaCharacter.h
Normal file
51
Project/Source/Gasa/Characters/GasaCharacter.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include "GasaCommon.h"
|
||||
#include "GameFramework/Character.h"
|
||||
|
||||
#include "GasaCharacter.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EHighlight : uint8
|
||||
{
|
||||
Disabled,
|
||||
Enabled,
|
||||
};
|
||||
|
||||
UCLASS(Abstract)
|
||||
class GASA_API AGasaCharacter : public ACharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
#pragma region Combat
|
||||
UPROPERTY(EditAnywhere, Category="Combat")
|
||||
TObjectPtr<USkeletalMeshComponent> Weapon;
|
||||
#pragma endregion Combat
|
||||
|
||||
#pragma region Highlighting
|
||||
static constexpr float HighlightStencilDepth = 256.0;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Highlighting")
|
||||
EHighlight HighlightState;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Highlighting")
|
||||
FLinearColor HighlightColor;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Highlighting")
|
||||
void SetHighlight( EHighlight Desired );
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Highlighting")
|
||||
FORCEINLINE void Highlight() { SetHighlight(EHighlight::Enabled); };
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Highlighting")
|
||||
FORCEINLINE void Dehighlight() { SetHighlight(EHighlight::Disabled); };
|
||||
#pragma endregion Highlighting
|
||||
|
||||
AGasaCharacter();
|
||||
|
||||
#pragma region Actor
|
||||
void BeginPlay() override;
|
||||
|
||||
void Tick(float DeltaSeconds) override;
|
||||
#pragma endregion Actor
|
||||
};
|
6
Project/Source/Gasa/Characters/PlayerCharacter.cpp
Normal file
6
Project/Source/Gasa/Characters/PlayerCharacter.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "PlayerCharacter.h"
|
||||
|
||||
APlayerCharacter::APlayerCharacter()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
}
|
14
Project/Source/Gasa/Characters/PlayerCharacter.h
Normal file
14
Project/Source/Gasa/Characters/PlayerCharacter.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "GasaCharacter.h"
|
||||
|
||||
#include "PlayerCharacter.generated.h"
|
||||
|
||||
UCLASS(Blueprintable)
|
||||
class GASA_API APlayerCharacter : public AGasaCharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
APlayerCharacter();
|
||||
};
|
Reference in New Issue
Block a user