Created
April 4, 2024 16:51
-
-
Save kirby561/c6aaff26a6d823bd97259f462edfb076 to your computer and use it in GitHub Desktop.
UBpPoseableMeshComponent C++ code for the Splined Road Youtube Video ( Also see https://www.youtube.com/watch?v=399k219oxi8 )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "BpPoseableMeshComponent.h" | |
UBpPoseableMeshComponent::UBpPoseableMeshComponent(const FObjectInitializer& objInitializer) : Super(objInitializer) { | |
} | |
void UBpPoseableMeshComponent::SetBoneLocalTransformByName(const FName& boneName, const FTransform& transform) { | |
if (!GetSkinnedAsset() || !RequiredBones.IsValid()) { | |
return; | |
} | |
int32 boneIndex = GetBoneIndex(boneName); | |
if (boneIndex >= 0 && boneIndex < BoneSpaceTransforms.Num()) { | |
BoneSpaceTransforms[boneIndex] = transform; | |
MarkRefreshTransformDirty(); | |
} | |
} | |
FTransform UBpPoseableMeshComponent::GetBoneLocalTransformByName(const FName& boneName) { | |
FTransform result; | |
if (!GetSkinnedAsset() || !RequiredBones.IsValid()) { | |
return result; | |
} | |
int32 boneIndex = GetBoneIndex(boneName); | |
if (boneIndex >= 0 && boneIndex < BoneSpaceTransforms.Num()) { | |
result = BoneSpaceTransforms[boneIndex]; | |
} | |
return result; | |
} | |
void UBpPoseableMeshComponent::UpdatePose() { | |
if (!GetSkinnedAsset() || GetNumComponentSpaceTransforms() == 0) { | |
return; | |
} | |
FillComponentSpaceTransforms(); | |
FinalizeBoneTransform(); | |
UpdateChildTransforms(); | |
UpdateBounds(); | |
MarkRenderTransformDirty(); | |
MarkRenderDynamicDataDirty(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "CoreMinimal.h" | |
#include "Components/PoseableMeshComponent.h" | |
#include "BpPoseableMeshComponent.generated.h" | |
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) | |
class UBpPoseableMeshComponent : public UPoseableMeshComponent { | |
GENERATED_BODY() | |
public: | |
UBpPoseableMeshComponent() : UPoseableMeshComponent() { } | |
UBpPoseableMeshComponent(const FObjectInitializer& objInitializer); | |
UFUNCTION(BlueprintCallable, Category="Components|PoseableMesh") | |
void SetBoneLocalTransformByName(const FName& boneName, const FTransform& transform); | |
UFUNCTION(BlueprintCallable, Category="Components|PoseableMesh") | |
FTransform GetBoneLocalTransformByName(const FName& boneName); | |
UFUNCTION(BlueprintCallable, Category="Components|PoseableMesh") | |
void UpdatePose(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment