美文网首页
2023-02-06【Gpt】niubility的一次使用 su

2023-02-06【Gpt】niubility的一次使用 su

作者: 持刀的要迟到了 | 来源:发表于2023-02-05 17:10 被阅读0次
using UnityEngine;

public class UnpackSubmesh : MonoBehaviour
{
    public int submeshIndex = 0;

    private void Start()
    {
        MeshFilter meshFilter = GetComponent<MeshFilter>();
        Mesh mesh = meshFilter.mesh;
        int[] triangles = mesh.GetTriangles(submeshIndex);

        for (int i = 0; i < triangles.Length; i += 3)
        {
            Vector3[] vertices = new Vector3[3];
            Vector3[] normals = new Vector3[3];
            Vector2[] uv = new Vector2[3];

            for (int j = 0; j < 3; j++)
            {
                int index = triangles[i + j];
                vertices[j] = mesh.vertices[index];
                normals[j] = mesh.normals[index];
                uv[j] = mesh.uv[index];
            }

            GameObject triangleMesh = new GameObject("Triangle Mesh");
            triangleMesh.transform.parent = transform;
            triangleMesh.AddComponent<MeshFilter>().mesh = CreateMesh(vertices, normals, uv);
            triangleMesh.AddComponent<MeshRenderer>().material = meshFilter.GetComponent<MeshRenderer>().materials[submeshIndex];
        }

        meshFilter.mesh = new Mesh();
    }

    private Mesh CreateMesh(Vector3[] vertices, Vector3[] normals, Vector2[] uv)
    {
        Mesh mesh = new Mesh();
        mesh.vertices = vertices;
        mesh.normals = normals;
        mesh.uv = uv;
        mesh.triangles = new int[] { 0, 1, 2 };
        return mesh;
    }
}

相关文章

  • GPT、LVM概念介绍及shell脚本

    1、描述GPT是什么,应该怎么使用。 GPT的全称是Globally Unique Identifier Part...

  • 第四周

    1、描述GPT是什么,应该怎么使用。 GPT的全称是Globally Unique Identifier Part...

  • 第四周作业

    1、描述GPT是什么,应该怎么使用。 GPT的全称为Globally Unique ldentifire Part...

  • 2018-05-03

    TLCL 学习总结 5-03 su命令相关 在学习使用 su 命令切换用户时发现一个很奇怪的现象。当第一次使用su...

  • 脚本与磁盘管理

    1、描述GPT是什么,应该怎么使用。 GPT是GUIDPartition Table,GUID分区表。GUID(G...

  • 第四周作业

    壹、描述GPT是什么,应该怎么使用。 GUID磁盘分区表(GUID Partition Table,缩写:GPT)...

  • 2019-02-23

    一、描述GPT是什么,应该怎么使用 GUID磁盘分区表(GUID Partition Table,缩写:GPT...

  • 第四周作业

    1、描述GPT是什么,应该怎么使用。 GPT(GUID Partition Table):是一个较新的分区机制,解...

  • 第五周

    1.描述GPT是什么,应该怎么使用 GPT(GUID Partition Table):是一个较新的分区机制,解...

  • 第四周作业

    1、描述GPT是什么,该怎么使用 GPT(GUID Partition Table):是一个较新的分区机制,解决了...

网友评论

      本文标题:2023-02-06【Gpt】niubility的一次使用 su

      本文链接:https://www.haomeiwen.com/subject/cmczhdtx.html