예제 #1
0
 public bool LoadEffect(IntPtr data, int size, string path)
 {
     return(native.LoadEffect(data, size, path));
 }
예제 #2
0
        unsafe void Export()
        {
            Manager.Viewer.SetDynamicInput(
                Core.Dynamic.Inputs.Values[0].Input.Value,
                Core.Dynamic.Inputs.Values[1].Input.Value,
                Core.Dynamic.Inputs.Values[2].Input.Value,
                Core.Dynamic.Inputs.Values[3].Input.Value);

            SetLotationVelocity(
                Core.EffectBehavior.LocationVelocity.X,
                Core.EffectBehavior.LocationVelocity.Y,
                Core.EffectBehavior.LocationVelocity.Z);

            SetRotationVelocity(
                Core.EffectBehavior.RotationVelocity.X / 180.0f * 3.141592f,
                Core.EffectBehavior.RotationVelocity.Y / 180.0f * 3.141592f,
                Core.EffectBehavior.RotationVelocity.Z / 180.0f * 3.141592f);

            SetScaleVelocity(
                Core.EffectBehavior.ScaleVelocity.X,
                Core.EffectBehavior.ScaleVelocity.Y,
                Core.EffectBehavior.ScaleVelocity.Z);

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

            SetLotation(
                Core.EffectBehavior.Location.X,
                Core.EffectBehavior.Location.Y,
                Core.EffectBehavior.Location.Z);

            SetRotation(
                Core.EffectBehavior.Rotation.X / 180.0f * 3.141592f,
                Core.EffectBehavior.Rotation.Y / 180.0f * 3.141592f,
                Core.EffectBehavior.Rotation.Z / 180.0f * 3.141592f);

            SetScale(
                Core.EffectBehavior.Scale.X,
                Core.EffectBehavior.Scale.Y,
                Core.EffectBehavior.Scale.Z);

            SetTargetLocation(
                Core.EffectBehavior.TargetLocation.X,
                Core.EffectBehavior.TargetLocation.Y,
                Core.EffectBehavior.TargetLocation.Z);

            SetEffectCount(
                Core.EffectBehavior.CountX,
                Core.EffectBehavior.CountY,
                Core.EffectBehavior.CountZ);

            SetAllColor(
                (byte)Core.EffectBehavior.ColorAll.R,
                (byte)Core.EffectBehavior.ColorAll.G,
                (byte)Core.EffectBehavior.ColorAll.B,
                (byte)Core.EffectBehavior.ColorAll.A);

            var behavior = native.GetEffectBehavior();

            behavior.PlaybackSpeed = Core.EffectBehavior.PlaybackSpeed.Value;
            native.SetViewerEffectBehavior(behavior);

            SetEffectTimeSpan(Core.EffectBehavior.TimeSpan);

            SetEffectDistance(Core.EffectBehavior.Distance);

            SetBackgroundColor(
                (byte)Core.Environment.Background.BackgroundColor.R,
                (byte)Core.Environment.Background.BackgroundColor.G,
                (byte)Core.Environment.Background.BackgroundColor.B);

            SetGridLength(
                Core.Option.GridLength);

            SetStep((int)Core.Option.FPS.Value);
            SetIsRightHand(Core.Option.Coordinate.Value == Data.OptionValues.CoordinateType.Right);

            SetDistortionType((int)Core.Option.DistortionType.Value);
            SetRenderMode((int)Core.Option.RenderingMode.Value);

            if (Core.Culling.Type.Value == Data.EffectCullingValues.ParamaterType.Sphere)
            {
                SetCullingParameter(Core.Culling.IsShown, Core.Culling.Sphere.Radius.Value, Core.Culling.Sphere.Location.X, Core.Culling.Sphere.Location.Y, Core.Culling.Sphere.Location.Z);
            }
            else if (Core.Culling.Type.Value == Data.EffectCullingValues.ParamaterType.None)
            {
                SetCullingParameter(false, 0.0f, 0.0f, 0.0f, 0.0f);
            }

            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);

                native.LoadEffect(newEffect);

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

                CurrentEffect = newEffect;
            }
        }