我有这段代码,可以在网格的每个顶点生成球形预制件。我该如何使用每个生成的球形预制件制作蒙皮的网格渲染器,以填充每个生成的球形之间的间隙?
基本上,Im试图做的就是填充此形状,以便这些球体像顶点一样工作,并生成一个网格将其包围。
我的球形生成代码。
谢谢。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class gen : MonoBehaviour {
public Mesh mesh;
public GameObject SpherePrefab;
private static int sphereCount = 0;
private static GameObject SphereContainer;
// Use this for initialization
private void Start () {
SphereContainer = new GameObject("Sphere container");
Vector3[] verts = mesh.vertices;
for(int i = 0; i < verts.Length; i++)
{
sphereCount++;
GameObject sphere = Instantiate(SpherePrefab, verts[i] + transform.position, Quaternion.identity) as GameObject ;
//sphere.AddComponent<SpringJoint>();
sphere.name = "Sphere " + sphereCount;
sphere.transform.parent = SphereContainer.transform;
}
}
// Update is called once per frame
void Update () {
}
}