public void UpdateViewer() { if (isViewerShown) { if ((IsChanged && (IsPlaying || IsPaused)) || IsRequiredToReload) { if (IsRequiredToReload) { Reload(true); } else { Reload(false); } IsChanged = false; IsRequiredToReload = false; } if (IsPlaying && !IsPaused) { var stepFrame = Manager.NativeManager.GetDeltaSecond() * 60.0f; // regard as 1 frame because of accuracy problem if (Math.Abs(1.0f - stepFrame) < 0.05f) { stepFrame = 1.0f; } // large step is not better than slow stepFrame = Math.Min(stepFrame, 4); StepViewer(stepFrame, true); } // update environment native.SetGroundParameters( Core.Environment.Ground.IsShown.Value, Core.Environment.Ground.Height.Value, Core.Environment.Ground.Extent.Value); native.SetBackgroundColor( (byte)Core.Environment.Background.BackgroundColor.R, (byte)Core.Environment.Background.BackgroundColor.G, (byte)Core.Environment.Background.BackgroundColor.B); native.SetBackgroundImage(Core.Environment.Background.BackgroundImage.AbsolutePath); native.SetGridColor( (byte)Core.Option.GridColor.R, (byte)Core.Option.GridColor.G, (byte)Core.Option.GridColor.B, (byte)Core.Option.GridColor.A); native.SetGridLength( Core.Option.GridLength); native.SetIsGridShown( Core.Option.IsGridShown, Core.Option.IsXYGridShown, Core.Option.IsXZGridShown, Core.Option.IsYZGridShown); native.SetLightDirection( Core.Environment.Lighting.LightDirection.X, Core.Environment.Lighting.LightDirection.Y, Core.Environment.Lighting.LightDirection.Z); native.SetLightColor( (byte)Core.Environment.Lighting.LightColor.R, (byte)Core.Environment.Lighting.LightColor.G, (byte)Core.Environment.Lighting.LightColor.B, (byte)Core.Environment.Lighting.LightColor.A); native.SetLightAmbientColor( (byte)Core.Environment.Lighting.LightAmbientColor.R, (byte)Core.Environment.Lighting.LightAmbientColor.G, (byte)Core.Environment.Lighting.LightAmbientColor.B, (byte)Core.Environment.Lighting.LightAmbientColor.A); ViewPointController.SetMouseInverseFlag( Core.Option.MouseRotInvX, Core.Option.MouseRotInvY, Core.Option.MouseSlideInvX, Core.Option.MouseSlideInvY); if (Core.Culling.Type.Value == Data.EffectCullingValues.ParamaterType.Sphere) { native.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) { native.SetCullingParameter(false, 0.0f, 0.0f, 0.0f, 0.0f); } } else { System.Threading.Thread.Sleep(1); } }
public void UpdateViewer() { if (isViewerShown) { if ((IsChanged && (IsPlaying || IsPaused)) || IsRequiredToReload) { if (IsRequiredToReload) { Reload(true); } else { Reload(false); } IsChanged = false; IsRequiredToReload = false; } if (IsPlaying && !IsPaused) { var stepFrame = Manager.NativeManager.GetDeltaSecond() * 60.0f; // regard as 1 frame because of accuracy problem if (Math.Abs(1.0f - stepFrame) < 0.05f) { stepFrame = 1.0f; } // large step is not better than slow stepFrame = Math.Min(stepFrame, 4); StepViewer(stepFrame, true); } // update environment var renderParam = EffectRenderer.GetParameter(); renderParam.IsGroundShown = Core.Environment.Ground.IsShown.Value; renderParam.GroundHeight = Core.Environment.Ground.Height.Value; renderParam.GroundExtent = Core.Environment.Ground.Extent.Value; renderParam.BackgroundColor = new swig.Color { R = (byte)Core.Environment.Background.BackgroundColor.R, G = (byte)Core.Environment.Background.BackgroundColor.G, B = (byte)Core.Environment.Background.BackgroundColor.B, A = 255, }; renderParam.LightDirection = new swig.Vector3F { X = Core.Environment.Lighting.LightDirection.X, Y = Core.Environment.Lighting.LightDirection.Y, Z = Core.Environment.Lighting.LightDirection.Z, }; renderParam.LightColor = new swig.Color { R = (byte)Core.Environment.Lighting.LightColor.R, G = (byte)Core.Environment.Lighting.LightColor.G, B = (byte)Core.Environment.Lighting.LightColor.B, A = (byte)Core.Environment.Lighting.LightColor.A }; renderParam.LightAmbientColor = new swig.Color { R = (byte)Core.Environment.Lighting.LightAmbientColor.R, G = (byte)Core.Environment.Lighting.LightAmbientColor.G, B = (byte)Core.Environment.Lighting.LightAmbientColor.B, A = (byte)Core.Environment.Lighting.LightAmbientColor.A }; renderParam.Distortion = (swig.DistortionType)(int) Core.Option.DistortionType.Value; renderParam.RenderingMethod = (swig.RenderingMethodType)(int) Core.Option.RenderingMode.Value; EffectRenderer.SetParameter(renderParam); EffectRenderer.LoadBackgroundImage(Core.Environment.Background.BackgroundImage.AbsolutePath); EffectRenderer.GridColor = new swig.Color { R = (byte)Core.Option.GridColor.R, G = (byte)Core.Option.GridColor.G, B = (byte)Core.Option.GridColor.B, A = (byte)Core.Option.GridColor.A }; EffectRenderer.GridLength = Core.Option.GridLength; EffectRenderer.IsGridShown = Core.Option.IsGridShown; EffectRenderer.IsGridXYShown = Core.Option.IsXYGridShown; EffectRenderer.IsGridXZShown = Core.Option.IsXZGridShown; EffectRenderer.IsGridYZShown = Core.Option.IsYZGridShown; if (Core.Culling.Type.Value == Data.EffectCullingValues.ParamaterType.Sphere) { EffectRenderer.IsCullingShown = true; EffectRenderer.CullingRadius = Core.Culling.Sphere.Radius.Value; EffectRenderer.CullingPosition.X = Core.Culling.Sphere.Location.X; EffectRenderer.CullingPosition.Y = Core.Culling.Sphere.Location.Y; EffectRenderer.CullingPosition.Z = Core.Culling.Sphere.Location.Z; } else if (Core.Culling.Type.Value == Data.EffectCullingValues.ParamaterType.None) { EffectRenderer.IsCullingShown = false; EffectRenderer.CullingRadius = 0.0f; EffectRenderer.CullingPosition.X = 0.0f; EffectRenderer.CullingPosition.Y = 0.0f; EffectRenderer.CullingPosition.Z = 0.0f; } ViewPointController.SetMouseInverseFlag( Core.Option.MouseRotInvX, Core.Option.MouseRotInvY, Core.Option.MouseSlideInvX, Core.Option.MouseSlideInvY); } else { System.Threading.Thread.Sleep(1); } }