Esempio n. 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);
        }
Esempio n. 2
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static DepthRectNode Create()
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, RectModel.strPosition);
            map.Add(inUV, RectModel.strUV);
            var builder = new RenderMethodBuilder(provider, map);
            var node    = new DepthRectNode(new RectModel(), RectModel.strPosition, builder);

            node.Initialize();

            return(node);
        }