Ejemplo n.º 1
0
        //private EventHandler mouseEnter;
        //private EventHandler mouseLeave;
        /// <summary>
        /// Creats render context and supports OpenGL rendering.
        /// </summary>
        public GLSceneCanvas()
        {
            InitializeComponent();

            //  Set the user draw styles.
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            // check http://stackoverflow.com/questions/34664/designmode-with-controls
            this.designMode = this.DesignMode || System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime;

            //if (!this.designMode)
            //{
            //    //this.mouseEnter = GLCanvas_MouseEnter;
            //    this.mouseEnter = (x, y) => ShowCursor(0);// hide system's cursor.
            //    this.mouseLeave = (x, y) => ShowCursor(1);// show system's cursor.
            //}
            {
                var camera = new Camera(
                    new vec3(0, 0, 5), new vec3(0, 0, 0), new vec3(0, 1, 0),
                    CameraType.Perspecitive, this.Width, this.Height);
                var scene = new Scene(camera, this);
                this.Scene = scene;
                this.Resize += scene.Resize;
                var rotator = new FirstPerspectiveManipulater();// SatelliteManipulater();
                //rotator.Bind(camera, this);
                this.CameraManipulater = rotator;
            }
            this.fullname = this.GetType().FullName;
        }
Ejemplo n.º 2
0
        private void ScientificCanvas_Load(object sender, EventArgs e)
        {
            var camera = new Camera(new vec3(4, 1.6f, 3), new vec3(0, 0, 0), new vec3(0, 1, 0),
                 CameraType.Perspecitive, this.Width, this.Height);
            var cameraManipulater = new SatelliteManipulater();
            cameraManipulater.Bind(camera, this);
            this.cameraManipulater = cameraManipulater;

            this.Scene = new Scene(camera, this);
            //this.Scene.Cursor.Enabled = false;
            {
                var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom,
                    new Padding(10, 10, 10, 10), new Size(128, 128));
                uiAxis.Initialize();
                //// display this UI control's area.
                //uiAxis.StateList.Add(new ClearColorState());
                this.Axis = uiAxis;
                this.Scene.RootUI.Children.Add(uiAxis);
            }
            {
                var uiColorPalette = new UIColorPaletteRenderer(100,
                    CodedColor.GetDefault(),
                    AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right,
                    new Padding(148, 10, 60, 10 + 40), new Size(400, 40), -100, 100);
                uiColorPalette.Initialize();
                this.ColorPalette = uiColorPalette;
                this.Scene.RootUI.Children.Add(uiColorPalette);
            }
            this.Resize += this.Scene.Resize;
            this.OpenGLDraw += ScientificCanvas_OpenGLDraw;
            //this.MouseDown += ScientificCanvas_MouseDown;
            //this.MouseMove += ScientificCanvas_MouseMove;
            //this.MouseUp += ScientificCanvas_MouseUp;
            //this.MouseWheel += ScientificCanvas_MouseWheel;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Manages a scene to be rendered and updated.
        /// </summary>
        /// <param name="camera">camera of the scene</param>
        /// <param name="objects">objects to be rendered</param>
        public Scene(Camera camera, params SceneObject[] objects)
        {
            if (camera == null)
            { throw new ArgumentNullException(); }

            this.Camera = camera;
            var list = new SceneObjectList();
            list.AddRange(objects);
            this.ObjectList = list;
            this.UIRoot = new UIRoot();
        }