Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sceneElement"></param>
        /// <param name="arg"></param>
        public static void Render(SceneNodeBase sceneElement, RenderEventArgs arg)
        {
            if (sceneElement != null)
            {
                var        renderable = sceneElement as IRenderable;
                ThreeFlags flags      = (renderable != null) ? renderable.EnableRendering : ThreeFlags.None;
                bool       before     = (renderable != null) && ((flags & ThreeFlags.BeforeChildren) == ThreeFlags.BeforeChildren);
                bool       children   = (renderable == null) || ((flags & ThreeFlags.Children) == ThreeFlags.Children);
                bool       after      = (renderable != null) && ((flags & ThreeFlags.AfterChildren) == ThreeFlags.AfterChildren);

                if (before)
                {
                    renderable.RenderBeforeChildren(arg);
                }

                if (children)
                {
                    foreach (var item in sceneElement.Children)
                    {
                        RenderAction.Render(item, arg);
                    }
                }

                if (after)
                {
                    renderable.RenderAfterChildren(arg);
                }
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="param"></param>
        public override void Act(ActionParams param)
        {
            //int[] value = null;
            //value = new int[4];
            //GL.Instance.GetIntegerv((uint)GetTarget.ColorClearValue, value);
            vec4 clearColor = this.Scene.ClearColor;

            GL.Instance.ClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
            GL.Instance.Clear(this.ClearMask);

            var arg = new RenderEventArgs(this.Scene, param, this.Scene.Camera);

            RenderAction.Render(this.Scene.RootElement, arg);

            //GL.Instance.ClearColor(value[0], value[1], value[2], value[3]);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        public override void Act()
        {
            //int[] value = null;
            //value = new int[4];
            //GL.Instance.GetIntegerv((uint)GetTarget.ColorClearValue, value);
            vec4 clearColor = this.Scene.ClearColor;

            GL.Instance.ClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
            GL.Instance.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            var arg = new RenderEventArgs(this.Scene, this.Scene.Camera);

            RenderAction.Render(this.Scene.RootElement, arg);

            //GL.Instance.ClearColor(value[0], value[1], value[2], value[3]);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clear"></param>
        /// <param name="clearColor"></param>
        /// <param name="rootElement"></param>
        /// <param name="camera"></param>
        public static void Render(bool clear, vec4 clearColor, RendererBase rootElement, ICamera camera)
        {
            int[] value = null;
            if (clear)
            {
                value = new int[4];
                GL.Instance.GetIntegerv((uint)GetTarget.ColorClearValue, value);
                GL.Instance.ClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
                GL.Instance.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);
            }

            var arg = new RenderEventArgs(camera);

            RenderAction.Render(rootElement, arg);

            if (clear)
            {
                GL.Instance.ClearColor(value[0], value[1], value[2], value[3]);
            }
        }
Example #5
0
        public DesignModeAssist(WinGLCanvas canvas, bool designMode, System.ComponentModel.LicenseUsageMode licenseUsageMode)
        {
            var       camera = new Camera(new vec3(0, 0, 4), new vec3(0, 0, 0), new vec3(0, 1, 0), CameraType.Perspecitive, canvas.Width, canvas.Height);
            GroupNode group;
            {
                group = new GroupNode();
                if (designMode)
                {
                    var propeller = new PropellerRenderer()
                    {
                        WorldPosition = new vec3(0, -1.5f, 0)
                    };
                    group.Children.Add(propeller);
                }
                if (licenseUsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
                {
                    var clock = new ClockNode();
                    group.Children.Add(clock);
                }
            }
            var scene = new Scene(camera)
            {
                ClearColor = Color.Black.ToVec4(),
                RootNode   = group,
            };

            this.scene = scene;

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            this.fullname = canvas.GetType().FullName;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        public void RenderBeforeChildren(RenderEventArgs arg)
        {
            if (this.Width <= 0 || this.Height <= 0)
            {
                return;
            }

            var viewport = new int[4];

            GL.Instance.GetIntegerv((uint)GetTarget.Viewport, viewport);

            this.framebuffer = this.framebufferSource.GetFramebuffer(this.Width, this.Height);
            framebuffer.Bind();
            GL.Instance.Viewport(0, 0, this.Width, this.Height);
            this.state.On();
            {
                int[] value = new int[4];
                GL.Instance.GetIntegerv((uint)GetTarget.ColorClearValue, value);
                {
                    vec3 color = this.BackgroundColor.ToVec3();
                    GL.Instance.ClearColor(color.x, color.y, color.z, 0.0f); // 0.0f for alpha channel, in case that transparent background is needed.
                    GL.Instance.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);
                }
                {
                    // TODO: maybe action should record only the root element instead of the scene.
                    var args = new RenderEventArgs(arg.Param, this.Camera);
                    foreach (var item in this.Children)
                    {
                        RenderAction.Render(item, args);
                    }
                }
                {
                    GL.Instance.ClearColor(value[0], value[1], value[2], value[3]);// recover clear color.
                }
            }
            this.state.Off();
            GL.Instance.Viewport(viewport[0], viewport[1], viewport[2], viewport[3]);// recover viewport.
            this.framebuffer.Unbind();
        }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 public void Render()
 {
     RenderAction.Render(true, this.clearColor, this.RootElement, this.Camera);
 }