1. Quad 그리기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
[RequireComponent(typeof(MeshFilter))]
public class proceduralMesh : MonoBehaviour
{
    Mesh mesh;
    Material material;
 
    Vector3[] vertices;
    int[] triangles;
 
 
    private void Awake()
    {
        mesh = GetComponent<MeshFilter>().mesh;
        material = GetComponent<Renderer>().material;
    }
    // Start is called before the first frame update
    void Start()
    {
        meshData();
        createObj();
    }
 
    void meshData()
    {
        //vertices, triangles베열에 값 넣기
        //vertices에서는 점의 위치를 설정
        vertices = new Vector3[] { new Vector3(000), new Vector3(001), new Vector3(100), new Vector3(1,0,1) };
        //triangles에서는 vertices를 어떻게 연결할지 정하기 
        triangles = new int[] { 012213 };
    }
 
    //obj 그리기 
    void createObj()
    {
        mesh.vertices = vertices;
        mesh.triangles = triangles;
        material.color = Color.green;
 
        //법선벡터 계산(라이팅)
        mesh.RecalculateNormals();
    }
 
    }
 
cs


'Project > TouchMe' 카테고리의 다른 글

10/8 joint 안정화 작업  (0) 2019.10.09
10/6 procedural grid, physics and soft body(nvidia flux)  (0) 2019.10.08
04. 10/3 softBody effect  (0) 2019.10.04
03. 10/2 physics & leapmotion SDK  (0) 2019.10.02
02. 기술 기획  (0) 2019.10.02
Posted by 도이(doi)
,