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; } } }
public FormToon() { 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; }
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 FormLoadTexture() { 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 LoadTextureExample(); 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; }
/// <summary> /// /// </summary> /// <param name="param">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="content"></param> public DummyLabel(IUILayoutParam param, string content) { this.renderer = new StringRenderer(content.GetModel()); IUILayout layout = this; layout.Param = param; }
public SimpleUIPointSpriteStringElement(IUILayoutParam param, string content, vec3 position, GLColor color = null, int fontSize = 32, int maxRowWidth = 256, FontResource fontResource = null) { IUILayout layout = this; layout.Param = param; this.element = new PointSpriteStringElement(content, position, color, fontSize, maxRowWidth, fontResource); }
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 FormLegacyTexture3D2() { 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); //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 DemoLegacyGLTexture3D(); 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 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); } }
/// <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 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.8f, 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; }
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; }
public FormMapBuffer() { 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); } const int size = 3; this.camera.Position = new vec3(size * 3, size * 3, size * 3); rotator = new SatelliteRotator(this.camera); element = new DemoMapBuffer(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 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 FormParticleSimulator() { 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); //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(); 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 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; }
/// <summary> /// 根据UI元素的布局设定,计算其应有的宽高及其在ortho()中应有的参数。 /// </summary> /// <param name="uiElement"></param> /// <param name="viewportWidth"></param> /// <param name="viewportHeight"></param> /// <param name="args"></param> static void CalculateCoords(IUILayout uiElement, int viewportWidth, int viewportHeight, IUILayoutArgs args) { IUILayoutParam param = uiElement.Param; if ((param.Anchor & leftRightAnchor) == leftRightAnchor) { args.UIWidth = viewportWidth - param.Margin.Left - param.Margin.Right; if (args.UIWidth < 0) { args.UIWidth = 0; } } else { args.UIWidth = param.Size.Width; } if ((param.Anchor & topBottomAnchor) == topBottomAnchor) { args.UIHeight = viewportHeight - param.Margin.Top - param.Margin.Bottom; if (args.UIHeight < 0) { args.UIHeight = 0; } } else { args.UIHeight = param.Size.Height; } if ((param.Anchor & leftRightAnchor) == AnchorStyles.None) { args.left = -(args.UIWidth / 2 + (viewportWidth - args.UIWidth) * ((double)param.Margin.Left / (double)(param.Margin.Left + param.Margin.Right))); } else if ((param.Anchor & leftRightAnchor) == AnchorStyles.Left) { args.left = -(args.UIWidth / 2 + param.Margin.Left); } else if ((param.Anchor & leftRightAnchor) == AnchorStyles.Right) { args.left = -(viewportWidth - args.UIWidth / 2 - param.Margin.Right); } else // if ((Anchor & leftRightAnchor) == leftRightAnchor) { args.left = -(args.UIWidth / 2 + param.Margin.Left); } if ((param.Anchor & topBottomAnchor) == AnchorStyles.None) { args.bottom = -viewportHeight / 2; args.bottom = -(args.UIHeight / 2 + (viewportHeight - args.UIHeight) * ((double)param.Margin.Bottom / (double)(param.Margin.Bottom + param.Margin.Top))); } else if ((param.Anchor & topBottomAnchor) == AnchorStyles.Bottom) { args.bottom = -(args.UIHeight / 2 + param.Margin.Bottom); } else if ((param.Anchor & topBottomAnchor) == AnchorStyles.Top) { args.bottom = -(viewportHeight - args.UIHeight / 2 - param.Margin.Top); } else // if ((Anchor & topBottomAnchor) == topBottomAnchor) { args.bottom = -(args.UIHeight / 2 + param.Margin.Bottom); } }
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(); }
void ISupportInitialize.EndInit() { CreateRenderContext(); this.camera = new Camera(CameraType.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 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; }
/// <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; }