Example #1
0
        private WinCtrlRoot GetRootControl()
        {
            var root = new WinCtrlRoot(this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            var bitmap = new Bitmap(@"particle.png");

            {
                var control = new CtrlImage(bitmap, false);
                control.Location = new GUIPoint(10, 10);
                control.Width    = 100; control.Height = 50;
                bitmap.Dispose();
                root.Children.Add(control);
            }
            {
                var control = new CtrlButton()
                {
                    Anchor = GUIAnchorStyles.Left | GUIAnchorStyles.Bottom
                };
                control.Location = new GUIPoint(10, 70);
                control.Width    = 100; control.Height = 50;
                root.Children.Add(control);
                control.Focused = true;
            }

            return(root);
        }
Example #2
0
        private WinCtrlRoot GetRootControl()
        {
            var root = new WinCtrlRoot(this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            string folder = System.Windows.Forms.Application.StartupPath;
            var    bitmap = new Bitmap(System.IO.Path.Combine(folder, @"particle.png"));

            {
                var control = new CtrlImage(bitmap, false);
                control.Location = new GUIPoint(10, 10);
                control.Width    = 100; control.Height = 50;
                bitmap.Dispose();
                root.Children.Add(control);
            }
            {
                var control = new CtrlButton()
                {
                    Anchor = GUIAnchorStyles.Left | GUIAnchorStyles.Bottom
                };
                control.Location = new GUIPoint(10, 70);
                control.Width    = 100; control.Height = 50;
                root.Children.Add(control);
                control.Focused = true;
            }

            return(root);
        }
Example #3
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);
        }
Example #4
0
        private WinCtrlRoot GetRootControl()
        {
            var root = new WinCtrlRoot(this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            string folder = System.Windows.Forms.Application.StartupPath;
            var    bitmap = new Bitmap(System.IO.Path.Combine(folder, @"particle.png"));

            {
                var control = new CtrlImage(bitmap, false)
                {
                    Anchor = GUIAnchorStyles.Left | GUIAnchorStyles.Bottom
                };
                control.Location = new GUIPoint(10, 10);
                control.Width    = 100; control.Height = 50;
                bitmap.Dispose();
                control.MouseUp += control_MouseUp;
                root.Children.Add(control);
            }
            {
                var control = new CtrlButton()
                {
                    Anchor = GUIAnchorStyles.Left | GUIAnchorStyles.Bottom
                };
                control.Location = new GUIPoint(10, 70);
                control.Width    = 100; control.Height = 50;
                control.Focused  = true;
                control.MouseUp += control_MouseUp;
                root.Children.Add(control);
            }
            {
                var control = new CtrlLabel(100)
                {
                    Anchor = GUIAnchorStyles.Left | GUIAnchorStyles.Bottom
                };
                control.Location         = new GUIPoint(10, 130);
                control.Width            = 100; control.Height = 30;
                control.Text             = "Hello CSharpGL!";
                control.RenderBackground = true;
                control.BackgroundColor  = new vec4(1, 0, 0, 1);
                control.MouseUp         += control_MouseUp;

                root.Children.Add(control);
            }

            return(root);
        }
Example #5
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            SceneNodeBase rootElement = GetRootElement();
            WinCtrlRoot   rootControl = GetRootControl();

            var position = new vec3(1, 0, 4);
            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,
                RootControl = rootControl,
                ClearColor  = Color.SkyBlue.ToVec4(),
            };
            rootControl.Bind(this.winGLCanvas1);

            var list = new ActionList();

            var transformAction = new TransformAction(scene);

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

            list.Add(renderAction);

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

            list.Add(guiRenderAction);

            this.actionList = list;

            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);
            manipulater.StepLength = 0.1f;
        }
Example #6
0
        private WinCtrlRoot GetRootControl()
        {
            var root = new WinCtrlRoot(this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            var bitmap = new Bitmap(@"particle.png");

            {
                var control = new CtrlImage(bitmap, false);
                control.Left  = 10; control.Bottom = 10;
                control.Width = 100; control.Height = 50;
                bitmap.Dispose();
                root.Children.Add(control);
            }
            {
                var control = new CtrlButton();
                control.Left  = 10; control.Bottom = 70;
                control.Width = 100; control.Height = 50;
                root.Children.Add(control);
            }

            return(root);
        }