Beispiel #1
0
    public TrailRenderer(int max_vert, GameObject parent)
    {
        if (PerformanceManager.Instance.CurrentEnvironmentInfo != null) //by pj 重新修正 当当前有配置的时候使用配置 否则就不改变
        {
            _Quality = PerformanceManager.Instance.CurrentEnvironmentInfo.trailQuality;
        }

        _GameObject = new GameObject("TrailRenderer", typeof(MeshFilter), typeof(MeshRenderer));
        _GameObject.transform.parent = parent.transform;
        meshFilter = _GameObject.GetComponent <MeshFilter>();
        _Renderer  = meshFilter.GetComponent <Renderer>();
        if (!Application.isPlaying)
        {
            meshFilter.sharedMesh = new Mesh();
            _Mesh = meshFilter.sharedMesh;
        }
        else
        {
            meshFilter.mesh = new Mesh();
            _Mesh           = meshFilter.mesh;
        }
        _TotalSubsections = 0;
        _TextureYCount    = _TextureYSplit;
        _HermiteBasis     = new Vector4[4];
        _HermiteBasis[0]  = new Vector4(2, -3, 0, 1);
        _HermiteBasis[1]  = new Vector4(-2, 3, 0, 0);
        _HermiteBasis[2]  = new Vector4(1, -2, 1, 0);
        _HermiteBasis[3]  = new Vector4(1, -1, 0, 0);

        int max_indices = max_vert * 3 - 6;

        _MaxVerts   = max_vert;
        _MaxIndices = max_indices;
        _SegmentPositionTopBuffer    = new EB.CircularBuffer <Vector3>(max_vert);
        _SegmentPositionBottomBuffer = new EB.CircularBuffer <Vector3>(max_vert);
        _SegmentSubsectionsBuffer    = new EB.CircularBuffer <int>(max_vert);
        _SegmentTimesBuffer          = new EB.CircularBuffer <float>(max_vert);

        //move vert,etc. array creation here
        _vertices = new Vector3[max_vert];
        _uvs      = new Vector3[max_vert];
        _colors   = new Color[max_vert];
        _indices  = new int[max_indices];

        for (int i = 0; i < max_indices; ++i)
        {
            _indices[i] = 0;
        }
    }
Beispiel #2
0
 public void DestroyTrail()
 {
     if (Application.isPlaying)
     {
         GameObject.Destroy(_GameObject);
         GameObject.Destroy(_Mesh);
     }
     else
     {
         GameObject.DestroyImmediate(_GameObject);
         GameObject.DestroyImmediate(_Mesh);
     }
     _SegmentPositionBottomBuffer = null;
     _SegmentPositionTopBuffer    = null;
     _SegmentSubsectionsBuffer    = null;
     _SegmentTimesBuffer          = null;
     _HermiteBasis = null;
 }