//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; }
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; }
public SimpleUIColorIndicator(IUILayoutParam param, ColorPalette colorPalette, GLColor textColor, float min, float max, float step) { this.bar = new SimpleUIColorIndicatorBar(param, colorPalette, min, max, step); float[] coords = colorPalette.Coords; float coordLength = coords[coords.Length - 1] - coords[0]; this.numbers = new SimpleUIPointSpriteStringElement[coords.Length]; const float posY = -1.0f; this.numbers[0] = new SimpleUIPointSpriteStringElement( param, (-100.0f).ToShortString(), new vec3(-0.5f, posY, 0), textColor, 20); for (int i = 1; i < coords.Length; i++) { float x = (coords[i] - coords[0]) / coordLength - 0.5f; if (i + 1 == coords.Length) { var number = new SimpleUIPointSpriteStringElement(param, (100.0f).ToShortString(), new vec3(x, posY, 0), textColor, 20); this.numbers[i] = number; } else { var number = new SimpleUIPointSpriteStringElement(param, (-100.0f + i * (100 - (-100)) / 5).ToShortString(), new vec3(x, posY, 0), textColor, 20); this.numbers[i] = number; } } }
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); } }
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; }
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(); }
public FormSimpleUIRect() { 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, 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; }
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(); }
/// <summary> /// /// </summary> /// <param name="anchor">the edges of the viewport to which a SimpleUIRect is bound and determines how it is resized with its parent. /// <para>something like AnchorStyles.Left | AnchorStyles.Bottom.</para></param> /// <param name="margin">the space between viewport and SimpleRect.</param> /// <param name="size">Stores width when <see cref="OpenGLUIRect.Anchor"/>.Left & <see cref="OpenGLUIRect.Anchor"/>.Right is <see cref="OpenGLUIRect.Anchor"/>.None. /// <para> and height when <see cref="OpenGLUIRect.Anchor"/>.Top & <see cref="OpenGLUIRect.Anchor"/>.Bottom is <see cref="OpenGLUIRect.Anchor"/>.None.</para></param> /// <param name="zNear"></param> /// <param name="zFar"></param> /// <param name="rectColor">default color is red.</param> //public LegacySimpleUIRect(AnchorStyles anchor, Padding margin, System.Drawing.Size size, int zNear = -1000, int zFar = 1000, GLColor rectColor = null) public LegacySimpleUIRect(IUILayoutParam param, GLColor rectColor = null) { this.Param = param; if (rectColor == null) { this.RectColor = new GLColor(1, 0, 0, 1); } else { this.RectColor = rectColor; } }
/// <summary> /// /// </summary> /// <param name="anchor">the edges of the viewport to which a SimpleUIRect is bound and determines how it is resized with its parent. /// <para>something like AnchorStyles.Left | AnchorStyles.Bottom.</para></param> /// <param name="margin">the space between viewport and SimpleRect.</param> /// <param name="size">Stores width when <see cref="OpenGLUIRect.Anchor"/>.Left & <see cref="OpenGLUIRect.Anchor"/>.Right is <see cref="OpenGLUIRect.Anchor"/>.None. /// <para> and height when <see cref="OpenGLUIRect.Anchor"/>.Top & <see cref="OpenGLUIRect.Anchor"/>.Bottom is <see cref="OpenGLUIRect.Anchor"/>.None.</para></param> /// <param name="zNear"></param> /// <param name="zFar"></param> /// <param name="rectColor">default color is red.</param> public SimpleUIColorIndicatorBar(IUILayoutParam param, ColorPalette colorPalette, float min, float max, float step) { IUILayout layout = this; layout.Param = param; this.ColorPalette = colorPalette; this.Min = min; this.Max = max; this.Step = step; }
/// <summary> /// /// </summary> /// <param name="anchor">the edges of the viewport to which a SimpleUIRect is bound and determines how it is resized with its parent. /// <para>something like AnchorStyles.Left | AnchorStyles.Bottom.</para></param> /// <param name="margin">the space between viewport and SimpleRect.</param> /// <param name="size">Stores width when <see cref="OpenGLUIRect.Anchor"/>.Left & <see cref="OpenGLUIRect.Anchor"/>.Right is <see cref="OpenGLUIRect.Anchor"/>.None. /// <para> and height when <see cref="OpenGLUIRect.Anchor"/>.Top & <see cref="OpenGLUIRect.Anchor"/>.Bottom is <see cref="OpenGLUIRect.Anchor"/>.None.</para></param> /// <param name="zNear"></param> /// <param name="zFar"></param> /// <param name="rectColor">default color is red.</param> public SimpleUIAxis(IUILayoutParam param, GLColor rectColor = null, float radius = 0.3f, float axisLength = 10, int faceCount = 10) { // 把AxiesElement缩放到恰好放进此UI radius = radius / axisLength / 2; axisLength = 0.5f; this.axisElement = new AxisElement(radius, axisLength, faceCount); IUILayout layout = this; layout.Param = param; }
/// <summary> /// /// </summary> /// <param name="anchor">the edges of the viewport to which a SimpleUIRect is bound and determines how it is resized with its parent. /// <para>something like AnchorStyles.Left | AnchorStyles.Bottom.</para></param> /// <param name="margin">the space between viewport and SimpleRect.</param> /// <param name="size">Stores width when <see cref="OpenGLUIRect.Anchor"/>.Left & <see cref="OpenGLUIRect.Anchor"/>.Right is <see cref="OpenGLUIRect.Anchor"/>.None. /// <para> and height when <see cref="OpenGLUIRect.Anchor"/>.Top & <see cref="OpenGLUIRect.Anchor"/>.Bottom is <see cref="OpenGLUIRect.Anchor"/>.None.</para></param> /// <param name="zNear"></param> /// <param name="zFar"></param> /// <param name="rectColor">default color is red.</param> public SimpleUIRect(IUILayoutParam param, GLColor rectColor = null) { IUILayout layout = this; layout.Param = param; if (rectColor == null) { this.rectColor = new vec3(0, 0, 1); } else { this.rectColor = new vec3(rectColor.R, rectColor.G, rectColor.B); } }
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; }
//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; }
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; }
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; }
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; }
public FormSimpleUIColorIndicator() { 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); 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; }
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; }
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; }
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; }
//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; }
/// <summary> /// /// </summary> /// <param name="anchor">the edges of the viewport to which a SimpleUIRect is bound and determines how it is resized with its parent. /// <para>something like AnchorStyles.Left | AnchorStyles.Bottom.</para></param> /// <param name="margin">the space between viewport and SimpleRect.</param> /// <param name="size">Stores width when <see cref="OpenGLUIRect.Anchor"/>.Left & <see cref="OpenGLUIRect.Anchor"/>.Right is <see cref="OpenGLUIRect.Anchor"/>.None. /// <para> and height when <see cref="OpenGLUIRect.Anchor"/>.Top & <see cref="OpenGLUIRect.Anchor"/>.Bottom is <see cref="OpenGLUIRect.Anchor"/>.None.</para></param> /// <param name="zNear"></param> /// <param name="zFar"></param> /// <param name="rectColor">default color is red.</param> public SimpleUICube(IUILayoutParam param) { IUILayout layout = this; layout.Param = param; }
//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; }
public SimpleUIColorIndicator(IUILayoutParam param, ColorPalette colorPalette, GLColor textColor, float min, float max, float step) { this.bar = new SimpleUIColorIndicatorBar(param, colorPalette, min, max, step); }