添加 Source/FLESHEditor/Private/VisceraNodeFactory.cpp
This commit is contained in:
139
Source/FLESHEditor/Private/VisceraNodeFactory.cpp
Normal file
139
Source/FLESHEditor/Private/VisceraNodeFactory.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
#include "VisceraNodeFactory.h"
|
||||
|
||||
TSharedPtr<FVisceraNodeItem> FVisceraNodeFactory::CreateSoftBodyNode(const FName& Name, const FString& DisplayName)
|
||||
{
|
||||
TSharedPtr<FVisceraNodeItem> Node = MakeShareable(new FVisceraNodeItem(Name, DisplayName, TEXT("SoftBody")));
|
||||
|
||||
// Set default properties
|
||||
Node->BoolProperties.Add(TEXT("EnableSimulation"), true);
|
||||
Node->FloatProperties.Add(TEXT("GravityStrength"), 1.0f);
|
||||
Node->FloatProperties.Add(TEXT("MinFrameSpeed"), 0.0f);
|
||||
Node->FloatProperties.Add(TEXT("MaxFrameSpeed"), 200.0f);
|
||||
Node->FloatProperties.Add(TEXT("ExternalFrameLerp"), 1.0f);
|
||||
Node->FloatProperties.Add(TEXT("InitialGPUInfluence"), 0.5f);
|
||||
Node->FloatProperties.Add(TEXT("SubstepTime"), 0.01667f);
|
||||
Node->FloatProperties.Add(TEXT("SolverIterations"), 1.0f);
|
||||
Node->BoolProperties.Add(TEXT("RecomputeNormals"), true);
|
||||
Node->BoolProperties.Add(TEXT("EnableMultiLayerCutting"), true);
|
||||
Node->FloatProperties.Add(TEXT("CapMethod"), (float)ECapMeshMethod::TriangleFan);
|
||||
|
||||
return Node;
|
||||
}
|
||||
|
||||
TSharedPtr<FVisceraNodeItem> FVisceraNodeFactory::CreateAnchorNode(
|
||||
const FName& Name,
|
||||
const FString& DisplayName,
|
||||
const FVector& Location,
|
||||
float Radius,
|
||||
float Stiffness,
|
||||
FName BoneName)
|
||||
{
|
||||
TSharedPtr<FVisceraNodeItem> Node = MakeShareable(new FVisceraNodeItem(Name, DisplayName, TEXT("Anchor")));
|
||||
|
||||
// Set properties
|
||||
Node->VectorProperties.Add(TEXT("Location"), Location);
|
||||
Node->FloatProperties.Add(TEXT("Radius"), Radius);
|
||||
Node->FloatProperties.Add(TEXT("Stiffness"), Stiffness);
|
||||
Node->NameProperties.Add(TEXT("BoneName"), BoneName);
|
||||
|
||||
return Node;
|
||||
}
|
||||
|
||||
TSharedPtr<FVisceraNodeItem> FVisceraNodeFactory::CreateLineChainNode(
|
||||
const FName& Name,
|
||||
const FString& DisplayName,
|
||||
const TArray<FVector>& Points,
|
||||
float Stiffness,
|
||||
float Thickness)
|
||||
{
|
||||
TSharedPtr<FVisceraNodeItem> Node = MakeShareable(new FVisceraNodeItem(Name, DisplayName, TEXT("LineChain")));
|
||||
|
||||
// Set properties
|
||||
Node->FloatProperties.Add(TEXT("Stiffness"), Stiffness);
|
||||
Node->FloatProperties.Add(TEXT("Thickness"), Thickness);
|
||||
|
||||
// Add points
|
||||
if (Points.Num() > 0)
|
||||
{
|
||||
Node->PointsArray = Points;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default add two points
|
||||
Node->PointsArray.Add(FVector(-10.0f, 0.0f, 0.0f));
|
||||
Node->PointsArray.Add(FVector(10.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
return Node;
|
||||
}
|
||||
|
||||
TSharedPtr<FVisceraNodeItem> FVisceraNodeFactory::CreateTetraNode(
|
||||
const FName& Name,
|
||||
const FString& DisplayName,
|
||||
const TArray<FVector>& Points,
|
||||
float Stiffness)
|
||||
{
|
||||
TSharedPtr<FVisceraNodeItem> Node = MakeShareable(new FVisceraNodeItem(Name, DisplayName, TEXT("Tetra")));
|
||||
|
||||
// Set properties
|
||||
Node->FloatProperties.Add(TEXT("Stiffness"), Stiffness);
|
||||
|
||||
// Add points
|
||||
if (Points.Num() >= 4)
|
||||
{
|
||||
Node->PointsArray = Points;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default add four points to form a tetrahedron
|
||||
Node->PointsArray.Add(FVector(0.0f, 0.0f, 0.0f));
|
||||
Node->PointsArray.Add(FVector(10.0f, 0.0f, 0.0f));
|
||||
Node->PointsArray.Add(FVector(0.0f, 10.0f, 0.0f));
|
||||
Node->PointsArray.Add(FVector(0.0f, 0.0f, 10.0f));
|
||||
}
|
||||
|
||||
return Node;
|
||||
}
|
||||
|
||||
TSharedPtr<FVisceraNodeItem> FVisceraNodeFactory::CreatePlaneNode(
|
||||
const FName& Name,
|
||||
const FString& DisplayName,
|
||||
const FVector& Location,
|
||||
const FVector& Normal,
|
||||
float Stiffness)
|
||||
{
|
||||
TSharedPtr<FVisceraNodeItem> Node = MakeShareable(new FVisceraNodeItem(Name, DisplayName, TEXT("Plane")));
|
||||
|
||||
// Set properties
|
||||
Node->VectorProperties.Add(TEXT("Location"), Location);
|
||||
Node->VectorProperties.Add(TEXT("Normal"), Normal);
|
||||
Node->FloatProperties.Add(TEXT("Stiffness"), Stiffness);
|
||||
|
||||
return Node;
|
||||
}
|
||||
|
||||
TSharedPtr<FVisceraNodeItem> FVisceraNodeFactory::CreateTimeNode(
|
||||
const FName& Name,
|
||||
const FString& DisplayName,
|
||||
float SubstepTime,
|
||||
float SolverIterations)
|
||||
{
|
||||
TSharedPtr<FVisceraNodeItem> Node = MakeShareable(new FVisceraNodeItem(Name, DisplayName, TEXT("Time")));
|
||||
|
||||
// Set properties
|
||||
Node->FloatProperties.Add(TEXT("SubstepTime"), SubstepTime);
|
||||
Node->FloatProperties.Add(TEXT("SolverIterations"), SolverIterations);
|
||||
|
||||
return Node;
|
||||
}
|
||||
|
||||
TSharedPtr<FVisceraNodeItem> FVisceraNodeFactory::CreateGroupCollisionsNode(
|
||||
const FName& Name,
|
||||
const FString& DisplayName)
|
||||
{
|
||||
TSharedPtr<FVisceraNodeItem> Node = MakeShareable(new FVisceraNodeItem(Name, DisplayName, TEXT("GroupCollisions")));
|
||||
|
||||
// Default properties can be added here
|
||||
|
||||
return Node;
|
||||
}
|
Reference in New Issue
Block a user