Пример #1
0
 /// <summary>
 /// Called when [render].
 /// </summary>
 /// <param name="context">The context.</param>
 protected virtual void OnRender(RenderContext2D context)
 {
     RenderCore.Render(context);
     for (var i = 0; i < this.ItemsInternal.Count; ++i)
     {
         ItemsInternal[i].Render(context);
     }
 }
Пример #2
0
 /// <summary>
 /// Called when [render].
 /// </summary>
 /// <param name="context">The context.</param>
 protected virtual void OnRender(RenderContext2D context)
 {
     RenderCore.Render(context);
     for (int i = 0; i < this.Items.Count; ++i)
     {
         Items[i].Render(context);
     }
 }
Пример #3
0
 /// <summary>
 /// Detaches the element from the host. Override <see cref="OnDetach"/>
 /// </summary>
 public void Detach()
 {
     if (IsAttached)
     {
         IsAttached = false;
         RenderCore.Detach();
         OnDetach();
         OnDetached?.Invoke(this, EventArgs.Empty);
     }
 }
Пример #4
0
        /// <summary>
        /// Called when [attach].
        /// </summary>
        /// <param name="host">The host.</param>
        /// <returns></returns>
        protected override bool OnAttach(IRenderHost host)
        {
            RenderCore.Attach(renderTechnique);
            var screenSpaceCore = RenderCore as ScreenSpacedMeshRenderCore;

            screenSpaceCore.RelativeScreenLocationX = RelativeScreenLocationX;
            screenSpaceCore.RelativeScreenLocationY = RelativeScreenLocationY;
            screenSpaceCore.SizeScale = SizeScale;
            return(base.OnAttach(host));
        }
Пример #5
0
            protected override bool OnAttach(IEffectsManager effectsManager)
            {
                RenderCore.Attach(EffectTechnique);
                var screenSpaceCore = RenderCore as ScreenSpacedMeshRenderCore;

                screenSpaceCore.RelativeScreenLocationX = RelativeScreenLocationX;
                screenSpaceCore.RelativeScreenLocationY = RelativeScreenLocationY;
                screenSpaceCore.SizeScale = SizeScale;
                return(base.OnAttach(effectsManager));
            }
 /// <summary>
 /// Initializes a new instance of the <see cref="SceneNode"/> class.
 /// </summary>
 public SceneNode()
 {
     WrapperSource = this;
     renderCore    = new Lazy <RenderCore>(() =>
     {
         core = OnCreateRenderCore();
         core.OnInvalidateRenderer += RenderCore_OnInvalidateRenderer;
         return(core);
     }, true);
 }
Пример #7
0
 private bool previewTest(MultiSourceTreeNode node, NodeInfo info)
 {
     // Check to see if the tag is previewable and isn't already open.
     if (game.TypeTable.Previewable(Path.GetExtension(info.Identifier).TrimStart('.')))
     {
         TagPath path = new TagPath(info.Identifier, game.GameID, TagLocation.Project);
         return(!RenderCore.ContainsScene(path.ToPath()));
     }
     return(false);
 }
Пример #8
0
 /// <summary>
 /// Detaches this instance.
 /// </summary>
 public void Detach()
 {
     if (IsAttached)
     {
         IsAttached = false;
         RenderCore.Detach();
         Disposer.RemoveAndDispose(ref bitmapCache);
         OnDetach();
         OnDetached?.Invoke(this, EventArgs.Empty);
     }
 }
Пример #9
0
        /// <summary>
        /// Assigns the default values to core.
        /// </summary>
        /// <param name="core">The core.</param>
        protected override void AssignDefaultValuesToCore(RenderCore core)
        {
            base.AssignDefaultValuesToCore(core);
            var c = core as ShadowMapCore;

            //c.FactorPCF = (float)FactorPCF;
            c.Intensity = (float)Intensity;
            c.Bias      = (float)Bias;
            c.Width     = (int)(Resolution.Width);
            c.Height    = (int)(Resolution.Height);
        }
Пример #10
0
 protected override bool OnAttach(IRenderHost host)
 {
     if (base.OnAttach(host))
     {
         RenderCore.Attach(this.EffectTechnique);
         return(true);
     }
     else
     {
         return(false);
     }
 }
 /// <summary>
 /// Detaches the element from the host. Override <see cref="OnDetach"/>
 /// </summary>
 public void Detach()
 {
     if (IsAttached)
     {
         IsAttached = false;
         InvalidateSceneGraph();
         RenderCore.Detach();
         OnDetach();
         DisposeAndClear();
         OnDetached?.Invoke(this, EventArgs.Empty);
     }
 }
Пример #12
0
 protected override bool OnAttach(IEffectsManager effectsManager)
 {
     if (base.OnAttach(effectsManager))
     {
         RenderCore.Attach(this.EffectTechnique);
         return(true);
     }
     else
     {
         return(false);
     }
 }
            /// <summary>
            /// Called when [attach].
            /// </summary>
            /// <param name="host">The host.</param>
            /// <returns></returns>
            protected override bool OnAttach(IRenderHost host)
            {
                RenderCore.Attach(EffectTechnique);
                var screenSpaceCore = RenderCore as ScreenSpacedMeshRenderCore;

                screenSpaceCore.RelativeScreenLocationX = RelativeScreenLocationX;
                screenSpaceCore.RelativeScreenLocationY = RelativeScreenLocationY;
                screenSpaceCore.SizeScale = SizeScale;
                for (int i = 0; i < ItemsInternal.Count; ++i)
                {
                    ItemsInternal[i].RenderType = RenderType.ScreenSpaced;
                }
                return(base.OnAttach(host));
            }
Пример #14
0
        private void InitializeCore()
        {
            Core = new RenderCore();
            ThumbnailBinding.ThumbMan.SetTarget(Core.ThumbMan);
            ThumbnailBinding.TexLoad.SetTarget(Core.TexLoader);
            OperateTargets[0] = Core.TheScene.MainCamera;
            OperateTargets[1] = Core.TheScene.Drawables.LastOrDefault();
            OperateTargets[2] = Core.TheScene.Lights.LastOrDefault();

            Core.Resize((uint)glMain.ClientSize.Width, (uint)glMain.ClientSize.Height);
            this.Closed += (o, e) => { Core.Dispose(); Core = null; };

            glMain.Draw   += Core.Draw;
            glMain.Resize += (o, e) => { Core.Resize((uint)e.Width, (uint)e.Height); };

            AutoRefresher = new Timer(o =>
            {
                if (!ShouldRefresh)
                {
                    return;
                }
                OperateTargets[1]?.Rotate(0, 3 * MULER, 0);
                this.Dispatcher.InvokeAsync(() => glMain.Invalidate(), System.Windows.Threading.DispatcherPriority.Normal);
            }, null, 0, 15);
            this.Closing += (o, e) => AutoRefresher.Change(Timeout.Infinite, 20);
            glMain.Invalidate();
            WaitingCount = 0;

            var fpsTimer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(0.5)
            };

            fpsTimer.Tick += (o, e) => { var timeUs = glMain?.AvgDrawTime ?? 0; txtFPS.Text = timeUs > 0 ? $"{1000000 / timeUs} FPS@{timeUs / 1000}ms" : ""; };
            fpsTimer.Start();

            Core.TheScene.Drawables.ObjectPropertyChanged += (s, t, e) => InvalidateOnPropChanged(e.PropertyName);
            drawablePage.DataContext = Core.TheScene.Drawables;
            Core.TheScene.Lights.ObjectPropertyChanged += (s, t, e) => InvalidateOnPropChanged(e.PropertyName);
            lightPage.DataContext                         = Core.TheScene.Lights;
            Core.Passes.ObjectPropertyChanged            += (s, t, e) => InvalidateOnPropChanged(e.PropertyName);
            shaderPage.DataContext                        = Core.Passes;
            Core.Controls.ForEach(x => x.PropertyChanged += (o, e) => InvalidateOnPropChanged(e.PropertyName));
            controlPage.DataContext                       = Core.Controls;
            Core.TheScene.MainCamera.PropertyChanged     += (o, e) => InvalidateOnPropChanged(e.PropertyName);
        }
Пример #15
0
 protected override void OnDispose(bool disposeManagedResources)
 {
     if (!Items.IsReadOnly)
     {
         Items.Clear();
     }
     RenderCore.Dispose();
     OnVisibleChanged              = null;
     OnTransformChanged            = null;
     OnSetRenderTechnique          = null;
     OnBoundChanged                = null;
     OnTransformBoundChanged       = null;
     OnBoundSphereChanged          = null;
     OnTransformBoundSphereChanged = null;
     OnAttached    = null;
     OnDetached    = null;
     WrapperSource = null;
     base.OnDispose(disposeManagedResources);
 }
Пример #16
0
        void Init()
        {
            Console.WriteLine(GL.GetString(StringName.Renderer));
            Console.WriteLine(GL.GetString(StringName.Version));

            AssetLoader.Init();
            RenderCore.Create();
            GameLoop                   = new GameLoop(this);
            EditorLoop                 = new GameLoop(this);
            DisplayRT                  = new RenderTexture();
            FullscreenQuadProgram      = ShaderUtils.CreateFromResource("RasterDraw.Shaders.SimpleVert.glsl", "RasterDraw.Shaders.SimpleFrag.glsl");
            PhysicsEngine              = new PhysicsManager();
            EditorManager              = new EditorManager(ClientSize);
            EditorManager.GameGameLoop = GameLoop;
            GameObject editorManager = new GameObject("Editor Manager");

            editorManager.AddScript(EditorManager);
            EditorManager.Enabled = false;
            EditorLoop.Add(editorManager);
        }
Пример #17
0
        public Form1()
        {
            Common.ViewModelSyncRoot.Init();
            InitializeComponent();
            AllowDrop  = true;
            DragEnter += (o, e) =>
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    e.Effect = DragDropEffects.Link;
                }
                else
                {
                    e.Effect = DragDropEffects.None;
                }
            };
            DragDrop += OnDropFileAsync;

            GLView = new OGLView()
            {
                Location     = new System.Drawing.Point(0, 0),
                Name         = "oglv",
                Size         = ClientSize,
                ResizeBGDraw = false
            };
            Core = new RenderCore();
            OperateTargets[0] = Core.TheScene.MainCamera;
            OperateTargets[1] = Core.TheScene.Drawables.LastOrDefault();
            OperateTargets[2] = Core.TheScene.Lights.LastOrDefault();
            Core.Resize((uint)ClientSize.Width, (uint)ClientSize.Height);

            Controls.Add(GLView);
            Resize      += (o, e) => { GLView.Size = ClientSize; };
            FormClosing += (o, e) => { Core.Dispose(); Core = null; };

            GLView.Draw    += Core.Draw;
            GLView.Resize  += (o, e) => { Core.Resize((uint)e.Width, (uint)e.Height); };
            GLView.KeyDown += OnKeyDown;
            //oglv.KeyAction += OnKeyAction;
            GLView.MouseAction += OnMouse;
        }
Пример #18
0
 /// <summary>
 /// Assigns the default values to core.
 /// </summary>
 /// <param name="core">The core.</param>
 protected virtual void AssignDefaultValuesToCore(RenderCore core)
 {
 }
Пример #19
0
 /// <summary>
 /// To override Attach routine, please override this.
 /// </summary>
 /// <param name="host"></param>
 /// <returns>Return true if attached</returns>
 protected virtual bool OnAttach(IRenderHost host)
 {
     RenderCore.Attach(host);
     return(true);
 }
Пример #20
0
 /// <summary>
 /// Assigns the default values to core.
 /// </summary>
 /// <param name="core">The core.</param>
 protected override void AssignDefaultValuesToCore(RenderCore core)
 {
     base.AssignDefaultValuesToCore(core);
     boneSkinRenderCore.BoneMatrices = BoneMatrices;
 }
Пример #21
0
 /// <summary>
 /// Renders the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="deviceContext">The device context.</param>
 public void Render(RenderContext context, DeviceContextProxy deviceContext)
 {
     RenderCore.Render(context, deviceContext);
 }
 /// <summary>
 /// Called when [detach].
 /// </summary>
 protected override void OnDetach()
 {
     RenderCore.Detach();
     base.OnDetach();
 }
Пример #23
0
 /// <summary>
 /// To override Attach routine, please override this.
 /// </summary>
 /// <param name="host"></param>
 /// <returns>Return true if attached</returns>
 protected virtual bool OnAttach(IRenderHost host)
 {
     RenderCore.Attach(renderTechnique);
     AssignDefaultValuesToCore(RenderCore);
     return(RenderCore == null ? false : RenderCore.IsAttached);
 }