Unreal Path Trail(Procedural Mesh)2
ํ๊ทธ: Trail, Trajectory, Unreal, ์ธ๋ฆฌ์ผ
์นดํ ๊ณ ๋ฆฌ: UnRealStudy
๐ Procedural Mesh
1
2
3
4
5
6
7
8
9
10
11
CreateMeshSection_LinearColor
(
int32 SectionIndex,
const TArray< FVector >& Vertices,
const TArray< int32 >& Triangles,
const TArray< FVector >& Normals,
const TArray< FVector2D >& UV0,
const TArray< FLinearColor >& Vert...,
const TArray< FProcMeshTangent >& ...,
bool bCreateCollision
)
๋ค์ ํจ์๋ฅผ ์ด์ฉํ์ฌ Mesh๋ฅผ ๊ทธ๋ ค๋ณด์.
๊ธฐ๋ณธ์ ์ธ ์ ์ ๊ณผ ์ผ๊ฐํ๋ง ๋ฃ์ด์ฃผ์.
๐ ์ธํ
๋ค์๊ณผ ๊ฐ์ด ๊ถค์ ์ ์์ฑํ ์ ์๋ค.
์ ์ ์๋ ์ ์ ์ ์์๋๋ก ๋ฃ์ด์ฃผ๊ณ ์ผ๊ฐํ์๋ ์๊ณ ๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ์ ์ ์ ๋ฃ์ด์ฃผ๋ฉด ๋๋ค.
์ ์ ์ (0, 1, 2, 3, 4, โฆ)
์ผ๊ฐํ์ (0, 1, 2, 3, 2, 1, โฆ)
์ด๋ฌํ ๋ฐฉ์์ผ๋ก ์์ฑํ๋ค.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void UpdateVertices();
UPROPERTY()
UProceduralMeshComponent* proceduralMesh;
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (AllowPrivateAccess = true))
AActor* Target;
TArray<FVector> vertices;
TArray<int32> triangles;
TArray<FVector> normals;
TArray<FProcMeshTangent> tangents;
TArray<FVector2D> uv0;
TArray<FLinearColor> vertexColors;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
void AMyActor::UpdateVertices()
{
// ํ๋ธ์ ์ข, ์ฐ๋ฅผ ๊ตฌ๋ถ
vertices.Add(Target->GetActorLocation() - Target->GetActorRightVector() * 50);
vertices.Add(Target->GetActorLocation() + Target->GetActorRightVector() * 50);
// ์ ์ 2๊ฐ์ผ ๋
if(vertices.Num() < 4)
{
triangles.Add(0);
triangles.Add(1);
}
// ์ ์ 4๊ฐ์ผ ๋
else if(vertices.Num() == 4)
{
triangles.Add(2);
for(int i = 2; i >= 0; i--)
{
triangles.Add(triangles[i] + 1);
}
}
// ์ ์ 4๊ฐ ์ด๊ณผ์ผ ๋
else
{
int to = triangles.Num();
int from = to - 6;
for(int i = from; i < to; i++)
{
triangles.Add(triangles[i] + 2);
}
}
proceduralMesh->CreateMeshSection_LinearColor(count, vertices, triangles, normals, uv0, vertexColors, tangents, true);
}
๐ ๊ฒฐ๊ณผ
๊ฒฐ๊ณผ๋ ๋ค์๊ณผ ๊ฐ๋ค.
๋๊ธ๋จ๊ธฐ๊ธฐ