About 'Deforming Meshes With Splines'!

  • What is a USplineMeshComponent?
  • Replacing the UStaticMeshComponent
  • Getting the spline tangents.
  • Tracing the spline.
  • Hiding extra meshes.

(Unique Video Reference: 20_AE_VR2)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

This one was super confusing to get through, possibly because I’m on 4.25 and there are bugs.

Basically, I could not get local coordinate space vectors from the USplineComponent no matter what. The results were always identical regardless of choosing local or world coordinate space:

	TeleportPath->GetLocationAndTangentAtSplinePoint(i - 1, StartLocation, StartTangent, ESplineCoordinateSpace::World);
	TeleportPath->GetLocationAndTangentAtSplinePoint(i, EndLocation, EndTangent, ESplineCoordinateSpace::World);

Later I ended up just inverse transforming from the TeleportPath’s transform:

		Obj->SetStartAndEnd(
			TeleportPath->GetComponentTransform().InverseTransformPosition(StartLocation),
			TeleportPath->GetComponentTransform().InverseTransformVector(StartTangent),
			TeleportPath->GetComponentTransform().InverseTransformPosition(EndLocation),
			TeleportPath->GetComponentTransform().InverseTransformVector(EndTangent)
		);

Again, maybe a bug as the interface has changed somewhat, but the code inside the various components looks fine and you can see the transforms being applied there depending on the coordinate space enum.

I was also momentarily confused by the choice of VRRoot as the attachment parent, glad you corrected that after the challenge slide but it would have been better before! In the course of my experimentation I had decided to attach to the RightController anyway…

Little performance optimisation. It should not account for much, since it’s not like the spline mesh has an insane amount of segments (depending on your design choices of course), and chances are that Unreal won’t perform any graphics operations until the function has finished running (maybe?) making it efectively just a marking process, but only Tim knows what goes underneath Unreal when running visibility functions, maybe they execute the graphics operations immediately in another thread, so it’s nice to have. Instead of hiding all the segments at the begining of “DrawTeleportPath” just to probably show most of them again right after, I do hide at the end “DrawTeleportPath” only the ones that have not been used (if any).

	...
		SplineMesh->SetStartAndEnd(StartPosition, StartTangent, EndPosition, EndTangent);

		SplineMesh->SetVisibility(true);
	}

	for (int32 Index = Path.Num(); Index < TeleportPathMeshPool.Num(); ++Index)
	{
		TeleportPathMeshPool[Index]->SetVisibility(false);
	}
}

For some reason the materials to the dynamically created spline meshes are not applied. If during runtime I select the spline mesh and reassign the material through the details panel it is rendered correctly. Moreover the spline meshes are not connected and there is a gab between them. Any ideas how to approach this ?

Can you share a couple of screenshots highlighting the issue so I can understand better what is going on. Thanks.

I actually had same issue with 4.27 here … There is effectively a bug to get local location and tangent. I spend a long time to have a functionnal result.

Here is my workaround, inspired by your comment ohookins:

  • Keep VRRoot to attach the splineMesh
  • Fix the positions by removing VRRoot Location
  • Rotate All FVector by -90
		TeleportPath->GetLocalLocationAndTangentAtSplinePoint(i, StartPos, StartTangent);
		TeleportPath->GetLocalLocationAndTangentAtSplinePoint(i+1, EndPos, EndTangent);	

		StartPos = StartPos - VRRoot->GetComponentLocation();
		EndPos = EndPos - VRRoot->GetComponentLocation();

		FVector FixedStartTangent = StartTangent.RotateAngleAxis(-90, FVector::ZAxisVector);
		FVector FixedEndTangent = EndTangent.RotateAngleAxis(-90, FVector::ZAxisVector);
		FVector FixedStartPos = StartPos.RotateAngleAxis(-90, FVector::ZAxisVector);
		FVector FixedEndPos = EndPos.RotateAngleAxis(-90, FVector::ZAxisVector);

		SplineMesh->SetStartAndEnd(FixedStartPos, FixedStartTangent, FixedEndPos, FixedEndTangent, true);
1 Like

Privacy & Terms