Exemplo n.º 1
0
        public FormAlwaysFaceCamera()
        {
            InitializeComponent();

            if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            {
                this.camera = CameraDictionary.Instance[this.GetType().Name];
            }
            else
            {
                this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            rotator = new SatelliteRotator(this.camera);
            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;

            element = new PyramidElement();
            element.Initialize();

            element.BeforeRendering += element_BeforeRendering;
            element.AfterRendering  += element_AfterRendering;

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SharpGLForm"/> class.
        /// </summary>
        public SharpGLForm()
        {
            InitializeComponent();

            int radius = 1;

            legacyModel.Build(
                new SharpGL.SceneGraph.Vertex(-radius, -0, -radius),
                new SharpGL.SceneGraph.Vertex(radius, 0, radius));

            vertexArrayModel.Build(
                new SharpGL.SceneGraph.Vertex(-radius, -radius, -radius),
                new SharpGL.SceneGraph.Vertex(radius, radius, radius));

            VBOModel.Build(
                new SharpGL.SceneGraph.Vertex(-radius, -radius, -radius),
                new SharpGL.SceneGraph.Vertex(radius, radius, radius));
            ScientificCamera camera = new ScientificCamera(CameraTypes.Perspecitive);

            camera.Target   = new SharpGL.SceneGraph.Vertex(0, 0, 0);
            camera.Position = new SharpGL.SceneGraph.Vertex(-2, 2, -2);
            camera.UpVector = new SharpGL.SceneGraph.Vertex(0, 1, 0);
            IPerspectiveViewCamera perspective = camera;

            perspective.AspectRatio = (double)Width / (double)Height;
            perspective.Far         = 100;
            perspective.Near        = 0.01;
            perspective.FieldOfView = 60;
            this.element            = new ScientificModelElement(VBOModel, camera);
        }
Exemplo n.º 3
0
        public FormTranslateOnScreen()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            satelliteRoration = new SatelliteRotator(camera);

            //var planColor = new vec3(1, 1, 0);
            //var faceCount = 10;
            //var radius = 0.1f;
            //var height = 10f;
            //element = new AxisElement(planColor, radius, height, faceCount);
            element = new AxisElement();
            element.Initialize();

            element.BeforeRendering += element_BeforeRendering;
            element.AfterRendering  += element_AfterRendering;

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
Exemplo n.º 4
0
        public FormLegacySimpleUIRect()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            satelliteRoration = new SatelliteRotator(camera);

            uiRectElement = new LegacySimpleUIRect(
                new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right, new Padding(10, 10, 10, 10), new Size(40, 30)));
            uiRectElement.Initialize();

            axisElement = new AxisElement();
            axisElement.Initialize();
            axisElement.BeforeRendering += axisElement_BeforeRendering;
            axisElement.AfterRendering  += axisElement_AfterRendering;

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormModernOpenGLControlDemo"/> class.
        /// </summary>
        public FormModernSceneControlDemo()
        {
            InitializeComponent();

            foreach (var name in Enum.GetNames(typeof(BeginMode)))
            {
                var item = new ComboBoxItem <BeginMode>(
                    name, (BeginMode)Enum.Parse(typeof(BeginMode), name));
                this.cmbBeginMode.Items.Add(item);
            }
            this.cmbBeginMode.SelectedIndex = 4;

            // prepare camera.
            ScientificCamera camera = new ScientificCamera(CameraTypes.Perspecitive);

            camera.Position            = new SharpGL.SceneGraph.Vertex(0, 0, 5);
            camera.Target              = new SharpGL.SceneGraph.Vertex();
            camera.UpVector            = new SharpGL.SceneGraph.Vertex(0, 1, 0);
            this.cameraRotation.Camera = camera;
            this.sceneElement.Camera   = camera;
            this.sceneElement2.Camera  = camera;

            // prepare scene's settings.
            this.mySceneControl.Scene.SceneContainer.Children.Clear();
            this.mySceneControl.Scene.SceneContainer.Effects.Clear();
            this.mySceneControl.Scene.ClearColor = new GLColor(0.4f, 0.6f, 0.9f, 0.5f);

            // prepare models' elements.
            this.sceneElement.Initialise(this.mySceneControl.OpenGL,
                                         this.mySceneControl.Width, this.mySceneControl.Height);
            this.mySceneControl.Scene.SceneContainer.AddChild(this.sceneElement);
            this.sceneElement2.Initialise(this.mySceneControl.OpenGL,
                                          this.mySceneControl.Width, this.mySceneControl.Height);
            this.mySceneControl.Scene.SceneContainer.AddChild(this.sceneElement2);
        }
Exemplo n.º 6
0
        public FormFontElement()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            IPerspectiveCamera perspectiveCamera = this.camera;

            perspectiveCamera.FieldOfView = 60f;
            perspectiveCamera.AspectRatio = (double)this.glCanvas1.Width / (double)this.glCanvas1.Height;
            perspectiveCamera.Near        = 0.01;
            perspectiveCamera.Far         = 10000;

            IOrthoCamera orthoCamera = this.camera;

            orthoCamera.Left   = -this.glCanvas1.Width / 2;
            orthoCamera.Right  = this.glCanvas1.Width / 2;
            orthoCamera.Bottom = -this.glCanvas1.Height / 2;
            orthoCamera.Top    = this.glCanvas1.Height / 2;
            orthoCamera.Near   = -10000;
            orthoCamera.Far    = 10000;

            this.camera.Position = new vec3(0, 0, 9.23f);

            satelliteRoration = new SatelliteRotator(camera);

            //element = new ModernSingleTextureFont("simsun.ttf", 48, '祝', '神');//char.MinValue, char.MaxValue);
            //element = new FontElement("simsun.ttf", 48, '一', '龟');//包含了几乎所有汉字字符
            element = new FontElement("simsun.ttf", 48, (char)0, '~');

            element.Initialize();

            //element.SetText("祝神");
            //element.SetText("一龟");
            element.SetText("The quick brown fox jumps over the lazy dog!");

            element.BeforeRendering += element_BeforeRendering;
            element.AfterRendering  += element_AfterRendering;

            uiAxisElement = new SimpleUIAxis(
                new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom,
                                   new Padding(0, 0, 0, 0), new System.Drawing.Size(100, 100)));
            uiAxisElement.Initialize();

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
Exemplo n.º 7
0
        public FormSimpleUIRect()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            satelliteRoration = new SatelliteRotator(camera);

            Padding        padding = new System.Windows.Forms.Padding(10, 10, 10, 10);
            Size           size    = new Size(100, 100);
            IUILayoutParam param;

            param                = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom, padding, size);
            uiLeftBottomRect     = new SimpleUIRect(param);
            legacyLeftBottomRect = new LegacySimpleUIRect(param, new Objects.GLColor(1, 1, 1, 1));

            param             = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Top, padding, size);
            uiLeftTopRect     = new SimpleUIRect(param);
            legacyLeftTopRect = new LegacySimpleUIRect(param, new Objects.GLColor(1, 1, 1, 1));

            param                 = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Bottom, padding, size);
            uiRightBottomRect     = new SimpleUIRect(param);
            legacyRightBottomRect = new LegacySimpleUIRect(param, new Objects.GLColor(1, 1, 1, 1));

            param              = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Top, padding, size);
            uiRightTopRect     = new SimpleUIRect(param);
            legacyRightTopRect = new LegacySimpleUIRect(param, new Objects.GLColor(1, 1, 1, 1));

            uiLeftBottomRect.Initialize();
            uiLeftTopRect.Initialize();
            uiRightBottomRect.Initialize();
            uiRightTopRect.Initialize();

            legacyLeftBottomRect.Initialize();
            legacyLeftTopRect.Initialize();
            legacyRightBottomRect.Initialize();
            legacyRightTopRect.Initialize();

            axisElement = new AxisElement();
            axisElement.Initialize();
            axisElement.BeforeRendering += axisElement_BeforeRendering;
            axisElement.AfterRendering  += axisElement_AfterRendering;

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
Exemplo n.º 8
0
        public FormLegacyTexture3D()
        {
            InitializeComponent();


            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            satelliteRoration = new SatelliteRotator(camera);

            Padding padding = new System.Windows.Forms.Padding(10, 10, 10, 10);
            Size    size    = new Size(100, 100);
            //Size size = new Size(5, 5);
            IUILayoutParam param;

            param        = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom, padding, size);
            legacyUIRect = new LegacySimpleUIRect(param, new Objects.GLColor(1, 0, 0, 1));

            param        = new IUILayoutParam(AnchorStyles.Bottom | AnchorStyles.Right, padding, size);
            modernUIRect = new SimpleUIRect(param, new GLColor(0, 1, 1, 1));

            param      = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom, padding, size);
            leftUIAxis = new SimpleUIAxis(param, new GLColor(1, 1, 1, 1));

            param       = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Bottom, padding, size);
            rightUIAxis = new SimpleUIAxis(param, new GLColor(1, 1, 1, 1));


            legacyUIRect.Initialize();
            modernUIRect.Initialize();
            leftUIAxis.Initialize();
            rightUIAxis.Initialize();

            legacyUIRect.BeforeRendering += legacyUIRect_BeforeRendering;
            legacyUIRect.AfterRendering  += legacyUIRect_AfterRendering;

            element = new DemoLegacyTexture3DCubeElement();
            element.Initialize();
            element.BeforeRendering += element_BeforeRendering;
            element.AfterRendering  += element_AfterRendering;

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;

            UpdateInfo();
        }
        public ModernOpenGLControlSceneElement()
        {
            ScientificCamera camera = new ScientificCamera(CameraTypes.Perspecitive);

            camera.Position            = new SharpGL.SceneGraph.Vertex(0, 0, 5);
            camera.Target              = new SharpGL.SceneGraph.Vertex();
            camera.UpVector            = new SharpGL.SceneGraph.Vertex(0, 1, 0);
            this.cameraRotation.Camera = camera;
        }
Exemplo n.º 10
0
        public FormWell()
        {
            this.camera  = new ScientificCamera(CameraTypes.Perspecitive);
            this.rotator = new SatelliteRotation(camera);

            InitializeComponent();

            this.openGLControl.MouseWheel += openGLControl_MouseWheel;
        }
        void ScientificVisual3DControl_MouseWheel(object sender, MouseEventArgs e)
        {
            ScientificCamera camera = this.sceneControl.Scene.CurrentCamera as ScientificCamera;

            //if (camera == null) { return; }

            camera.Scale(e.Delta);

            ManualRender(this.sceneControl);
        }
Exemplo n.º 12
0
        void openGLControl_MouseWheel(object sender, MouseEventArgs e)
        {
            ScientificCamera camera = this.camera;

            //if (camera == null) { return; }

            camera.Scale(e.Delta);

            this.openGLControl_Resized(sender, e);
        }
Exemplo n.º 13
0
        public FormTransformFeedback()
        {
            InitializeComponent();

            this.camera       = new ScientificCamera(CameraTypes.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);
            satelliteRoration = new SatelliteRotator(camera);

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
Exemplo n.º 14
0
        public FormSimplePointSprite(float fontSize, bool foreshortening, FragShaderType type)
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            satelliteRoration = new SatelliteRotator(camera);

            Padding padding = new System.Windows.Forms.Padding(40, 40, 40, 40);
            Size    size    = new Size(100, 100);
            //Size size = new Size(5, 5);
            IUILayoutParam param;

            param             = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom, padding, size);
            uiLeftBottomAxis  = new SimpleUIAxis(param);
            param             = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Top, padding, size);
            uiLeftTopAxis     = new SimpleUIAxis(param);
            param             = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Bottom, padding, size);
            uiRightBottomAxis = new SimpleUIAxis(param);
            param             = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Top, padding, size);
            uiRightTopAxis    = new SimpleUIAxis(param);

            uiLeftBottomAxis.Initialize();
            uiLeftTopAxis.Initialize();
            uiRightBottomAxis.Initialize();
            uiRightTopAxis.Initialize();

            pointSpriteElement = new DemoSimplePointSpriteElement(fontSize, foreshortening, type);
            pointSpriteElement.Initialize();
            pointSpriteElement.BeforeRendering += pointSpriteElement_BeforeRendering;
            pointSpriteElement.AfterRendering  += pointSpriteElement_AfterRendering;

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
        public FormPointSpriteStringElement()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            rotator = new SatelliteRotator(this.camera);
            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;

            //textElement = new PointSpriteStringElement("HTMLHHTMLHHTMLHHTMLH", new vec3(0, 1, 0));
            //textElement = new PointSpriteStringElement("good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good good good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good good good good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good good good good good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good good good good good good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteStringElement("good good good good good good good good good good good!", new vec3(0, 0, 0));
            //textElement = new PointSpriteFontElement("QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm", new vec3(0, 0, 0));
            //textElement.Initialize();

            //textElement.BeforeRendering += textElement_BeforeRendering;
            //textElement.AfterRendering += textElement_AfterRendering;

            pyramidElement = new PyramidElement();
            pyramidElement.Initialize();
            pyramidElement.BeforeRendering += pyramidElement_BeforeRendering;
            pyramidElement.AfterRendering  += pyramidElement_AfterRendering;

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
Exemplo n.º 16
0
        void IRenderable.Render(OpenGL gl, RenderMode renderMode)
        {
            ScientificCamera camera = this.Camera;

            if (camera == null)
            {
                return;
            }

            IOrthoCamera orthoCamera = camera;
            double       width       = orthoCamera.Right - orthoCamera.Left;
            double       height      = orthoCamera.Top - orthoCamera.Bottom;

            Vertex back  = camera.Position - camera.Target;
            Vertex right = camera.UpVector.VectorProduct(back);
            Vertex up    = back.VectorProduct(right);

            back.Normalize();
            right.Normalize();
            up.Normalize();
            right.X *= (float)(height / 2);
            right.Y *= (float)(height / 2);
            right.Z *= (float)(height / 2);
            up.X    *= (float)(width / 2);
            up.Y    *= (float)(width / 2);
            up.Z    *= (float)(width / 2);

            IOrthoInfo viewportInfo = this;

            viewportInfo.LeftBottom  = camera.Position - right - up;
            viewportInfo.LeftTop     = camera.Position - right + up;
            viewportInfo.RightBottom = camera.Position + right - up;
            viewportInfo.RightTop    = camera.Position + right + up;
            viewportInfo.Width       = (float)width;
            viewportInfo.Height      = (float)height;

            gl.MatrixMode(SharpGL.Enumerations.MatrixMode.Projection);
            gl.LoadIdentity();
            gl.Ortho(orthoCamera.Left, orthoCamera.Right, orthoCamera.Bottom, orthoCamera.Top, orthoCamera.Near, orthoCamera.Far);
            gl.LookAt(
                (double)camera.Position.X, (double)camera.Position.Y, (double)camera.Position.Z,
                (double)camera.Target.X, (double)camera.Target.Y, (double)camera.Target.Z,
                (double)camera.UpVector.X, (double)camera.UpVector.Y, (double)camera.UpVector.Z);
            gl.MatrixMode(Enumerations.MatrixMode.Modelview);
        }
Exemplo n.º 17
0
        public FormColorCodedPicking()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            const int size = 3;

            this.camera.Position = new vec3(size * 3, size * 3, size * 3);

            rotator = new SatelliteRotator(this.camera);

            element = new DemoColorCodedPickingElement(size);
            element.Initialize();
            //element.BeforeRendering += element_BeforeRendering;
            //element.AfterRendering += element_AfterRendering;

            Padding        uiPadding = new System.Windows.Forms.Padding(10, 10, 10, 10);
            Size           uiSize    = new System.Drawing.Size(50, 50);
            IUILayoutParam uiParam   = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom, uiPadding, uiSize);

            uiAxis = new SimpleUIAxis(uiParam);
            uiAxis.Initialize();

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;

            this.Load += FormColorCodedPicking_Load;
        }
        void ScientificVisual3DControl_Resized(object sender, EventArgs e)
        {
            ScientificCamera camera = this.sceneControl.Scene.CurrentCamera as ScientificCamera;

            if (camera.CameraType == CameraTypes.Perspecitive)
            {
                IPerspectiveViewCamera perspecitive = camera;
                perspecitive.AdjustCamera(this.modelContainer.BoundingBox, this.sceneControl.OpenGL);
            }
            else if (camera.CameraType == CameraTypes.Ortho)
            {
                IOrthoViewCamera orthoCamera = camera;
                orthoCamera.AdjustCamera(this.modelContainer.BoundingBox, this.sceneControl.OpenGL);
            }
            else
            {
                throw new NotImplementedException();
            }
            ManualRender(this.sceneControl);
        }
Exemplo n.º 19
0
        public FormParticleSimulator()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                //this.camera.Position = new vec3(111420.30f, 125347.80f, 116062.80f);
                this.camera.Position = new vec3(397, 447, 414);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            rotator = new SatelliteRotator(this.camera);
            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;

            element = new ParticleSimulatorExample();
            element.Initialize();

            //element.BeforeRendering += element_BeforeRendering;
            //element.AfterRendering += element_AfterRendering;

            IUILayoutParam param = new IUILayoutParam(
                AnchorStyles.Left | AnchorStyles.Bottom,
                new Padding(10, 10, 10, 10), new Size(50, 50));

            uiAxis = new SimpleUIAxis(param);
            uiAxis.Initialize();

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
            this.Load += Form_Load;
        }
Exemplo n.º 20
0
        public FormSimpleUIColorIndicator()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            satelliteRoration = new SatelliteRotator(camera);

            ColorPalette colorPalette = ColorPaletteFactory.CreateRainbow();

            Padding        padding = new System.Windows.Forms.Padding(40, 40, 40, 40);
            Size           size    = new Size(100, 30);
            IUILayoutParam param;

            param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right, padding, size);
            this.colorIndicator = new SimpleUIColorIndicator(param, colorPalette, new GLColor(1, 1, 1, 1), -100, 100, 5);
            this.colorIndicator.Initialize();

            axisElement = new AxisElement();
            axisElement.Initialize();
            axisElement.BeforeRendering += axisElement_BeforeRendering;
            axisElement.AfterRendering  += axisElement_AfterRendering;

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
        private void InitializeSceneControl()
        {
            var root = this.sceneControl.Scene.SceneContainer;

            root.Children.Clear();
            root.Effects.Clear();
            //InitializeSceneAttributes(root);
            this.modelContainer = new ModelContainer();
            this.modelContainer.RenderBoundingBox = false;
            root.AddChild(this.modelContainer);

            {
                var model = new ScientificModel(100 * 100 * 100, BeginMode.Points);
                ScientificModelElement element = new ScientificModelElement(
                    model, this.sceneControl.Scene.CurrentCamera as ScientificCamera);
                this.modelContainer.AddChild(element);
                this.modelContainer.BoundingBox.Extend(model.BoundingBox.MaxPosition);
                this.modelContainer.BoundingBox.Extend(model.BoundingBox.MinPosition);
            }

            var camera = new ScientificCamera()
            {
                Position = new Vertex(-10f, -10f, 10f),
                Target   = new Vertex(0f, 0f, 0f),
                UpVector = new Vertex(0f, 0f, 1f)
            };

            this.sceneControl.Scene.CurrentCamera = camera;

            this.cameraRotation        = new SatelliteRotation();
            this.cameraRotation.Camera = this.sceneControl.Scene.CurrentCamera as ScientificCamera;

            this.sceneControl.MouseDown  += ScientificVisual3DControl_MouseDown;
            this.sceneControl.MouseMove  += ScientificVisual3DControl_MouseMove;
            this.sceneControl.MouseUp    += ScientificVisual3DControl_MouseUp;
            this.sceneControl.MouseWheel += ScientificVisual3DControl_MouseWheel;
            this.sceneControl.Resized    += ScientificVisual3DControl_Resized;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormModernOpenGLControlDemo"/> class.
        /// </summary>
        public FormModernSceneControlDemo()
        {
            InitializeComponent();

            // prepare camera.
            ScientificCamera camera = new ScientificCamera(CameraTypes.Perspecitive);

            camera.Position            = new SharpGL.SceneGraph.Vertex(0, 0, 5);
            camera.Target              = new SharpGL.SceneGraph.Vertex();
            camera.UpVector            = new SharpGL.SceneGraph.Vertex(0, 1, 0);
            this.cameraRotation.Camera = camera;
            this.sceneElement.Camera   = camera;

            // prepare scene's settings.
            this.sceneControl.Scene.SceneContainer.Children.Clear();
            this.sceneControl.Scene.SceneContainer.Effects.Clear();
            this.sceneControl.Scene.ClearColor = new GLColor(0.4f, 0.6f, 0.9f, 0.5f);

            // prepare model's element.
            this.sceneElement.Initialise(this.sceneControl.OpenGL,
                                         this.sceneControl.Width, this.sceneControl.Height);
            this.sceneControl.Scene.SceneContainer.AddChild(this.sceneElement);
        }
Exemplo n.º 23
0
        public FormWholeFontTextureElement()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
            }

            rotator    = new SatelliteRotator(this.camera);
            this.Load += FormWholeFontTextureElement_Load;

            element = new WholeFontTextureElement("FormWholeFontTextureElement.png", "FormWholeFontTextureElement.xml");
            element.Initialize();

            element.BeforeRendering += element_BeforeRendering;
            element.AfterRendering  += element_AfterRendering;

            IUILayoutParam param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom,
                                                      new Padding(10, 10, 10, 10), new Size(40, 40));

            uiAxis = new SimpleUIAxis(param);
            uiAxis.Initialize();

            this.glCanvas1.MouseWheel += glCanvas1_MouseWheel;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
            this.glCanvas1.MouseDown  += glCanvas1_MouseDown;
            this.glCanvas1.MouseMove  += glCanvas1_MouseMove;
            this.glCanvas1.MouseUp    += glCanvas1_MouseUp;
            this.glCanvas1.OpenGLDraw += glCanvas1_OpenGLDraw;
            this.glCanvas1.Resize     += glCanvas1_Resize;
        }
Exemplo n.º 24
0
        //Random random = new Random();

        /// <summary>
        /// Initializes a new instance of the <see cref="FormOpenGLControl"/> class.
        /// </summary>
        public FormMySceneControl()
        {
            InitializeComponent();

            //for (int i = 0; i < verticesCount; i++)
            //{
            //    var position = new Vertex();
            //    position.X = (float)random.NextDouble() * 2 - 1;
            //    position.Y = (float)random.NextDouble() * 2 - 1;
            //    position.Z = (float)random.NextDouble() * 2 - 1;
            //    positions.Add(position);
            //    var color = new GLColor();
            //    color.R = (float)random.NextDouble();
            //    color.G = (float)random.NextDouble();
            //    color.B = (float)random.NextDouble();
            //    color.A = (float)random.NextDouble();
            //    colors.Add(color);
            //}

            this.camera          = this.mySceneControl.Scene.CurrentCamera;
            this.camera.Target   = new SharpGL.SceneGraph.Vertex(0, 0, 0);
            this.camera.UpVector = new SharpGL.SceneGraph.Vertex(0, 1, 0);
            this.camera.Position = new SharpGL.SceneGraph.Vertex(0, 0, 10);
            IOrthoCamera orthoCamera = this.camera;

            orthoCamera.Left  = -10; orthoCamera.Bottom = -10; orthoCamera.Near = 0;
            orthoCamera.Right = 10; orthoCamera.Top = 10; orthoCamera.Far = 15;
            //this.sceneControl.Scene.CurrentCamera = camera;
            this.cameraRotation.Camera = this.camera;
            this.mySceneControl.Scene.SceneContainer.Children.Clear();
            this.mySceneControl.Scene.SceneContainer.Effects.Clear();
            //var model = new ModelDemo(
            //    new Vertex(-1, -1, -1), new Vertex(1, 1, 1),
            //    verticesCount, SharpGL.Enumerations.BeginMode.Points);
            //this.mySceneControl.Scene.SceneContainer.AddChild(model);
            {
                var model = new ScientificModel(verticesCount, SharpGL.Enumerations.BeginMode.Points);
                model.Build(new Vertex(-3, -3, -3), new Vertex(-1, -1, -1));
                var element = new ScientificModelElement(model, this.mySceneControl.Scene.CurrentCamera);
                this.mySceneControl.Scene.SceneContainer.AddChild(element);
            }
            {
                var model = new ScientificModel(verticesCount, SharpGL.Enumerations.BeginMode.Points);
                model.Build(new Vertex(-1, -1, -1), new Vertex(1, 1, 1));
                var element = new ScientificModelElement(model, this.mySceneControl.Scene.CurrentCamera);
                this.mySceneControl.Scene.SceneContainer.AddChild(element);
            }
            {
                var model = new ScientificModel(verticesCount, SharpGL.Enumerations.BeginMode.Points);
                model.Build(new Vertex(1, 1, 1), new Vertex(3, 3, 3));
                var element = new ScientificModelElement(model, this.mySceneControl.Scene.CurrentCamera);
                this.mySceneControl.Scene.SceneContainer.AddChild(element);
            }
            {
                var modelContainer = new ModelContainer();
                modelContainer.BoundingBox.Set(-3.1f, -3.1f, -3.1f, 3.1f, 3.1f, 3.1f);
                this.mySceneControl.Scene.SceneContainer.AddChild(modelContainer);
            }

            this.mySceneControl.MouseWheel += openGLControl_MouseWheel;
        }