Пример #1
0
 private void BrokerToScene(ConsoleKey key, Action a, ConsoleModifiers?modifiers = null)
 {
     FocusManager.GlobalKeyHandlers.PushForLifetime(key, modifiers, () =>
     {
         PreviewScene.QueueAction(a);
     }, LifetimeManager);
 }
Пример #2
0
        private void LoadLevel(string levelFile)
        {
            var level = LevelDefinition.Load(levelFile);

            this.CurrentLevelDefinition = level;

            PreviewScene.QueueAction(() =>
            {
                foreach (var thing in PreviewScene.Things.ToArray())
                {
                    if (thing is Cursor)
                    {
                        continue;
                    }
                    PreviewScene.Remove(thing);
                }

                foreach (var interaction in PreviewScene.Interactions.ToArray())
                {
                    PreviewScene.Remove(interaction);
                }

                level.Hydrate(PreviewScene, true);
            });
        }
 private void OnViewPortLoaded(object sender, RoutedEventArgs e)
 {
     if (m_bWorldLoaded && !PreviewScene.IsCreated)
     {
         IRenderSurface renderSurface = m_viewPortControl.GetRenderSurface();
         PreviewScene.EditorThread_CreateScene(renderSurface, EInputClass.AssetPreview);
         Input.SetInputClassActive(EInputClass.AssetPreview, IsActive);
     }
 }
        public override void PostWorldLoad()
        {
            base.PostWorldLoad();

            m_bWorldLoaded = true;
            if (m_viewPortControl.IsLoaded && !PreviewScene.IsCreated)
            {
                IRenderSurface renderSurface = m_viewPortControl.GetRenderSurface();
                PreviewScene.EditorThread_CreateScene(renderSurface, EInputClass.AssetPreview);
                Input.SetInputClassActive(EInputClass.AssetPreview, IsActive);
            }
        }
        public void OnTargetAssetChanged()
        {
            MaterialName = m_targetMaterialAsset.Name;
            PreviewScene previewScene = CWorkspace.Instance.GetTool <CAssetPreviewerViewModel>().PreviewScene;

            CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () =>
            {
                m_targetMaterial = CRenderer.Instance.ResourceManager.RequestResourceFromAsset <CMaterial>(m_targetMaterialAsset);
                previewScene.ShowMeshSelection = true;
                previewScene.EngineThread_SetLastDefaultMesh(false);
                previewScene.EngineThread_SetPreviewMeshMaterial(m_targetMaterial);
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)WaitTargetMaterialLoaded);
            });
        }
Пример #6
0
        private static PreviewScene GetOrCreateScene(ConstructedMeshInfo obj, RenderContext rc)
        {
            if (s_validContext != rc)
            {
                s_validContext = rc;
                _previewScenes = new ConditionalWeakTable <ConstructedMeshInfo, PreviewScene>();
            }

            PreviewScene scene;

            if (!_previewScenes.TryGetValue(obj, out scene))
            {
                scene = new PreviewScene(rc, obj);
                _previewScenes.Add(obj, scene);
            }

            return(scene);
        }
Пример #7
0
    private void Awake()
    {
        previewScene = new PreviewScene("preview scene");
        previewScene.camera.clearFlags         = CameraClearFlags.SolidColor;
        previewScene.camera.transform.position = new Vector3(0, 0, -10);
        previewScene.camera.backgroundColor    = Color.grey;

        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);

        go.transform.position = Vector3.zero;
        previewScene.AddGameObject(go);

        GameObject light = new GameObject("light", typeof(Light));

        previewScene.AddGameObject(light);
        Light Light1 = light.GetComponent <Light>();

        Light1.transform.rotation = Quaternion.Euler(340, 218, 177);
        Light1.color = new Color(.4f, .4f, .45f, 0f) * .7f;

        previwRT = new RenderTexture((int)position.width, (int)position.height - 30, 24, RenderTextureFormat.ARGBHalf);
    }
Пример #8
0
        public LevelBuilder()
        {
            Cursor    = new Cursor();
            UndoStack = new UndoRedoStack();
            var topPanel = LayoutRoot.Add(new ConsolePanel()
            {
                Background = System.ConsoleColor.Black
            }).Fill(padding: new Thickness(0, 0, 0, 6));
            var botPanel = LayoutRoot.Add(new ConsolePanel()
            {
                Height = 6, Background = System.ConsoleColor.DarkRed
            }).DockToBottom().FillHoriontally();

            var borderPanel = topPanel.Add(new ConsolePanel()
            {
                Background = ConsoleColor.DarkGray, Width = LevelDefinition.Width + 2, Height = LevelDefinition.Height + 2
            }).CenterHorizontally().CenterVertically();

            ScenePanel = borderPanel.Add(new ScenePanel(LevelDefinition.Width, LevelDefinition.Height)).Fill(padding: new Thickness(1, 1, 1, 1));

            var sceneFPSLabel = LayoutRoot.Add(new Label()
            {
                Text = "".ToConsoleString()
            }).FillHoriontally();
            var renderFPSLabel = LayoutRoot.Add(new Label()
            {
                Y = 1, Text = "".ToConsoleString()
            }).FillHoriontally();
            var paintFPSLabel = LayoutRoot.Add(new Label()
            {
                Y = 2, Text = "".ToConsoleString()
            }).FillHoriontally();

            LifetimeManager.Manage(SetInterval(() =>
            {
                sceneFPSLabel.Text  = $"{ScenePanel.Scene.FPS} scene frames per second".ToCyan();
                renderFPSLabel.Text = $"{FPS} render frames per second".ToCyan();
                paintFPSLabel.Text  = $"{PPS} paint frames per second".ToCyan();
            }, TimeSpan.FromSeconds(1)));



            QueueAction(() =>
            {
                if (this.LevelId != null)
                {
                    LoadLevel(this.LevelId);
                }
                else
                {
                    CurrentLevelDefinition = new LevelDefinition();
                }

                PreviewScene.Start();
                SetupCursorKeyInput();
                SetupDropKeyInput();
                SetupSaveKeyInput();
            });

            PreviewScene.QueueAction(() =>
            {
                Cursor.Bounds.Resize(ScenePanel.PixelSize);
                PreviewScene.Add(Cursor);
            });
        }