0
\$\begingroup\$

I am trying to display a rendered wound on the character, but I still can't figure out how to display it properly without sliding on character's body.

I'm following this link on rendering the wounds on characters but I still can't figure out why it isn't working.

This is what I have so far on rendering the wound based on hit location enter image description here

What have I done wrong? Any ideas is appreciated. Thanks!

p.s This is how I draw the wound based on hit location. enter image description here

UPDATE: So I replace WorldPosition into Preskinned Position based on the comment suggested and the sphere mask won't render at all. I thought my HitLocation must be the problem, so I get back to the linked post to understands better on how to approach this, and included some C++ as well, but all those still resulting in the same results. The sphere mask keep on sliding on the body.

The pre skinned node I added

The updated blueprint

This is the code I have been using for both callable functions above

//Recursive function to have results relative to world origin
FTransform UGestureMathLibrary::GetWorldSpaceTransform(FReferenceSkeleton RefSkel, int32 BoneIdx)
{
	FTransform BoneTransform;

	if (BoneIdx > 0)
	{
		BoneTransform = RefSkel.GetRefBonePose()[BoneIdx];

		FMeshBoneInfo BoneInfo = RefSkel.GetRefBoneInfo()[BoneIdx];
		if (BoneInfo.ParentIndex != 0)
		{
			BoneTransform *= GetWorldSpaceTransform(RefSkel, BoneInfo.ParentIndex);
			UE_LOG(LogTemp, Warning, TEXT("if parent index is not equal to zero"));
		}
	}

	return BoneTransform;
}

//Reference pose bone transform
FTransform UGestureMathLibrary::GetRefPoseBoneTransform(USkeletalMeshComponent* SkelMesh, FName BoneName)
{
	FTransform BoneTransform;

	if (SkelMesh && !BoneName.IsNone())
	{
		SkelMesh->ClearRefPoseOverride();
		FReferenceSkeleton RefSkel;
		RefSkel = SkelMesh->SkeletalMesh->RefSkeleton;
		BoneTransform = GetWorldSpaceTransform(RefSkel, RefSkel.FindBoneIndex(BoneName));
		//BoneTransform = RefSkel.GetRefBonePose()[RefSkel.FindBoneIndex(BoneName)];
	}

	return BoneTransform;
}

//Bone transform
FTransform UGestureMathLibrary::GetBoneTransform(USkeletalMeshComponent* SkelMesh, FName BoneName)
{
	FTransform BoneTransform;

	if (SkelMesh && !BoneName.IsNone())
	{
		FReferenceSkeleton RefSkel;
		RefSkel = SkelMesh->SkeletalMesh->RefSkeleton;
		BoneTransform = SkelMesh->GetBoneTransform(RefSkel.FindBoneIndex(BoneName));
	}

	return BoneTransform;
}

Am I missing something?? Thanks again!

\$\endgroup\$
3
  • \$\begingroup\$ You will want to bake it inside texture in the material of the character based on UV \$\endgroup\$ Apr 7, 2020 at 14:38
  • \$\begingroup\$ Can you show us how you're drawing the wound based on the hit location? You're remembering to compare the distance between the wound sphere and the pre-animated position of the point you're sampling, right? \$\endgroup\$
    – DMGregory
    Apr 7, 2020 at 16:03
  • 1
    \$\begingroup\$ There's your problem. You do not want to use world position here, but pre-skinned local position. ie, where is this point in the character's bind pose / T-Pose local space, not its animated position in the world. This is explained in the article you linked. \$\endgroup\$
    – DMGregory
    Apr 9, 2020 at 17:10

1 Answer 1

2
\$\begingroup\$

I know this is a super old question, but I'm researching this exact topic and I think I can point out a mistake above. The preskinned location node needs to be used in the material used for unwrapping the mesh. That allows for baking the preskinned location, instead of the absolute world location, into that render target. The unwrapped texture from that target can then be made into a static texture. Then you can use the method, those c++ functions, for for converting the transform/location into the space that gets sent to your sphere mask. That's from the original Tom Looman post.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .