public void Dispose() { if (CurrentEffect != null) { CurrentEffect.Dispose(); CurrentEffect = null; } if (effectFactory != null) { effectFactory.Dispose(); effectFactory = null; } if (effectSetting != null) { effectSetting.Dispose(); effectSetting = null; } if (EffectRenderer != null) { EffectRenderer.Dispose(); EffectRenderer = null; } }
/// <summary> /// Entlade die Inhalte. Falls das aktuell verwendete Rendereffekt-Objekt in dieser Klasse erstellt werde, dispose es auch hier. /// </summary> public override void UnloadContent(GameTime time) { if (disposeEffect && CurrentEffect != null) { CurrentEffect.Dispose(); CurrentEffect = null; } }
public void Dispose() { if (CurrentEffect != null) { CurrentEffect.Dispose(); CurrentEffect = null; } if (effectFactory != null) { effectFactory.Dispose(); effectFactory = null; } }
/// <summary> /// Lade die Inhalte der Spielwelt. Falls kein Rendereffekt im Konstruktor übergeben wurde, /// wird der Standard-Effekt als zu verwendender Rendereffekt zugewiesen. /// </summary> public override void LoadContent(GameTime time) { if (CurrentEffect == null) { CurrentEffect = DefaultEffect(screen: Screen); disposeEffect = true; RenderEffectLibrary.RenderEffectChanged += (newEffectName, time2) => { if (CurrentEffect != null) { CurrentEffect.Dispose(); } CurrentEffect = RenderEffectLibrary.CreateEffect(screen: Screen, name: newEffectName); }; } }
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; } }
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; } }