Inheritance: MonoBehaviour
Beispiel #1
0
    // Update is called once per frame
    void UpdatePoint(Transform _tr, TraceMesh _mesh)
    {
        Vector3 localXAxis = _tr.right * WheelSize;

        _mesh.m_previousPts[0] = _mesh.m_currentPts[0];
        _mesh.m_previousPts[1] = _mesh.m_currentPts[1];
        _mesh.m_currentPts[0]  = _tr.position + localXAxis - _tr.up * WheelSize;
        _mesh.m_currentPts[1]  = _tr.position - localXAxis - _tr.up * WheelSize;

        // Creation of a the vertice table
        Vector3[] vertices = new Vector3[4];
        vertices[0] = _mesh.m_previousPts[0];
        vertices[1] = _mesh.m_previousPts[1];
        vertices[2] = _mesh.m_currentPts[1];
        vertices[3] = _mesh.m_currentPts[0];

        if (_mesh.m_index < _mesh.m_vertices.Count)
        {
            _mesh.m_vertices[_mesh.m_index] = new Vector3[4];
            for (int i = 0; i < 4; i++)
            {
                _mesh.m_vertices[_mesh.m_index][i] = vertices[i];
            }
        }
        else
        {
            _mesh.m_vertices.Add(vertices);
        }

        int offset = mVertices.Count;

        for (int i = 0; i < _mesh.m_vertices.Count; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                mVertices.Add(_mesh.m_vertices[i][j]);
                mUvs.Add(c_uvs[j]);
            }
            for (int j = 0; j < 6; j++)
            {
                mTriangles.Add(offset + i * 4 + c_triangles[j]);
            }
        }

        _mesh.m_index++;
        if (_mesh.m_index > length)
        {
            _mesh.m_index = 0;
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        m_traceMeshs = new TraceMesh[m_points.Length];
        for (int i = 0; i < m_traceMeshs.Length; i++)
        {
            m_traceMeshs[i] = new TraceMesh();
        }

        m_slidingTraces     = new GameObject("SlidingTraces");
        m_mf                = m_slidingTraces.AddComponent <MeshFilter>();
        m_mesh              = new Mesh();
        m_mf.mesh           = m_mesh;
        m_renderer          = m_slidingTraces.AddComponent <MeshRenderer>();
        m_renderer.material = TraceMaterial;
    }
Beispiel #3
0
 void Start()
 {
     tm = transform.parent.parent.GetComponent<TraceMesh>();
     if (tm == null) Debug.LogWarning("Vertice instantiated without parent.parent having TraceMesh!");
 }