示例#1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(1, 0.6f, 1) * 16;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene          = new Scene(camera);
            this.scene.RootNode = GetRootNode();
            WinCtrlRoot rootControl = GetRootControl();

            rootControl.Bind(this.winGLCanvas1);
            this.scene.RootControl = rootControl;

            // add lights.
            {
                var   lightList = this.lights;
                float angle     = 0;
                foreach (var light in lightList)
                {
                    this.scene.Lights.Add(light);
                    var node = LightPositionNode.Create(light, angle);
                    angle += 360.0f / lightList.Count;
                    this.scene.RootNode.Children.Add(node);
                }
            }
            {
                var list = new ActionList();
                list.Add(new TransformAction(scene));
                var shadowMappingAction = new ShadowMappingAction(scene);
                list.Add(shadowMappingAction);
                this.shadowMappingAction = shadowMappingAction;
                list.Add(new RenderAction(scene));

                //var guiLayoutAction = new GUILayoutAction(scene.RootControl);
                //list.Add(guiLayoutAction);
                var guiRenderAction = new GUIRenderAction(scene.RootControl);
                list.Add(guiRenderAction);

                this.actionList = list;
            }
            {
                var node = DepthRectNode.Create();
                node.TextureSource = this.shadowMappingAction.LightEquipment;
                this.scene.RootNode.Children.Add(node);
            }

            Match(this.trvSceneObject, scene.RootNode);
            this.trvSceneObject.ExpandAll();

            Match(this.trvSceneGUI, scene.RootControl);
            this.trvSceneGUI.ExpandAll();

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
示例#2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(1, 0.6f, 1) * 16;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene          = new Scene(camera);
            this.scene.RootNode = GetRootNode();
            // add lights.
            {
                var   lightList = this.lights;
                float angle     = 0;
                foreach (var light in lightList)
                {
                    this.scene.Lights.Add(light);
                    var node = LightPositionNode.Create(light, angle);
                    angle += 360.0f / lightList.Count;
                    this.scene.RootNode.Children.Add(node);
                }
            }
            var list            = new ActionList();
            var transformAction = new TransformAction(scene.RootNode);

            list.Add(transformAction);
            var blinnPhongAction = new BlinnPhongAction(scene);

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

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

            Match(this.trvScene, scene.RootNode);
            this.trvScene.ExpandAll();

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            var rootElement = GetRootElement();
            //var teapot = ShadowMappingRenderer.Create();
            //var rootElement = teapot;

            var position = new vec3(5, 3, 5) * 3;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera)
            {
                RootNode   = rootElement,
                ClearColor = Color.SkyBlue.ToVec4(),
            };
            {
                // add lights.
                var    list   = new List <LightBase>();
                double radian = 120.0 / 180.0 * Math.PI;
                {
                    var light = new CSharpGL.SpotLight(new vec3(3, 3, 3), new vec3(), (float)Math.Cos(radian), new Attenuation(2, 0, 0));
                    light.Diffuse  = new vec3(1, 0, 0);
                    light.Specular = new vec3(1, 0, 0);
                    list.Add(light);
                }
                {
                    var light = new CSharpGL.SpotLight(new vec3(3, 3, 3), new vec3(), (float)Math.Cos(radian), new Attenuation(2, 0, 0));
                    light.Diffuse  = new vec3(0, 1, 0);
                    light.Specular = new vec3(0, 1, 0);
                    list.Add(light);
                }
                {
                    var light = new CSharpGL.SpotLight(new vec3(3, 3, 3), new vec3(), (float)Math.Cos(radian), new Attenuation(2, 0, 0));
                    light.Diffuse  = new vec3(0, 0, 1);
                    light.Specular = new vec3(0, 0, 1);
                    list.Add(light);
                }
                for (int i = 0; i < list.Count; i++)
                {
                    var light = list[i];
                    var node  = LightPositionNode.Create(light, i * 360.0f / list.Count);

                    this.scene.Lights.Add(light);
                    this.scene.RootNode.Children.Add(node);
                }
            }

            Match(this.trvScene, scene.RootNode);
            this.trvScene.ExpandAll();

            var tansformAction = new TransformAction(scene);

            this.shadowMappingAction = new ShadowMappingAction(scene);
            var renderAction = new RenderAction(scene);
            var actionList   = new ActionList();

            actionList.Add(tansformAction); actionList.Add(shadowMappingAction); actionList.Add(renderAction);
            this.actionList = actionList;
            (new FormProperyGrid(shadowMappingAction)).Show();

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }