Exemple #1
0
 public void createOneWindow()
 {
     sceneViewController.closeAllWindows();
     sceneViewController.createWindow("Camera 1", Vector3.Backward * DefaultOrbitDistance, Vector3.Zero, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);
 }
        public static void createFromPresets(this SceneViewController controller, SceneViewWindowPresetSet presets, bool keepOldSettings = true)
        {
            //Capture current window configuration info
            List <Bookmark> currentWindowConfig = new List <Bookmark>();

            if (keepOldSettings)
            {
                SceneViewWindow activeWindow = controller.ActiveWindow;
                if (activeWindow != null)
                {
                    TransparencyController.ActiveTransparencyState = activeWindow.CurrentTransparencyState;
                    LayerState layerState = new LayerState();
                    layerState.captureState();
                    currentWindowConfig.Add(new Bookmark("", activeWindow.Translation, activeWindow.LookAt, layerState));
                }
                foreach (MDISceneViewWindow window in controller.MdiWindows)
                {
                    if (window != activeWindow)
                    {
                        TransparencyController.ActiveTransparencyState = window.CurrentTransparencyState;
                        LayerState layerState = new LayerState();
                        layerState.captureState();
                        currentWindowConfig.Add(new Bookmark("", window.Translation, window.LookAt, layerState));
                    }
                }
            }

            //Create windows
            int windowIndex = 0;
            int zOrder      = 100;
            int zOrderInc   = 10;

            controller.closeAllWindows();
            MDISceneViewWindow camera;
            MDISceneViewWindow toSelect = null;

            foreach (SceneViewWindowPreset preset in presets.getPresetEnum())
            {
                if (windowIndex < currentWindowConfig.Count)
                {
                    Bookmark bmk = currentWindowConfig[windowIndex++];
                    camera = controller.createWindow(preset.Name, bmk.CameraPosition.Translation, bmk.CameraPosition.LookAt, preset.BoundMin, preset.BoundMax, preset.OrbitMinDistance, preset.OrbitMaxDistance, zOrder, controller.findWindow(preset.ParentWindow), preset.WindowPosition);
                    TransparencyController.ActiveTransparencyState = camera.CurrentTransparencyState;
                    bmk.Layers.instantlyApply();
                }
                else
                {
                    camera = controller.createWindow(preset.Name, preset.Position, preset.LookAt, preset.BoundMin, preset.BoundMax, preset.OrbitMinDistance, preset.OrbitMaxDistance, zOrder, controller.findWindow(preset.ParentWindow), preset.WindowPosition);
                    Bookmark bmk = null;
                    if (BookmarksController != null)
                    {
                        bmk = BookmarksController.loadBookmark(String.Format("Cameras/{0}.bmk", camera.CurrentTransparencyState));

                        if (bmk != null)
                        {
                            camera.setPosition(bmk.CameraPosition, 0.0f);
                            TransparencyController.ActiveTransparencyState = camera.CurrentTransparencyState;
                            bmk.Layers.instantlyApply();
                        }
                    }
                }
                if (toSelect == null)
                {
                    toSelect = camera;
                }
                zOrder += zOrderInc;
            }
            if (toSelect != null)
            {
                controller.setActiveMdiWindow(toSelect);
            }
        }