using UnityEngine; using System.Collections; using System.Collections.Generic; public struct SegmentPoint { public Vector3 normal; public Vector3 pos; }; public class DrawMesh_Plane : MonoBehaviour { MeshFilter meshFilter; /// <summary> /// 面片
前言: 由於之前的基本介紹,所以有關的知識點不做贅述,只上案例,知識作爲自己做試驗的記錄,便於日後查看. 步驟: 1.創建一個empty 的gameobject: 2.添加一個脚本給這個game object: 具體脚本如下: using UnityEngine; using System.Collections; [RequireComponent(typeof(MeshRenderer), typeof(MeshFilter))] public class quad : MonoBehavi
using UnityEngine; using System.Collections; public class Quad : MonoBehaviour { // Use this for initialization void Start () { CreateQuad (); } ; ; public void CreateQuad() { /* 1. 顶点,三角形,法线,uv坐标, 绝对必要的部分只有顶点和三角形. 如果模型中不需要场景中的光照,那么就不需要法线.如果模型不需要贴材质,
using UnityEngine; using System.Collections; using System.Collections.Generic; public class Cone : MonoBehaviour { ; ; public int[] triangles; public Vector2[] uvs; public Vector3[] vertices; public Vector3[] normals; public float dist_min = 0.0f; pu
网格绘制主要用是对Mesh进行操作,通过对vertex和triangles进行操作生成对应的面片: 这里首先得用到一个类:Triangulator(根据vertex生成triangles数组) using UnityEngine; using System.Collections.Generic; public class Triangulator { private static List<Vector2> points; private static Vector3 cameraPosit