Publish:

ํƒœ๊ทธ: , , ,

์นดํ…Œ๊ณ ๋ฆฌ:

๐Ÿ“Œ 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๋ฅผ ๊ทธ๋ ค๋ณด์ž.

๊ธฐ๋ณธ์ ์ธ ์ •์ ๊ณผ ์‚ผ๊ฐํ˜•๋งŒ ๋„ฃ์–ด์ฃผ์ž.

๐Ÿ“‹ ์„ธํŒ…

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ถค์ ์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

Trail1

์ •์ ์—๋Š” ์ •์ ์„ ์ˆœ์„œ๋Œ€๋กœ ๋„ฃ์–ด์ฃผ๊ณ  ์‚ผ๊ฐํ˜•์—๋Š” ์‹œ๊ณ„ ๋ฐ˜๋Œ€ ๋ฐฉํ–ฅ์œผ๋กœ ์ •์ ์„ ๋„ฃ์–ด์ฃผ๋ฉด ๋œ๋‹ค.

์ •์ ์€ (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);
}

๐Ÿ“‹ ๊ฒฐ๊ณผ

๊ฒฐ๊ณผ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

1

๋ฐฉ๋ฌธํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!๐Ÿ˜Š

์—…๋ฐ์ดํŠธ:

๋Œ“๊ธ€๋‚จ๊ธฐ๊ธฐ