Ejemplo n.º 1
0
        public bool LoadEffectFunc()
        {
            StopViewer();

            EffectRenderer.SetEffect(null);
            EffectRenderer.ResetEffect();

            Export();

            IsChanged = false;

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// reload an effect including resources
        /// </summary>
        public unsafe void Reload(bool isResourceReloaded)
        {
            if (isResourceReloaded)
            {
                effectFactory.ReloadAllResources();
            }

            EffectRenderer.SetEffect(null);
            EffectRenderer.ResetEffect();

            Export();

            EffectRenderer.RandomSeed = random_seed;
            EffectRenderer.PlayEffect();
            StepEffectFrame((int)Current);
        }
Ejemplo n.º 3
0
        unsafe void PlayNew()
        {
            EffectRenderer.ResetEffect();

            if (IsChanged)
            {
                EffectRenderer.SetEffect(null);
                EffectRenderer.ResetEffect();

                Export();

                IsChanged = false;
            }

            RenewRandomSeed();
            EffectRenderer.PlayEffect();
            IsPlaying = true;

            if (Core.StartFrame > 0)
            {
                StepEffectFrame(Core.StartFrame);
            }
            current = Core.StartFrame;
        }
Ejemplo n.º 4
0
        unsafe void Export()
        {
            var behavior = EffectRenderer.GetBehavior();

            behavior.DynamicInput1 = Core.Dynamic.Inputs.Values[0].Input.Value;
            behavior.DynamicInput2 = Core.Dynamic.Inputs.Values[1].Input.Value;
            behavior.DynamicInput3 = Core.Dynamic.Inputs.Values[2].Input.Value;
            behavior.DynamicInput4 = Core.Dynamic.Inputs.Values[3].Input.Value;

            behavior.PositionVelocityX = Core.EffectBehavior.LocationVelocity.X;
            behavior.PositionVelocityY = Core.EffectBehavior.LocationVelocity.Y;
            behavior.PositionVelocityZ = Core.EffectBehavior.LocationVelocity.Z;

            behavior.RotationVelocityX = Core.EffectBehavior.RotationVelocity.X / 180.0f * 3.141592f;
            behavior.RotationVelocityY = Core.EffectBehavior.RotationVelocity.Y / 180.0f * 3.141592f;
            behavior.RotationVelocityZ = Core.EffectBehavior.RotationVelocity.Z / 180.0f * 3.141592f;

            behavior.ScaleVelocityX = Core.EffectBehavior.ScaleVelocity.X;
            behavior.ScaleVelocityY = Core.EffectBehavior.ScaleVelocity.Y;
            behavior.ScaleVelocityZ = Core.EffectBehavior.ScaleVelocity.Z;

            if (Core.EffectBehavior.RemovedTime.Infinite.Value)
            {
                behavior.RemovedTime = int.MaxValue;
            }
            else
            {
                behavior.RemovedTime = Core.EffectBehavior.RemovedTime.Value;
            }

            behavior.PositionX = Core.EffectBehavior.Location.X;
            behavior.PositionY = Core.EffectBehavior.Location.Y;
            behavior.PositionZ = Core.EffectBehavior.Location.Z;

            behavior.RotationX = Core.EffectBehavior.Rotation.X / 180.0f * 3.141592f;
            behavior.RotationY = Core.EffectBehavior.Rotation.Y / 180.0f * 3.141592f;
            behavior.RotationZ = Core.EffectBehavior.Rotation.Z / 180.0f * 3.141592f;

            behavior.ScaleX = Core.EffectBehavior.Scale.X;
            behavior.ScaleY = Core.EffectBehavior.Scale.Y;
            behavior.ScaleZ = Core.EffectBehavior.Scale.Z;

            behavior.TargetPositionX = Core.EffectBehavior.TargetLocation.X;
            behavior.TargetPositionY = Core.EffectBehavior.TargetLocation.Y;
            behavior.TargetPositionZ = Core.EffectBehavior.TargetLocation.Z;

            behavior.CountX = Core.EffectBehavior.CountX;
            behavior.CountY = Core.EffectBehavior.CountY;
            behavior.CountZ = Core.EffectBehavior.CountZ;

            behavior.AllColorR = (byte)Core.EffectBehavior.ColorAll.R;
            behavior.AllColorG = (byte)Core.EffectBehavior.ColorAll.G;
            behavior.AllColorB = (byte)Core.EffectBehavior.ColorAll.B;
            behavior.AllColorA = (byte)Core.EffectBehavior.ColorAll.A;

            behavior.PlaybackSpeed = Core.EffectBehavior.PlaybackSpeed.Value;

            behavior.TimeSpan = Core.EffectBehavior.TimeSpan;
            behavior.Distance = Core.EffectBehavior.Distance;

            EffectRenderer.SetBehavior(behavior);

            EffectRenderer.SetStep((int)Core.Option.FPS.Value);

            effectSetting.SetCoordinateSyatem(
                Core.Option.Coordinate.Value == Data.OptionValues.CoordinateType.Right ? swig.CoordinateSystemType.RH : swig.CoordinateSystemType.LH);

            var binaryExporter = new Binary.Exporter();
            var data           = binaryExporter.Export(Core.Root, Core.Option.Magnification);
            var path           = Utils.Misc.BackSlashToSlash(Core.Root.GetFullPath());

            fixed(byte *p = &data[0])
            {
                var newEffect = effectFactory.LoadEffect(new IntPtr(p), data.Length, path);

                EffectRenderer.SetEffect(newEffect);

                if (CurrentEffect != null)
                {
                    CurrentEffect.Dispose();
                }

                CurrentEffect = newEffect;
            }
        }