InvertedSphere
Unity3D/C# 2021. 7. 30. 14:01https://gist.github.com/unity3dcollege/d059b376f7461d908107e97534ed9e04
Normal 뒤집기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(MeshFilter))]
public class ReverseNormal : MonoBehaviour
{
private void Start()
{
var filter = this.GetComponent<MeshFilter>();
if (filter != null) {
var mesh = filter.mesh;
Vector3[] normals = mesh.normals;
for (int i = 0; i < normals.Length; i++) {
normals[i] = -normals[i];
}
mesh.normals = normals;
for (int m = 0; m < mesh.subMeshCount; m++) {
int[] triangles = mesh.GetTriangles(m);
for (int i = 0; i < triangles.Length; i += 3) {
int temp = triangles[i + 0];
triangles[i + 0] = triangles[i + 1];
triangles[i + 1] = temp;
}
mesh.SetTriangles(triangles, m);
}
}
}
}
'Unity3D > C#' 카테고리의 다른 글
C# 강좌 Day-02 (변수와 값) (0) | 2021.08.14 |
---|---|
C# 강좌 Day-01 (HelloWorld) (0) | 2021.08.14 |
싱글톤(Singletone) vs C#정적클래스(static class) 차이점 (0) | 2021.03.25 |
2048 (0) | 2021.03.19 |
IComparable.CompareTo(Object) 메서드 (0) | 2021.03.16 |