Esempio n. 1
0
        public void CreateTrail()
        {
            if (_customTrail.PointStart == null || _customTrail.PointEnd == null)
            {
                Debug.LogWarning("Secondary trail on saber doesn't seem to have a positional transform");
                return;
            }

            var trailInitData = new TrailInitData
            {
                TrailColor             = Color.white,
                TrailLength            = _customTrail.Length,
                Whitestep              = 0,
                Granularity            = 60,
                SamplingFrequency      = 80,
                SamplingStepMultiplier = 1,
            };

            TrailInstance.Setup(
                trailInitData,
                _customTrail.PointStart,
                _customTrail.PointEnd,
                _customTrail.TrailMaterial
                );

            _canColorMaterial = IsMaterialColorable(_customTrail.TrailMaterial);
        }
Esempio n. 2
0
        public void Setup(TrailInitData initData, Transform pointStart, Transform pointEnd, Material material, bool editor)
        {
            PointStart        = pointStart;
            PointEnd          = pointEnd;
            Material          = material;
            Granularity       = initData.Granularity;
            TrailLength       = initData.TrailLength;
            Whitestep         = initData.Whitestep;
            SamplingFrequency = initData.SamplingFrequency;

            gameObject.layer = 12;
            if (editor)
            {
                SortingOrder = 3;
            }

            _elemPool      = new ElementPool(TrailLength);
            _vertexPool    = new VertexPool(Material, this);
            _vertexSegment = _vertexPool.GetVertices(Granularity * 3, (Granularity - 1) * 12);
            UpdateIndices();

            _vertexPool.SetMeshObjectActive(false);

            _inited = true;
        }
Esempio n. 3
0
        public void CreateTrail(TrailConfig trailConfig)
        {
            if (_instanceTrailData is null)
            {
                if (_backupTrail is null)
                {
                    return;
                }

                var trailStart = TrailInstance.gameObject.CreateGameObject("Trail Start");
                var trailEnd   = TrailInstance.gameObject.CreateGameObject("TrailEnd");
                trailEnd.transform.localPosition = new Vector3(0, 0, 1);

                var trailRenderer = _backupTrail.GetField <SaberTrailRenderer, SaberTrail>("_trailRendererPrefab");

                var material = trailRenderer.GetField <MeshRenderer, SaberTrailRenderer>("_meshRenderer").material;

                var trailInitDataVanilla = new TrailInitData
                {
                    TrailColor  = Color.white,
                    TrailLength = 15,
                    Whitestep   = 0.02f,
                    Granularity = trailConfig.Granularity
                };

                TrailInstance.Setup(trailInitDataVanilla, trailStart.transform, trailEnd.transform, material);
                return;
            }

            var trailInitData = new TrailInitData
            {
                TrailColor  = Color.white,
                TrailLength = _instanceTrailData.Length,
                Whitestep   = _instanceTrailData.WhiteStep,
                Granularity = trailConfig.Granularity
            };

            Transform pointStart = _instanceTrailData.IsTrailReversed
                ? _instanceTrailData.PointEnd
                : _instanceTrailData.PointStart;

            Transform pointEnd = _instanceTrailData.IsTrailReversed
                ? _instanceTrailData.PointStart
                : _instanceTrailData.PointEnd;

            if (pointStart == null || pointEnd == null)
            {
                Debug.LogWarning("Primary trail on saber doesn't seem to have a positional transform");
                return;
            }

            TrailInstance.Setup(
                trailInitData,
                pointStart,
                pointEnd,
                _instanceTrailData.Material.Material
                );

            _canColorMaterial = IsMaterialColorable(_instanceTrailData.Material.Material);
        }
Esempio n. 4
0
        public void Setup(TrailInitData initData, Transform pointStart, Transform pointEnd, Material material)
        {
            PointStart  = pointStart;
            PointEnd    = pointEnd;
            MyMaterial  = material;
            Granularity = initData.Granularity;
            TrailLength = initData.TrailLength;
            Whitestep   = initData.Whitestep;

            _elemPool      = new ElementPool(TrailLength);
            _trailWidth    = (PointStart.position - PointEnd.position).magnitude;
            _vertexPool    = new VertexPool(MyMaterial, this);
            _vertexSegment = _vertexPool.GetVertices(Granularity * 3, (Granularity - 1) * 12);
            UpdateIndices();

            _vertexPool.SetMeshObjectActive(false);

            _inited = true;
        }
Esempio n. 5
0
        public void CreateTrail(TrailConfig trailConfig, bool editor)
        {
            if (_customTrail.PointStart == null || _customTrail.PointEnd == null)
            {
                Debug.LogWarning("Secondary trail on saber doesn't seem to have a positional transform");
                return;
            }

            if (_customTrail.Length < 1)
            {
                return;
            }

            var trailInitData = new TrailInitData
            {
                TrailColor             = Color.white,
                TrailLength            = _customTrail.Length,
                Whitestep              = 0,
                Granularity            = 60,
                SamplingFrequency      = 80,
                SamplingStepMultiplier = 1
            };

            TrailInstance.Setup(
                trailInitData,
                _customTrail.PointStart,
                _customTrail.PointEnd,
                _customTrail.TrailMaterial,
                editor
                );

            if (!trailConfig.OnlyUseVertexColor)
            {
                _canColorMaterial = MaterialHelpers.IsMaterialColorable(_customTrail.TrailMaterial);
            }
        }
        public void CreateTrail(TrailConfig trailConfig, bool editor)
        {
            if (InstanceTrailData is null)
            {
                if (_backupTrail is null)
                {
                    return;
                }

                var trailStart = TrailInstance.gameObject.CreateGameObject("Trail StartNew");
                var trailEnd   = TrailInstance.gameObject.CreateGameObject("TrailEnd");
                trailEnd.transform.localPosition = new Vector3(0, 0, 1);

                var trailRenderer = _backupTrail.GetField <SaberTrailRenderer, SaberTrail>("_trailRendererPrefab");

                var material = trailRenderer.GetField <MeshRenderer, SaberTrailRenderer>("_meshRenderer").material;

                var trailInitDataVanilla = new TrailInitData
                {
                    TrailColor  = Color.white,
                    TrailLength = 15,
                    Whitestep   = 0.02f,
                    Granularity = trailConfig.Granularity
                };

                TrailInstance.Setup(trailInitDataVanilla, trailStart.transform, trailEnd.transform, material, editor);
                return;
            }

            if (InstanceTrailData.Length < 1)
            {
                return;
            }

            var trailInitData = new TrailInitData
            {
                TrailColor  = Color.white,
                TrailLength = InstanceTrailData.Length,
                Whitestep   = InstanceTrailData.WhiteStep,
                Granularity = trailConfig.Granularity
            };

            var(pointStart, pointEnd) = InstanceTrailData.GetPoints();

            if (pointStart == null || pointEnd == null)
            {
                Debug.LogWarning("Primary trail on saber doesn't seem to have a positional transform");
                return;
            }

            TrailInstance.Setup(
                trailInitData,
                pointStart,
                pointEnd,
                InstanceTrailData.Material.Material,
                editor
                );

            if (!trailConfig.OnlyUseVertexColor)
            {
                _canColorMaterial = MaterialHelpers.IsMaterialColorable(InstanceTrailData.Material.Material);
            }
        }
Esempio n. 7
0
        public void CreateTrail(TrailConfig trailConfig)
        {
            if (_instanceTrailData is null)
            {
                if (_backupTrail is null)
                {
                    return;
                }

                var trailStart = TrailInstance.gameObject.CreateGameObject("Trail Start");
                var trailEnd   = TrailInstance.gameObject.CreateGameObject("TrailEnd");
                trailEnd.transform.localPosition = new Vector3(0, 0, 1);

                var trailRenderer = _backupTrail.GetField <SaberTrailRenderer, SaberTrail>("_trailRendererPrefab");

                var material = trailRenderer.GetField <MeshRenderer, SaberTrailRenderer>("_meshRenderer").material;

                var trailInitDataVanilla = new TrailInitData
                {
                    TrailColor             = Color.white,
                    TrailLength            = 15,
                    Whitestep              = 0.02f,
                    Granularity            = trailConfig.Granularity,
                    SamplingFrequency      = trailConfig.SamplingFrequency,
                    SamplingStepMultiplier = _samplingStepMultiplier
                };

                TrailInstance.Setup(
                    trailInitDataVanilla,
                    material,
                    trailStart.transform,
                    trailEnd.transform
                    );
                return;
            }

            var trailInitData = new TrailInitData
            {
                TrailColor             = Color.white,
                TrailLength            = _instanceTrailData.Length,
                Whitestep              = _instanceTrailData.WhiteStep,
                Granularity            = trailConfig.Granularity,
                SamplingFrequency      = trailConfig.SamplingFrequency,
                SamplingStepMultiplier = _samplingStepMultiplier,
            };

            Transform pointStart = _instanceTrailData.IsTrailReversed
                ? _instanceTrailData.PointEnd
                : _instanceTrailData.PointStart;

            Transform pointEnd = _instanceTrailData.IsTrailReversed
                ? _instanceTrailData.PointStart
                : _instanceTrailData.PointEnd;

            TrailInstance.Setup(
                trailInitData,
                _instanceTrailData.Material.Material,
                pointStart,
                pointEnd
                );

            _canColorMaterial = IsMaterialColorable(_instanceTrailData.Material.Material);
        }