(八)正二十面体
1.概述
本片转自如下
2.代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateIcosahedron : MonoBehaviour
{
public float size = 1;
private Vector3[] vertices;
private Vector2[] uvs;
private Vector3[] normals;
private Vector4[] tangents;
private int[] triangles;
private Mesh CreateRegular()
{
Mesh mesh = new Mesh();
// 先按12个顶点开辟顶点数组
vertices = new Vector3[12];
// 正二十面体顶点公式(度娘可查)
float m = Mathf.Sqrt(50 - 10 * Mathf.Sqrt(5)) / 10 * size;
float n = Mathf.Sqrt(50 + 10 * Mathf.Sqrt(5)) / 10 * size;
// 按公式顺序对顶点坐标赋值
vertices[0] = new Vector3(m, 0, n);
vertices[1] = new Vector3(m, 0, -n);
vertices[2] = new Vector3(-m, 0, n);
vertices[3] = new Vector3(-m, 0, -n);
vertices[4] = new Vector3(0, n, m);
vertices[5] = new Vector3(0, -n, m);
vertices[6] = new Vector3(0, n, -m);
vertices[7] = new Vector3(0, -n, -m);
vertices[8] = new Vector3(n, m, 0);
vertices[9] = new Vector3(-n, m, 0);
vertices[10] = new Vector3(n, -m, 0)