Mesh 클래스는 오브젝트의 메시 지오메트리에 대한 기본적인 스크립트 인터페이스입니다. 배열을 활용하여 삼각형, 버텍스 포지션, 노멀 및 텍스처 좌표를 나타내며 메시 생성에 도움이 되는 유용한 여러 프로퍼티 및 함수를 제공합니다.
메시 데이터는 Mesh Filter 컴포넌트를 사용하여 오브젝트에 추가됩니다(오브젝트는 지오메트리를 표시하기 위해 MeshRenderer를 필요로 합니다). 이 컴포넌트는 익숙한 GetComponent 함수로 액세스할 수 있습니다.
using UnityEngine;
public class ExampleScript : MonoBehaviour
{
MeshFilter mf;
void Start()
{
//if this gameObject has a MeshFilter, mf will reference the component
mf = GetComponent<MeshFilter>();
}
}
메시 오브젝트에는 버텍스와 관련 데이터(노멀 및 UV 좌표), 삼각형 데이터에 대한 프로퍼티가 있습니다. 버텍스는 임의의 순서로 제공되지만 노멀과 UV 배열은 인덱스가 버텍스에 대응하도록 정렬되어야 합니다(즉, 노멀 배열의 요소 0은 버텍스 0에 노멀을 제공). 버텍스는 오브젝트의 로컬 공간상 점을 나타내는 Vector3입니다. 노멀은 로컬 좌표로 방향을 나타내는 정규화된 Vector3입니다. UV는 Vector2로 지정되지만 Vector2 타입은 U와 V라는 필드가 없으므로 머리 속에서 각각 X와 Y로 변환해야 합니다.
삼각형은 버텍스 배열에서 인덱스 역할을 하는 정수의 3배수로 지정됩니다. 삼각형을 나타내는 특수한 클래스를 사용하지 않으며 이 배열은 정수 인덱스의 간단한 리스트입니다. 이들은 삼각형마다 세 개의 그룹에 분할되므로 처음 세 개의 요소는 첫 번째 삼각형, 그 다음 세 개의 요소는 두 번째 삼각형을 정의합니다. 삼각형에 대한 중요한 상세 정보는 코너 버텍스의 순서입니다. 어느 코너부터 시작하는지는 중요하지 않지만 삼각형의 가시적인 외면을 내려다보면서 코너가 시계 방향으로 되도록 배치해야 합니다.
또한 Mesh 클래스는 원시 메시 버텍스 및 인덱스 버퍼 데이터를 사용하도록 해주는 저수준 고급 API를 제공합니다. 이 API는 최대 성능 또는 최저 메모리 할당이 필요한 경우에 유용합니다.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.