Skip to content

Fixed building issues, added AnimToTexture Plugin. Works in 5.0 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "1.0",
"components": [
"Microsoft.Net.Component.4.6.2.TargetingPack",
"Microsoft.VisualStudio.Component.VC.14.34.17.4.x86.x64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.Windows10SDK",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.VisualStudio.Workload.NativeDesktop",
"Microsoft.VisualStudio.Workload.NativeGame"
]
}
Binary file modified Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
Binary file not shown.
Binary file modified Content/StarterContent/Materials/M_Basic_Wall.uasset
Binary file not shown.
Binary file modified Content/StarterContent/Shapes/Shape_Cone.uasset
Binary file not shown.
4 changes: 4 additions & 0 deletions MassAITesting.uproject
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
{
"Name": "MassGameplay",
"Enabled": true
},
{
"Name": "TDxUnrealEditor",
"Enabled": true
}
]
}
74 changes: 74 additions & 0 deletions Plugins/AnimToTexture/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Visual Studio 2015 user specific files
.vs/

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
*.ipa

# These project files can be generated by the engine
*.xcodeproj
*.xcworkspace
*.sln
*.suo
*.opensdf
*.sdf
*.VC.db
*.VC.opendb

# Precompiled Assets
SourceArt/**/*.png
SourceArt/**/*.tga

# Binary Files
Binaries/*
Plugins/*/Binaries/*

# Builds
Build/*

# Whitelist PakBlacklist-<BuildConfiguration>.txt files
!Build/*/
Build/*/**
!Build/*/PakBlacklist*.txt

# Don't ignore icon files in Build
!Build/**/*.ico

# Built data for maps
*_BuiltData.uasset

# Configuration files generated by the Editor
Saved/*

# Compiled source files for the engine to use
Intermediate/*
Plugins/*/Intermediate/*

# Cache files for the editor to use
DerivedDataCache/*
29 changes: 29 additions & 0 deletions Plugins/AnimToTexture/AnimToTexture.uplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "AnimToTexture",
"Description": "Converts SkeletalMesh Animations into Textures",
"Category": "Other",
"CreatedBy": "Epic Games",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": true,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [
{
"Name": "AnimToTexture",
"Type": "Runtime",
"LoadingPhase": "PreDefault"
},
{
"Name": "AnimToTextureEditor",
"Type": "Editor",
"LoadingPhase": "PreLoadingScreen"
}
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions Plugins/AnimToTexture/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UE-Only Content - Licensed for Use Only with Unreal Engine-based Products

https://www.unrealengine.com/marketplace/en-US/product/city-sample
2 changes: 2 additions & 0 deletions Plugins/AnimToTexture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# AnimToTexture
Unreal Engine 5 plugin from Epic's [City Sample project](https://www.unrealengine.com/marketplace/en-US/product/city-sample) to convert animations to textures.
54 changes: 54 additions & 0 deletions Plugins/AnimToTexture/Source/AnimToTexture/AnimToTexture.Build.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class AnimToTexture : ModuleRules
{
public AnimToTexture(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);


PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
}
);


PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);


PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
// ... add private dependencies that you statically link with here ...
"MeshDescription",
}
);


DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright Epic Games, Inc. All Rights Reserved.

#include "AnimToTexture.h"

#define LOCTEXT_NAMESPACE "FAnimToTextureModule"

void FAnimToTextureModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module

}

void FAnimToTextureModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.

}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FAnimToTextureModule, AnimToTexture)
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright Epic Games, Inc. All Rights Reserved.

#include "AnimToTextureDataAsset.h"

int32 UAnimToTextureDataAsset::GetIndexFromAnimSequence(const UAnimSequence* Sequence)
{
int32 OutIndex = 0;

int32 NumSequences = AnimSequences.Num();

// We can store a sequence to index map for a faster search
for (int32 CurrentIndex = 0; CurrentIndex < NumSequences; ++CurrentIndex)
{
const FAnimSequenceInfo& SequenceInfo = AnimSequences[CurrentIndex];
if (SequenceInfo.AnimSequence == Sequence)
{
OutIndex = CurrentIndex;
break;
}
}

return OutIndex;
}

namespace AnimToTextureParamNames
{
static const FName BoundingBoxMin = TEXT("MinBBox");
static const FName BoundingBoxScale = TEXT("SizeBBox");
static const FName RowsPerFrame = TEXT("RowsPerFrame");
static const FName BoneWeightRowsPerFrame = TEXT("BoneWeightsRowsPerFrame");
static const FName NumFrames = TEXT("NumFrames (S)");
//static const FName UVChannel = TEXT("UVChannel");
//static const FName AnimateSwitch = TEXT("Animate (B)");
static const FName VertexPositionTexture = TEXT("PositionTexture");
static const FName VertexNormalTexture = TEXT("NormalTexture");
static const FName BonePositionTexture = TEXT("BonePositionTexture");
static const FName BoneRotationTexture = TEXT("BoneRotationTexture");
static const FName BoneWeightsTexture = TEXT("BoneWeightsTexture");
}

FAnimToTextureMaterialParamNames::FAnimToTextureMaterialParamNames()
{
BoundingBoxMin = AnimToTextureParamNames::BoundingBoxMin;
BoundingBoxScale = AnimToTextureParamNames::BoundingBoxScale;
RowsPerFrame = AnimToTextureParamNames::RowsPerFrame;
BoneWeightRowsPerFrame = AnimToTextureParamNames::BoneWeightRowsPerFrame;
NumFrames = AnimToTextureParamNames::NumFrames;
//UVChannel = AnimToTextureParamNames::UVChannel;
//AnimateSwitch = AnimToTextureParamNames::AnimateSwitch;
VertexPositionTexture = AnimToTextureParamNames::VertexPositionTexture;
VertexNormalTexture = AnimToTextureParamNames::VertexNormalTexture;
BonePositionTexture = AnimToTextureParamNames::BonePositionTexture;
BoneRotationTexture = AnimToTextureParamNames::BoneRotationTexture;
BoneWeightsTexture = AnimToTextureParamNames::BoneWeightsTexture;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright Epic Games, Inc. All Rights Reserved.

#include "AnimToTextureInstancePlaybackHelpers.h"
#include "AnimToTextureDataAsset.h"

void UAnimToTextureInstancePlaybackLibrary::SetupInstancedMeshComponent(UInstancedStaticMeshComponent* InstancedMeshComponent, FAnimToTextureInstanceData& InstanceData, int32 NumInstances)
{
if (InstancedMeshComponent)
{
InstancedMeshComponent->NumCustomDataFloats = InstanceData.PlaybackData.GetTypeSize() / sizeof(float);
InstancedMeshComponent->PerInstanceSMData.Reset();
InstancedMeshComponent->PerInstanceSMData.AddDefaulted(NumInstances);
InstancedMeshComponent->PreAllocateInstancesMemory(NumInstances);
InstancedMeshComponent->PerInstanceSMCustomData.SetNumZeroed(NumInstances * InstancedMeshComponent->NumCustomDataFloats);
AllocateInstanceData(InstanceData, NumInstances);
}
}

void UAnimToTextureInstancePlaybackLibrary::BatchUpdateInstancedMeshComponent(UInstancedStaticMeshComponent* InstancedMeshComponent, FAnimToTextureInstanceData& InstanceData)
{
SIZE_T CustomDataSizeToCopy = FMath::Min(InstanceData.PlaybackData.Num() * InstanceData.PlaybackData.GetTypeSize(), InstancedMeshComponent->PerInstanceSMCustomData.Num() * InstancedMeshComponent->PerInstanceSMCustomData.GetTypeSize());
FMemory::Memcpy(InstancedMeshComponent->PerInstanceSMCustomData.GetData(), InstanceData.PlaybackData.GetData(), CustomDataSizeToCopy);

int32 TransformsToCopy = FMath::Min(InstancedMeshComponent->GetNumRenderInstances(), InstanceData.StaticMeshInstanceData.Num());
InstancedMeshComponent->BatchUpdateInstancesData(0, TransformsToCopy, InstanceData.StaticMeshInstanceData.GetData(), true, false);
}

void UAnimToTextureInstancePlaybackLibrary::AllocateInstanceData(FAnimToTextureInstanceData& InstanceData, int32 Count)
{
InstanceData.StaticMeshInstanceData.AddDefaulted(Count);
InstanceData.PlaybackData.AddDefaulted(Count);
}

bool UAnimToTextureInstancePlaybackLibrary::UpdateInstanceData(FAnimToTextureInstanceData& InstanceData, int32 InstanceIndex, const FAnimToTextureInstancePlaybackData& PlaybackData, const FTransform& Transform)
{
if (InstanceData.PlaybackData.IsValidIndex(InstanceIndex) && InstanceData.StaticMeshInstanceData.IsValidIndex(InstanceIndex))
{
InstanceData.PlaybackData[InstanceIndex] = PlaybackData;
InstanceData.StaticMeshInstanceData[InstanceIndex].Transform = Transform.ToMatrixWithScale();
return true;
}

return false;
}

bool UAnimToTextureInstancePlaybackLibrary::GetInstancePlaybackData(const FAnimToTextureInstanceData& InstanceData, int32 InstanceIndex, FAnimToTextureInstancePlaybackData& InstancePlaybackData)
{
if (InstanceData.PlaybackData.IsValidIndex(InstanceIndex))
{
InstancePlaybackData = InstanceData.PlaybackData[InstanceIndex];
return true;
}

return false;
}

bool UAnimToTextureInstancePlaybackLibrary::GetInstanceTransform(const FAnimToTextureInstanceData& InstanceData, int32 InstanceIndex, FTransform& InstanceTransform)
{
if (InstanceData.StaticMeshInstanceData.IsValidIndex(InstanceIndex))
{
InstanceTransform = FTransform(InstanceData.StaticMeshInstanceData[InstanceIndex].Transform);
return true;
}

return false;
}

bool UAnimToTextureInstancePlaybackLibrary::AnimStateFromDataAsset(const UAnimToTextureDataAsset* DataAsset, int32 StateIndex, FAnimToTextureAnimState& AnimState)
{
if (DataAsset && DataAsset->Animations.IsValidIndex(StateIndex))
{
const FAnimInfo& AnimInfo = DataAsset->Animations[StateIndex];
AnimState.StartFrame = AnimInfo.AnimStart;
AnimState.NumFrames = AnimInfo.NumFrames;
AnimState.bLooping = AnimInfo.bLooping;

return true;
}

AnimState = FAnimToTextureAnimState();
return false;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright Epic Games, Inc. All Rights Reserved.

#include "EvaluateSequenceAnimInstance.h"


UEvaluateSequenceAnimInstance::UEvaluateSequenceAnimInstance(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{

}
Loading