arskrald/AR-2/Assets/MeshScript.cs

134 lines
3.0 KiB
C#
Raw Normal View History

2019-02-13 15:20:58 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeshScript : MonoBehaviour
{
public Material material;
void Start() {
Vector3[] vertices = new Vector3[15];
Vector2[] uv = new Vector2[15];
int[] triangles = new int[39];
// top
vertices[0] = new Vector3(1.5f, 6);
vertices[1] = new Vector3(1, 5);
vertices[2] = new Vector3(2, 5);
vertices[3] = new Vector3(1, 4);
vertices[4] = new Vector3(2, 4);
vertices[5] = new Vector3(1, 3);
vertices[6] = new Vector3(2, 3);
vertices[7] = new Vector3(1, 2);
vertices[8] = new Vector3(2, 2);
vertices[9] = new Vector3(1, 1);
vertices[10] = new Vector3(2, 1);
vertices[11] = new Vector3(3, 1);
vertices[12] = new Vector3(3, 0);
vertices[13] = new Vector3(0, 1);
vertices[14] = new Vector3(0, 0);
// Right wing points
/* vertices[10] = new Vector3(0,0);
vertices[11] = new Vector3(1,1);
vertices[12] = new Vector3(0,1);
uv[10] = new Vector2(0,1);
uv[11] = new Vector2(1,1);
uv[12] = new Vector2(0,0);*/
// top
triangles[0] = 1;
triangles[1] = 2;
triangles[2] = 0;
triangles[3] = 1;
triangles[4] = 4;
triangles[5] = 2;
triangles[6] = 1;
triangles[7] = 3;
triangles[8] = 4;
triangles[9] = 3;
triangles[10] = 5;
triangles[11] = 4;
triangles[12] = 5;
triangles[13] = 6;
triangles[14] = 4;
triangles[15] = 5;
triangles[16] = 8;
triangles[17] = 6;
triangles[18] = 5;
triangles[19] = 7;
triangles[20] = 8;
triangles[21] = 7;
triangles[22] = 9;
triangles[23] = 8;
triangles[24] = 9;
triangles[25] = 10;
triangles[26] = 8;
triangles[27] = 13;
triangles[28] = 9;
triangles[29] = 7;
triangles[30] = 13;
triangles[31] = 14;
triangles[32] = 9;
triangles[33] = 8;
triangles[34] = 10;
triangles[35] = 11;
triangles[36] = 10;
triangles[37] = 12;
triangles[38] = 11;
// Right wing
/* triangles[10] = 0;
triangles[11] = 1;
triangles[12] = 2;*/
Mesh mesh = new Mesh();
mesh.vertices = vertices;
mesh.uv = uv;
mesh.triangles = triangles;
GameObject go = new GameObject("Mesh", typeof(MeshFilter), typeof(MeshRenderer));
go.transform.localScale = new Vector3(1, 1, 1);
go.GetComponent<MeshFilter>().mesh = mesh;
go.GetComponent<MeshRenderer>().material = new Material(Shader.Find("Unlit/ShitShader"));
}
// Update is called once per frame
void Update()
{
}
}