Beispiel #1
0
 public TrailRecordInfo(TrailRecordConfig config)
 {
     this.Config   = config;
     this.MeshInfo = new SplineMeshInfo(config, mMeshModifier);
     tmo           = new TrailMeshObject();
     tmo.Init(config.Materials, config.Layer, config.SortingLayerName, config.SortingOrder);
 }
Beispiel #2
0
        public void Play(TrailRecordInfo recordInfo, int recordNum)
        {
            TrailMeshObject tmo = recordInfo.tmo;

            NF.Collections.Generic.LinkedList <LineInfo> records = recordInfo.RecordElements;
            SplineMeshInfo    meshInfo = recordInfo.MeshInfo;
            TrailRecordConfig config   = recordInfo.Config;

            switch (config.ELinePerVertexCount)
            {
            case TrailRecordConfig.E_LinePerVertexCount.TWO:
                UpdateMeshObjectWithSpline2(tmo, recordInfo.mMeshModifier, records, meshInfo, config);
                break;

            case TrailRecordConfig.E_LinePerVertexCount.THREE:
                UpdateMeshObjectWithSpline3(tmo, recordInfo.mMeshModifier, records, meshInfo, config);
                break;
            }
        }
Beispiel #3
0
        public SplineMeshInfo(TrailRecordConfig config, MeshModifier meshModifier)
        {
            var linePerVertexCount = (int)config.ELinePerVertexCount;
            int line             = config.MaxPlayingRecordLength * config.SplineDetail;
            var totalVertexCount = line * linePerVertexCount;

            mMeshInfo.Vertices = new NativeArray <Vector3>(new Vector3[totalVertexCount], Allocator.Persistent);
            mMeshInfo.UVs      = new NativeArray <Vector2>(new Vector2[totalVertexCount], Allocator.Persistent);
            mMeshInfo.Colors   = new NativeArray <Color>(new Color[totalVertexCount], Allocator.Persistent);
            mMeshInfo.Indices  = new NativeArray <int>(new int[(line - 1) * linePerVertexCount * (linePerVertexCount + 1)], Allocator.Persistent);

            if (config.ColorStart == config.ColorEnd)
            {
                switch (config.ELinePerVertexCount)
                {
                case TrailRecordConfig.E_LinePerVertexCount.TWO:
                    meshModifier.FillSplineCI2(config.ColorStart, ref mMeshInfo);
                    break;

                case TrailRecordConfig.E_LinePerVertexCount.THREE:
                    meshModifier.FillSplineCI3(config.ColorStart, ref mMeshInfo);
                    break;
                }
            }
            else
            {
                switch (config.ELinePerVertexCount)
                {
                case TrailRecordConfig.E_LinePerVertexCount.TWO:
                    meshModifier.FillSplineI2(ref mMeshInfo);
                    break;

                case TrailRecordConfig.E_LinePerVertexCount.THREE:
                    meshModifier.FillSplineI3(ref mMeshInfo);
                    break;
                }
            }
        }
Beispiel #4
0
        void UpdateMeshObjectWithSpline2(TrailMeshObject tmo, MeshModifier meshModifier, NF.Collections.Generic.LinkedList <LineInfo> records, SplineMeshInfo meshInfo, TrailRecordConfig config)
        {
            int desireRecordFrameCount = Math.Min(records.Count, config.MaxPlayingRecordLength);

            if (desireRecordFrameCount < 2)
            {
                return;
            }

            var line = mSpliner.Refresh(records, desireRecordFrameCount);

            meshModifier.FillSplineVUC2(mSpliner, config.ColorStart, config.ColorEnd, ref meshInfo.mMeshInfo);
            tmo.UpdateMesh(line, 2, ref meshInfo.mMeshInfo);
        }