Exemplo n.º 1
0
        void ISupportInitialize.EndInit()
        {
            CreateRenderContext();

            this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.Width, this.Height);

            this.rotator = new SatelliteRotator(this.camera);

            this.MouseDown += scientificVisual3DControl1_MouseDown;
            this.MouseMove += scientificVisual3DControl1_MouseMove;
            this.MouseUp   += scientificVisual3DControl1_MouseUp;

            {
                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.ElementList.Add(uiAxis);
            }
            {
                IUILayoutParam param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
                                                          new Padding(100, 30, 40, 30), new Size(30, 30));
                ColorPalette colorPalette = ColorPaletteFactory.CreateRainbow();
                uiColorIndicator = new SimpleUIColorIndicator(param, colorPalette, new Objects.GLColor(1, 1, 1, 1), -100, 100, 5);
                uiColorIndicator.Initialize();
                this.ElementList.Add(uiColorIndicator);
            }
        }
Exemplo n.º 2
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.º 3
0
        public FormPolkadot3d()
        {
            InitializeComponent();

            this.camera = new Camera(CameraType.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);

            satelliteRoration = new SatelliteRotator(camera);

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

            param            = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom, padding, size);
            uiLeftBottomAxis = new SimpleUIAxis(param);
            uiLeftBottomAxis.Initialize();

            CreateElement();

            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;

            Application.Idle += Application_Idle;
        }
Exemplo n.º 4
0
        //Camera modelRotationCamera;
        //SatelliteRotator modelRotator;
        //private float rotateAngle;

        public FormPhongPointLight()
        {
            InitializeComponent();

            this.camera          = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
            this.camera.Position = new GLM.vec3(5, 5, 5);

            this.cameraRotator = new SatelliteRotator(this.camera);

            //this.modelRotationCamera = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
            //this.modelRotator = new SatelliteRotator(this.modelRotationCamera);
            this.modelRotator = new ArcBallRotator(this.camera);

            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();

            IModel model = (new TeapotFactory()).Create(1.0f);

            this.renderer = new PhongPointLightRenderer(model);
            this.renderer.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.º 5
0
        private void FormTransformFeedback_Load(object sender, EventArgs e)
        {
            IUILayoutParam param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom,
                                                      new Padding(10, 10, 10, 10), new Size(50, 50));

            this.uiAxis = new SimpleUIAxis(param);

            //frmWhiteBoard = new FormWhiteBoard();
            //frmWhiteBoard.Show();

            //GL.Enable(GL.GL_DEBUG_OUTPUT);
            //GL.Enable(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
            //GL.DebugMessageControl(
            //    Enumerations.DebugMessageControlSource.DONT_CARE,
            //    Enumerations.DebugMessageControlType.DONT_CARE,
            //    Enumerations.DebugMessageControlSeverity.DONT_CARE, 0, null, true);
            //GL.DebugMessageCallback(this.CallbackProc, this.Handle);

            GL.GenQueries(1, TimerQueryName);

            // begin
            GL.GenQueries(1, Query);

            InitProgram();

            InitBuffer();

            initVertexArray();

            initFeedback();
        }
Exemplo n.º 6
0
        public FormWholeFontTextureElement()
        {
            InitializeComponent();

            this.camera = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);

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

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

            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.º 7
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();
        }
Exemplo n.º 8
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 Camera(CameraType.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;
        }
Exemplo n.º 9
0
        //Camera modelRotationCamera;
        //SatelliteRotator modelRotator;
        //private float rotateAngle;

        public FormSimpleRenderer()
        {
            InitializeComponent();

            this.camera          = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
            this.camera.Position = new GLM.vec3(5, 5, 5);

            this.cameraRotator = new SatelliteRotator(this.camera);

            //this.modelRotationCamera = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
            //this.modelRotator = new SatelliteRotator(this.modelRotationCamera);
            this.modelRotator = new ArcBallRotator(this.camera);

            {
                const string           strGround = "Ground";
                IConvert2BufferPointer model     = new Ground();
                CodeShader[]           shaders   = new CodeShader[2];
                shaders[0] = CSharpGL.Objects.Common.ShaderLoadingHelper.LoadShaderSourceCode(strGround, CodeShader.GLSLShaderType.VertexShader);
                shaders[1] = CSharpGL.Objects.Common.ShaderLoadingHelper.LoadShaderSourceCode(strGround, CodeShader.GLSLShaderType.FragmentShader);
                PropertyNameMap propertyNameMap = CSharpGL.Objects.Common.ShaderLoadingHelper.LoadPropertyNameMap(strGround);
                UniformNameMap  uniformNameMap  = CSharpGL.Objects.Common.ShaderLoadingHelper.LoadUniformNameMap(strGround);
                this.groundRenderer = new ModernRenderer(model, shaders, propertyNameMap, uniformNameMap);
                this.groundRenderer.Initialize();
            }

            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();

            {
                IModel model = (new TeapotFactory()).Create(1.0f);
                this.renderer = new SimpleRenderer(model);
                this.renderer.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.º 10
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;
        }
Exemplo n.º 11
0
        public FormCubeMap()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                //CameraDictionary.Instance.Add(this.GetType().Name, this.camera);
                this.camera.UpVector = new vec3(-0.07f, 0.96f, 0.29f);
                this.camera.Position = new vec3(0.03f, 0.03f, 0.03f);
            }

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

            element = new CubeMapExample();
            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.º 12
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.º 13
0
        public FormDebugging()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new Camera(CameraType.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 | AnchorStyles.Right, padding, size);
            uiLeftBottomRect     = new SimpleUIRect(param);
            legacyLeftBottomRect = new LegacySimpleUIRect(param, new Objects.GLColor(1, 1, 1, 1));
            param                = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom, padding, size);
            uiLeftBottomAxis     = new SimpleUIAxis(param);

            uiLeftBottomRect.Initialize();
            legacyLeftBottomRect.Initialize();
            uiLeftBottomAxis.Initialize();

            axisElement = new AxisElement();
            axisElement.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.º 14
0
        public FormVolumeRendering00()
        {
            InitializeComponent();

            // 解析文件,得到3D数据纹理
            string datafilePrefix = @"data\floordata";

            string[] filenames = new string[20];
            for (int i = 0; i < 20; i++)
            {
                string filename = datafilePrefix + (i + 1).ToString() + ".txt";
                filenames[i] = filename;
            }
            processor.ReadFile(filenames, 921, 921, 20);

            // 初始化camera及其rotator
            this.camera          = new Camera(CameraType.Ortho, this.glCanvas1.Width, this.glCanvas1.Height);
            this.camera.Position = new vec3(0, 0, 5);
            this.camera.Target   = new vec3(0, 0, 0);
            this.camera.UpVector = new vec3(0, 1, 0);
            this.rotator         = new SatelliteRotator(this.camera);
            radarRenderer.Initialize(processor);

            // 初始化axis
            this.axis = new SimpleUIAxis(
                new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom,
                                   new Padding(10, 10, 10, 10), new Size(50, 50)));
            this.axis.Initialize();

            // 初始化各个事件
            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;
            this.glCanvas1.KeyPress   += glCanvas1_KeyPress;
        }
Exemplo n.º 15
0
        public FormWholeFontTextureElement()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new Camera(CameraType.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.º 16
0
        public FormLightingExample()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new Camera(CameraType.Ortho, 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 LightingExample();
            element.Initialize();

            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.º 17
0
        public FormIceCream()
        {
            InitializeComponent();

            //if (CameraDictionary.Instance.ContainsKey(this.GetType().Name))
            //{
            //    this.camera = CameraDictionary.Instance[this.GetType().Name];
            //}
            //else
            {
                this.camera = new Camera(CameraType.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();

            param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom, padding, size);
            //uiLeftBottomRect = new SimpleUIRect(param);
            //param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Top, padding, size);
            //uiLeftTopRect = new SimpleUIRect(param);
            //param = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Bottom, padding, size);
            //uiRightBottomRect = new SimpleUIRect(param);
            //param = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Top, padding, size);
            //uiRightTopRect = new SimpleUIRect(param);

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

            sphereElement = new IceCreamElement();
            sphereElement.Initialize();
            sphereElement.BeforeRendering += cubeElement_BeforeRendering;
            sphereElement.AfterRendering  += cubeElement_AfterRendering;

            lightElement = new PyramidElement();
            lightElement.Initialize();
            lightElement.BeforeRendering += lightElement_BeforeRendering;
            lightElement.AfterRendering  += lightElement_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.º 18
0
        //Camera modelRotationCamera;
        //SatelliteRotator modelRotator;
        //private float rotateAngle;

        public FormNormalLine()
        {
            InitializeComponent();

            this.camera          = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
            this.camera.Position = new GLM.vec3(50, 5, 5);

            this.cameraRotator = new SatelliteRotator(this.camera);

            //this.modelRotationCamera = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
            //this.modelRotator = new SatelliteRotator(this.modelRotationCamera);
            this.modelRotator = new ArcBallRotator(this.camera);

            //this.groundRenderer = new GroundRenderer(new Ground(100, 100, 0.1f, 0.1f));
            this.groundRenderer = new GroundRenderer(new Ground(100, 100, 1f, 1f));
            this.groundRenderer.Initialize();

            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();

            IModel model = (new TeapotFactory()).Create(1.0f);

            this.renderer = new NormalLineRenderer(model);
            this.renderer.Initialize();//不在此显式初始化也可以。

            //this.demoLifebar = new DemoLifeBar(0.2f, 0.02f, 4);
            //this.demolifebarRenderer = new NormalLineRenderer(this.demoLifebar);
            //this.demolifebarRenderer.Initialize();

            this.lifebarRenderer = new LifeBarRenderer(new LifeBar(2f, 0.2f, 4f));
            this.lifebarRenderer.Initialize();

            //StringModel stringModel = DummyStringModelFactory.GetModel("teapot");
            this.stringRenderer = new StringRenderer("teapot".GetModel());
            this.stringRenderer.Initialize();

            uiParam    = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Bottom, new Padding(10, 10, 120, 10), new Size(50, 50));
            this.label = new DummyLabel(uiParam, "Hello Label!");
            this.label.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;

            //var displayer = new FormNormalLineDisplay(this.demolifebarRenderer);
            //displayer.Show();
            var displayer = new FormNormalLineDisplay(this.renderer);

            displayer.Show();
            var cameraController = new FormCameraController(this.camera);

            cameraController.Show();

            Application.Idle += Application_Idle;
        }
Exemplo n.º 19
0
        //Camera modelRotationCamera;
        //SatelliteRotator modelRotator;
        //private float rotateAngle;

        public FormNewNormalLine()
        {
            InitializeComponent();

            this.camera          = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
            this.camera.Position = new GLM.vec3(50, 5, 5);

            this.cameraRotator = new SatelliteRotator(this.camera);

            //this.modelRotationCamera = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
            //this.modelRotator = new SatelliteRotator(this.modelRotationCamera);
            this.modelRotator = new ArcBallRotator(this.camera);

            {
                const string           strGround = "Ground";
                IConvert2BufferPointer model     = new Ground();
                CodeShader[]           shaders   = new CodeShader[2];
                shaders[0] = CSharpGL.Objects.Common.ShaderLoadingHelper.LoadShaderSourceCode(strGround, CodeShader.GLSLShaderType.VertexShader);
                shaders[1] = CSharpGL.Objects.Common.ShaderLoadingHelper.LoadShaderSourceCode(strGround, CodeShader.GLSLShaderType.FragmentShader);
                PropertyNameMap propertyNameMap = CSharpGL.Objects.Common.ShaderLoadingHelper.LoadPropertyNameMap(strGround);
                UniformNameMap  uniformNameMap  = CSharpGL.Objects.Common.ShaderLoadingHelper.LoadUniformNameMap(strGround);
                this.groundRenderer = new ModernRenderer(model, shaders, propertyNameMap, uniformNameMap);
                this.groundRenderer.Initialize();
            }

            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();

            //IModel model = (new TeapotFactory()).Create(1.0f);
            {
                IConvert2BufferPointer model       = new NewNormalLineDemoModel();
                CodeShader[]           codeShaders = new CodeShader[3];
                codeShaders[0] = new CodeShader(ShaderHelper.Load("NewNormalLine.vert"), CodeShader.GLSLShaderType.VertexShader);
                codeShaders[1] = new CodeShader(ShaderHelper.Load("NewNormalLine.geom"), CodeShader.GLSLShaderType.GeometryShader);
                codeShaders[2] = new CodeShader(ShaderHelper.Load("NewNormalLine.frag"), CodeShader.GLSLShaderType.FragmentShader);
                var propertyNameMap = new PropertyNameMap();
                propertyNameMap.Add("in_Position", NewNormalLineDemoModel.strPosition);
                propertyNameMap.Add("in_Normal", NewNormalLineDemoModel.strNormal);
                var uniformNameMap = new UniformNameMap();
                uniformNameMap.Add("model matrix", "modelMatrix");
                uniformNameMap.Add("view matrix", "viewMatrix");
                uniformNameMap.Add("projection matrix", "projectionMatrix");
                uniformNameMap.Add("show model", "showModel");
                uniformNameMap.Add("show normal", "showNormal");
                uniformNameMap.Add("normal length", "normalLength");
                this.renderer = new ModernRenderer(model, codeShaders, propertyNameMap, uniformNameMap);
                this.renderer.Initialize();//不在此显式初始化也可以。
                this.renderer.SetUniformValue("show model", 1.0f);
                this.renderer.SetUniformValue("show normal", 1.0f);
                this.renderer.SetUniformValue("normal length", 1.0f);
            }

            //this.demoLifebar = new DemoLifeBar(0.2f, 0.02f, 4);
            //this.demolifebarRenderer = new NormalLineRenderer(this.demoLifebar);
            //this.demolifebarRenderer.Initialize();

            this.lifebarRenderer = new LifeBarRenderer(new LifeBar(2f, 0.2f, 4f));
            this.lifebarRenderer.Initialize();

            //StringModel stringModel = DummyStringModelFactory.GetModel("teapot");
            this.stringRenderer = new StringRenderer("teapot".GetDummyModel());
            this.stringRenderer.Initialize();

            uiParam    = new IUILayoutParam(AnchorStyles.Right | AnchorStyles.Bottom, new Padding(10, 10, 120, 10), new Size(50, 50));
            this.label = new DummyLabel(uiParam, "Hello Label!");
            this.label.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;

            Application.Idle += Application_Idle;
        }