Yasiu Spline Meshed 1
Extension of basic spline for use with meshes.
Loading...
Searching...
No Matches
USplineMeshedComponent Class Reference

Core component that handles meshes spawning along spline. More...

#include <SplineMeshedComponent.h>

Inheritance diagram for USplineMeshedComponent:
USplineMeshedComponent_Extension USplineMeshedComponent_ExtendedToHelix USplineMeshedComponent_ExtendedToSinus

Public Member Functions

void PlaceMeshesAlongSpline (UStaticMesh *Mesh, const FSplineMeshedSpawnParams SpawnParameters)
 Spawn meshes along spline by given params. Override if you intend to clear/set variables before spawning meshes.
void GetMeshPositonsArray (TArray< FYasiuSplineMeshParams > &OutArray, const UStaticMesh *Mesh, const FSplineMeshedSpawnParams &paramsIn) const
 Function that evaluates mesh position and tangent based on params passed in.
void OnMeshSpawn (const FVector &ForwardVec, const FVector &UpVect, const int SegmentID, const float DistanceA, const float DistanceB, USplineMeshComponent *RefMesh)
 Function that is triggered after placing each mesh with corresponding values.
int Num () const
 Current amount of meshes stored (may count invalid).
void ChangeMesh (TSoftObjectPtr< UStaticMesh > Mesh)
 Change static mesh in all Objects. (Updates only mesh's tangents).
void GetMeshes (TArray< class USplineMeshComponent * > &OutArray) const
 Returns Copy of array containing only valid SplineMesh objects.
virtual void SetMaterialsByIndex (const TArray< UMaterialInterface * > &materials)
 Applies materials from array to all meshes.
virtual void CopySplinePoints (const USplineMeshedComponent *copyFrom)
 Copy spline points and curve.
virtual void CopySplineAndMeshes (const USplineMeshedComponent *copyFrom)
 Copy spline points, curve and mesh properties.
void MakeHelix (const FSplineHelixParams &HelixParams)
 Function that changes points to helix.
void MakeSinus (const FSplineSinusParams &SinusParams)
 Function that changes points to sinus.
ASplineMeshActor * SpawnMeshStaticClone (const USplineMeshComponent *Mesh)
 Spawns static actor in world and copies spline mesh properties.
TArray< ASplineMeshActor * > CloneSplineToStaticActors ()
 clone of all meshes in spline and make them static object
void SetSmoothnessAtPoint (int keyIndex, float smoothness=1.f, float ZRotationDeg=0.f)
 Change single point to have given smoothness and rotation. Does not update actor!
void SetSmoothnessAtAllPoints (float smoothness=1.f, float ZRotationDeg=0.f)
 Change spline all points to have desired params.
void OffsetAllPoints (const FVector &RelativeOffset)
 Function used to move all spline points with given relative offset.
void Sharp ()
 Function will adjust tangents of all points to make it sharp.
void Soft ()
 Function will adjust tangents of all points to make it look smooth.
void Smooth ()
 Function will set all points type to Curve (they auto update tangents).
void ExtraCurvy ()
 Function will adjust tangents of all points to make it look extra smooth and very curvy.
void CustomTangents ()
 Function will adjust tangents of single point using TangentToolParams variable.
void CustomTangentsAllPoints ()
 Function will adjust tangents of all spline points using TangentToolParams variable.
bool DetectObjectsAlongSpline (TArray< FSplineMeshedOverlapResult > &DetectResults, FSplineDetectionTestParams DetectionParams) const
 Detection function that iterates along spline and does multiple checks. Function evaluates shape of given mesh.
void DetectionFunction (TArray< FSplineMeshedOverlapResult > &DetectedObjects, UWorld *World, const FVector &LocationIn, const FQuat &RotationIn, const FSplineDetectionTestParams &ParamsIn) const
 Detection function's body, (can be customized), used by DetectObjectsAlongSpline. By default, it detects overlaps by object type.
FVector GetSideOffset (const FVector &Fwd, const FVector &Up, float DistanceRight, float AngleDeg) const
 Calculate helix offset defined by forward Axis, Up axis and rotation Angle.
FVector VectorFrom2Points (float distanceA, float distanceB, const TEnumAsByte< ESplineCoordinateSpace::Type > &CoordSpace=ESplineCoordinateSpace::World) const
 Get normalized vector between 2 points, points are clamped to spline length.
FVector CalculateSplineUpVector (ESplineRotateMode Mode, const FVector &CurrentUp, const FVector &CurrentForward, const FVector &PrevUp, const FVector &UpParameter) const
 Function used to calculate UpVector from given vectors.

Static Public Member Functions

static void ApplyParamsToMesh (const FYasiuSplineMeshParams &params, USplineMeshComponent *Mesh)
 Applies all parameters from struct to SplineMesh Object, without Update. Except ForwardDirection and StaticMesh.
static void CopyMeshMaterials (const UMeshComponent *copyFrom, UMeshComponent *copyTo)
 Copy materials between meshes.

Public Attributes

FSplineSinusParams SinusToolParams {}
 Parameters to create sinus spline in editor.
FSplineHelixParams HelixToolParams {}
 Parameters to create helix spline in editor.
FSplineSmoothParams TangentToolParams {}
 Parameter used by editor commands.

Protected Attributes

TArray< TObjectPtr< USplineMeshComponent > > MeshesArray
 Array of created SplineMeshes.

Detailed Description

Core component that handles meshes spawning along spline.

Member Function Documentation

◆ ChangeMesh()

void USplineMeshedComponent::ChangeMesh ( TSoftObjectPtr< UStaticMesh > Mesh)

Change static mesh in all Objects. (Updates only mesh's tangents).

Warning
Does not change spacing.
Parameters
MeshReference to mesh asset

◆ CloneSplineToStaticActors()

TArray< ASplineMeshActor * > USplineMeshedComponent::CloneSplineToStaticActors ( )

clone of all meshes in spline and make them static object

Returns
Array of actors spawned in world

◆ DetectionFunction()

void USplineMeshedComponent::DetectionFunction ( TArray< FSplineMeshedOverlapResult > & DetectedObjects,
UWorld * World,
const FVector & LocationIn,
const FQuat & RotationIn,
const FSplineDetectionTestParams & ParamsIn ) const

Detection function's body, (can be customized), used by DetectObjectsAlongSpline. By default, it detects overlaps by object type.

Other objects must have Collision "Query" enabled and math collision channel in paramsIn

Note
Please aggregate detected object into DetectedObjects if you want proper results from DetectObjectsAlongSpline
Parameters
DetectedObjectsOutput array, passed to top function.
WorldWorld reference used to run detection
LocationInLocation of detection
RotationInRotation of detection
ParamsInCollection of params used for detection

◆ DetectObjectsAlongSpline()

bool USplineMeshedComponent::DetectObjectsAlongSpline ( TArray< FSplineMeshedOverlapResult > & DetectResults,
FSplineDetectionTestParams DetectionParams ) const

Detection function that iterates along spline and does multiple checks. Function evaluates shape of given mesh.

By default, it detects Overlaps, objects must have Collision "Query" enabled (Physics is not required).

Returns all objects of given type, ignoring their ChannelType responses.

Note
Detection can be modified (by Injection)
In BP please override DetectionFunction
In C++ override DetectionFunction_Implementation, it is BlueprintNativeEvent
Parameters
DetectResultsOutput array of detected actors
DetectionParamsStruct that has test parameters
Returns
True if detected at least one object

◆ GetMeshes()

void USplineMeshedComponent::GetMeshes ( TArray< class USplineMeshComponent * > & OutArray) const

Returns Copy of array containing only valid SplineMesh objects.

Parameters
OutArrayArray with pointers to all valid objects.

◆ OffsetAllPoints()

void USplineMeshedComponent::OffsetAllPoints ( const FVector & RelativeOffset)

Function used to move all spline points with given relative offset.

Parameters
RelativeOffsetRelative offset to apply

◆ OnMeshSpawn()

void USplineMeshedComponent::OnMeshSpawn ( const FVector & ForwardVec,
const FVector & UpVect,
const int SegmentID,
const float DistanceA,
const float DistanceB,
USplineMeshComponent * RefMesh )

Function that is triggered after placing each mesh with corresponding values.

Use this function to modify placing behaviour

Note
For Customization (Injection)
In BP please override OnMeshSpawn
In C++ override OnMeshSpawn_Implementation, it is BlueprintNativeEvent
Parameters
ForwardVecVector from mesh start to mesh end
UpVectSpline's up vector for this mesh
SegmentIDMesh number, indexed from <0, N-1>
DistanceASpline distance along spline at start of mesh in unreal units
DistanceBSpline distance along spline at end of mesh in unreal units
RefMeshSpline Mesh reference for custom edits

◆ PlaceMeshesAlongSpline()

void USplineMeshedComponent::PlaceMeshesAlongSpline ( UStaticMesh * Mesh,
const FSplineMeshedSpawnParams SpawnParameters )

Spawn meshes along spline by given params. Override if you intend to clear/set variables before spawning meshes.

Parameters
MeshStatic mesh object to be used
SpawnParametersParameters how mesh should spawn

◆ SetMaterialsByIndex()

virtual void USplineMeshedComponent::SetMaterialsByIndex ( const TArray< UMaterialInterface * > & materials)
virtual

Applies materials from array to all meshes.

Materials are applied to each slot defined by array <0, N>.

◆ SetSmoothnessAtAllPoints()

void USplineMeshedComponent::SetSmoothnessAtAllPoints ( float smoothness = 1.f,
float ZRotationDeg = 0.f )

Change spline all points to have desired params.

Parameters
smoothnessHow smooth should spline be, 0 means sharp spline, 1 means smooth. Works with negative values
ZRotationDegAngle in degrees. Rotation around Z axis for cool effects

◆ SetSmoothnessAtPoint()

void USplineMeshedComponent::SetSmoothnessAtPoint ( int keyIndex,
float smoothness = 1.f,
float ZRotationDeg = 0.f )

Change single point to have given smoothness and rotation. Does not update actor!

Parameters
keyIndexSpline point index
smoothnessHow smooth should spline be, 0 means sharp spline, 1 means smooth. Works with negative values
ZRotationDegAngle in degrees. Rotation around Z axis for cool effects

◆ VectorFrom2Points()

FVector USplineMeshedComponent::VectorFrom2Points ( float distanceA,
float distanceB,
const TEnumAsByte< ESplineCoordinateSpace::Type > & CoordSpace = ESplineCoordinateSpace::World ) const

Get normalized vector between 2 points, points are clamped to spline length.

Parameters
distanceAdistance along spline for point A
distanceBdistance along spline for point B
CoordSpaceCoordinate space, World or Local
Returns

The documentation for this class was generated from the following file: