Ejemplo n.º 1
0
        public void RenderAmbientColor(BlinnPhongAmbientEventArgs arg)
        {
            ICamera camera     = arg.Camera;
            mat4    projection = camera.GetProjectionMatrix();
            mat4    view       = camera.GetViewMatrix();
            mat4    model      = this.GetModelMatrix();

            RenderMethod  method  = this.RenderUnit.Methods[0];
            ShaderProgram program = method.Program;

            program.SetUniform("mvpMat", projection * view * model);
            program.SetUniform("ambientColor", arg.Ambient);

            method.Render();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="param"></param>
        public override void Act(ActionParams param)
        {
            {
                var arg = new BlinnPhongAmbientEventArgs(param, this.scene.Camera, this.scene.AmbientColor);
                RenderAmbientColor(this.scene.RootNode, arg);
            }

            this.blend.On();
            foreach (var light in this.scene.Lights)
            {
                var arg = new RenderEventArgs(param, this.scene.Camera);
                RenderBlinnPhong(this.scene.RootNode, arg, light);
            }
            this.blend.Off();
        }
Ejemplo n.º 3
0
        private static void RenderAmbientColor(SceneNodeBase sceneNodeBase, BlinnPhongAmbientEventArgs arg)
        {
            if (sceneNodeBase != null)
            {
                var        node     = sceneNodeBase as IBlinnPhong;
                ThreeFlags flags    = (node != null) ? node.EnableRendering : ThreeFlags.None;
                bool       before   = (node != null) && ((flags & ThreeFlags.BeforeChildren) == ThreeFlags.BeforeChildren);
                bool       children = (node == null) || ((flags & ThreeFlags.Children) == ThreeFlags.Children);
                bool       after    = (node != null) && ((flags & ThreeFlags.AfterChildren) == ThreeFlags.AfterChildren);

                if (before || after)
                {
                    node.RenderAmbientColor(arg);
                }

                if (children)
                {
                    foreach (var item in sceneNodeBase.Children)
                    {
                        RenderAmbientColor(item, arg);
                    }
                }
            }
        }