Beispiel #1
0
        void ReleaseDesignerOutlets()
        {
            if (RevealButtonItem != null)
            {
                RevealButtonItem.Dispose();
                RevealButtonItem = null;
            }

            if (DummyLabel != null)
            {
                DummyLabel.Dispose();
                DummyLabel = null;
            }
        }
Beispiel #2
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;
        }
Beispiel #3
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;
        }