Esempio n. 1
0
		internal protected virtual void OnEnterState()
		{
			this.RestoreActiveLayers();
			this.RestoreObjectVisibility();

			// Create re-usable render passes for editor gizmos
			this.camPassBg = new Camera.Pass();
			this.camPassBg.MatrixMode = RenderMatrix.OrthoScreen;
			this.camPassBg.ClearFlags = ClearFlag.None;
			this.camPassBg.VisibilityMask = VisibilityFlag.ScreenOverlay;
			this.camPassEdWorld = new Camera.Pass();
			this.camPassEdWorld.ClearFlags = ClearFlag.None;
			this.camPassEdWorld.VisibilityMask = VisibilityFlag.None;
			this.camPassEdScreen = new Camera.Pass();
			this.camPassEdScreen.MatrixMode = RenderMatrix.OrthoScreen;
			this.camPassEdScreen.ClearFlags = ClearFlag.None;
			this.camPassEdScreen.VisibilityMask = VisibilityFlag.ScreenOverlay;

			this.camPassBg.CollectDrawcalls			+= this.camPassBg_CollectDrawcalls;
			this.camPassEdWorld.CollectDrawcalls	+= this.camPassEdWorld_CollectDrawcalls;
			this.camPassEdScreen.CollectDrawcalls	+= this.camPassEdScreen_CollectDrawcalls;

			Control control = this.RenderableSite.Control;
			control.Paint		+= this.RenderableControl_Paint;
			control.MouseDown	+= this.RenderableControl_MouseDown;
			control.MouseUp		+= this.RenderableControl_MouseUp;
			control.MouseMove	+= this.RenderableControl_MouseMove;
			control.MouseWheel	+= this.RenderableControl_MouseWheel;
			control.MouseLeave	+= this.RenderableControl_MouseLeave;
			control.KeyDown		+= this.RenderableControl_KeyDown;
			control.KeyUp		+= this.RenderableControl_KeyUp;
			control.GotFocus	+= this.RenderableControl_GotFocus;
			control.LostFocus	+= this.RenderableControl_LostFocus;
			control.DragDrop	+= this.RenderableControl_DragDrop;
			control.DragEnter	+= this.RenderableControl_DragEnter;
			control.DragLeave	+= this.RenderableControl_DragLeave;
			control.DragOver	+= this.RenderableControl_DragOver;
			control.Resize		+= this.RenderableControl_Resize;
			this.View.PerspectiveChanged	+= this.View_FocusDistChanged;
			this.View.CurrentCameraChanged	+= this.View_CurrentCameraChanged;
			DualityEditorApp.UpdatingEngine += this.DualityEditorApp_UpdatingEngine;
			DualityEditorApp.ObjectPropertyChanged += this.DualityEditorApp_ObjectPropertyChanged;

			Scene.Leaving += this.Scene_Changed;
			Scene.Entered += this.Scene_Changed;
			Scene.GameObjectParentChanged += this.Scene_Changed;
			Scene.GameObjectAdded += this.Scene_Changed;
			Scene.GameObjectRemoved += this.Scene_Changed;
			Scene.ComponentAdded += this.Scene_Changed;
			Scene.ComponentRemoving += this.Scene_Changed;

			if (Scene.Current != null) this.Scene_Changed(this, EventArgs.Empty);
			
			// Initial Camera update
			this.OnCurrentCameraChanged(new CamView.CameraChangedEventArgs(null, this.CameraComponent));
			this.UpdateFormattedTextRenderers();
		}
Esempio n. 2
0
        /// <summary>
        /// Called when the <see cref="CamViewState"/> is entered.
        /// Use this for overall initialization of the state.
        /// </summary>
        protected internal virtual void OnEnterState()
        {
            this.RestoreActiveLayers();
            this.RestoreObjectVisibility();

            // Create re-usable render passes for editor gizmos
            {
                // A screen overlay that is rendered behind all following gizmos.
                // This is used for the "background plate" to grey out or darken
                // the actual rendered world in order to make custom gizmos more visible.
                this.camPassBg = new Camera.Pass();
                this.camPassBg.MatrixMode = RenderMatrix.OrthoScreen;
                this.camPassBg.ClearFlags = ClearFlag.None;
                this.camPassBg.VisibilityMask = VisibilityFlag.ScreenOverlay;

                // An in-world rendering step that can make use of the existing depth
                // buffer values, so gizmos can interact with actual world geometry.
                this.camPassEdWorld = new Camera.Pass();
                this.camPassEdWorld.ClearFlags = ClearFlag.None;
                this.camPassEdWorld.VisibilityMask = VisibilityFlag.None;

                // An in-world rendering step where the depth buffer has been cleared.
                // This allows to render gizmos in world coordinates that can occlude
                // each other, while not interacting with world geometry or previously
                // rendered gizmos.
                this.camPassEdWorldNoDepth = new Camera.Pass();
                this.camPassEdWorldNoDepth.ClearFlags = ClearFlag.Depth;
                this.camPassEdWorldNoDepth.VisibilityMask = VisibilityFlag.None;

                // The final screen overlay rendering step after all gizmos have been
                // rendered. This is ideal for most text / status overlays, as well as
                // direct cursor feedback.
                this.camPassEdScreen = new Camera.Pass();
                this.camPassEdScreen.MatrixMode = RenderMatrix.OrthoScreen;
                this.camPassEdScreen.ClearFlags = ClearFlag.None;
                this.camPassEdScreen.VisibilityMask = VisibilityFlag.ScreenOverlay;
            }

            this.camPassBg.CollectDrawcalls             += this.camPassBg_CollectDrawcalls;
            this.camPassEdWorld.CollectDrawcalls        += this.camPassEdWorld_CollectDrawcalls;
            this.camPassEdWorldNoDepth.CollectDrawcalls	+= this.camPassEdWorldNoDepth_CollectDrawcalls;
            this.camPassEdScreen.CollectDrawcalls       += this.camPassEdScreen_CollectDrawcalls;

            Control control = this.RenderableSite.Control;
            control.Paint		+= this.RenderableControl_Paint;
            control.MouseDown	+= this.RenderableControl_MouseDown;
            control.MouseUp		+= this.RenderableControl_MouseUp;
            control.MouseMove	+= this.RenderableControl_MouseMove;
            control.MouseWheel	+= this.RenderableControl_MouseWheel;
            control.MouseLeave	+= this.RenderableControl_MouseLeave;
            control.KeyDown		+= this.RenderableControl_KeyDown;
            control.KeyUp		+= this.RenderableControl_KeyUp;
            control.GotFocus	+= this.RenderableControl_GotFocus;
            control.LostFocus	+= this.RenderableControl_LostFocus;
            control.DragDrop	+= this.RenderableControl_DragDrop;
            control.DragEnter	+= this.RenderableControl_DragEnter;
            control.DragLeave	+= this.RenderableControl_DragLeave;
            control.DragOver	+= this.RenderableControl_DragOver;
            control.Resize		+= this.RenderableControl_Resize;
            this.View.PerspectiveChanged	+= this.View_FocusDistChanged;
            this.View.CurrentCameraChanged	+= this.View_CurrentCameraChanged;
            DualityEditorApp.UpdatingEngine += this.DualityEditorApp_UpdatingEngine;
            DualityEditorApp.ObjectPropertyChanged += this.DualityEditorApp_ObjectPropertyChanged;

            Scene.Leaving += this.Scene_Changed;
            Scene.Entered += this.Scene_Changed;
            Scene.GameObjectParentChanged += this.Scene_Changed;
            Scene.GameObjectAdded += this.Scene_Changed;
            Scene.GameObjectRemoved += this.Scene_Changed;
            Scene.ComponentAdded += this.Scene_Changed;
            Scene.ComponentRemoving += this.Scene_Changed;

            if (Scene.Current != null) this.Scene_Changed(this, EventArgs.Empty);

            // Initial Camera update
            this.OnCurrentCameraChanged(new CamView.CameraChangedEventArgs(null, this.CameraComponent));
            this.UpdateFormattedTextRenderers();

            if (this.IsViewVisible)
                this.OnShown();
        }