public GLText( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar, FontResource fontResource = null, int maxCharCount = 100) : base(null, anchor, margin, size, zNear, zFar) { if (fontResource == null) { this.fontResource = FontResource.Default; } else { this.fontResource = fontResource; } this.Name = "GLText"; var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.GLText.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.GLText.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("position", "position"); map.Add("uv", "uv"); var model = new TextModel(maxCharCount); Renderer renderer = new Renderer(model, shaderCodes, map); this.model = model; this.Renderer = renderer; }
/// <summary> /// /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> /// <param name="fontTexture"></param> /// <param name="maxCharCount"></param> public UIText( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar, IFontTexture fontTexture = null, int maxCharCount = 100) : base(anchor, margin, size, zNear, zFar) { if (fontTexture == null) { this.fontTexture = FontTexture.Default; } // FontResource.Default; } else { this.fontTexture = fontTexture; } var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.TextModel.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.TextModel.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("position", TextModel.strPosition); map.Add("uv", TextModel.strUV); var model = new TextModel(maxCharCount); var renderer = new Renderer(model, shaderCodes, map); this.textModel = model; this.Renderer = renderer; }
/// <summary> /// /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIRenderer( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) { this.Children = new ChildList <UIRenderer>(this);// new ILayoutList(this); this.Anchor = anchor; this.Margin = margin; this.Size = size; this.zNear = zNear; this.zFar = zFar; }
/// <summary> /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIColorPaletteMarkersRenderer(int maxMarkerCount, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(anchor, margin, size, zNear, zFar) { var model = new LinesModel(maxMarkerCount); this.Renderer = LinesRenderer.Create(model); }
/// <summary> /// opengl UI for Axis /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> /// <param name="partCount">24 as default.</param> public UIAxis( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar, int partCount = 24) : base(anchor, margin, size, zNear, zFar) { AxisRenderer renderer = AxisRenderer.Create(partCount); this.Renderer = renderer; }
public UIRenderer(Renderer renderer, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) { this.Controls = new ILayoutCollection(this); this.Renderer = renderer; this.Anchor = anchor; this.Margin = margin; this.Size = size; this.zNear = zNear; this.zFar = zFar; }
/// <summary> /// Render scene to an area of canvas. /// </summary> /// <param name="camera"></param> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> public ViewPort(ICamera camera, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size) { this.Children = new ChildList <ViewPort>(this);// new ILayoutList(this); this.Camera = camera; this.Anchor = anchor; this.Margin = margin; this.Size = size; }
/// <summary> /// /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIRenderer( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) { this.Children = new TreeNodeChildren(this);// new ILayoutList(this); this.Anchor = anchor; this.Margin = margin; this.Size = size; this.zNear = zNear; this.zFar = zFar; this.ClearDepthBuffer = true; this.Enabled = true; }
// 判断停靠位置 private void mStopAnthor() { if (this.Top < screenRect.Bottom / 2) { if (this.Left < screenRect.Right / 2) { if (this.Top < this.Left) { StopAanhor = System.Windows.Forms.AnchorStyles.Top; } else { StopAanhor = System.Windows.Forms.AnchorStyles.Left; } } else { if (this.Top < (screenRect.Right - this.Left + this.Width)) { StopAanhor = System.Windows.Forms.AnchorStyles.Top; } else { StopAanhor = System.Windows.Forms.AnchorStyles.Right; } } } else { if (this.Left < screenRect.Right / 2) { if ((screenRect.Bottom - this.Top - this.Height) < this.Left) { StopAanhor = System.Windows.Forms.AnchorStyles.Bottom; } else { StopAanhor = System.Windows.Forms.AnchorStyles.Left; } } else { if ((screenRect.Bottom - this.Top - this.Height) < (screenRect.Right - this.Left + this.Width)) { StopAanhor = System.Windows.Forms.AnchorStyles.Bottom; } else { StopAanhor = System.Windows.Forms.AnchorStyles.Right; } } } }
/// <summary> /// 彩色的色标带。 /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIColorPaletteBarRenderer( CodedColor[] codedColors, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(anchor, margin, size, zNear, zFar) { this.codedColors = codedColors; var model = new QuadStripModel(1); this.Renderer = QuadStripRenderer.Create(model); }
/// <summary> /// 彩色的色标带。 /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIColorPaletteColoredBarRenderer( int maxMarkerCount, CodedColor[] codedColors, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(anchor, margin, size, zNear, zFar) { this.codedColors = codedColors; var model = new QuadStripColoredModel(maxMarkerCount, codedColors.GetBitmap(1024)); this.Renderer = QuadStripColoredRenderer.Create(model); }
/// <summary> /// opengl UI for Axis /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="partCount">24 as default.</param> public UIAxis( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int partCount = 24) : base(anchor, margin, size, -Math.Max(size.Width, size.Height), Math.Max(size.Width, size.Height)) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", Axis.strPosition); map.Add("in_Color", Axis.strColor); var renderer = new Renderer(new Axis(partCount, 0.5f), shaderCodes, map); this.Renderer = renderer; }
/// <summary> /// 支持UI布局的渲染器 /// </summary> /// <param name="modernRenderer">要渲染的对象</param> /// <param name="Anchor">绑定到窗口的哪些边?</param> /// <param name="Margin">到绑定边的距离</param> /// <param name="Size">UI大小</param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIAxisRenderer( System.Windows.Forms.AnchorStyles Anchor, System.Windows.Forms.Padding Margin, System.Drawing.Size Size, int zNear = -1000, int zFar = 1000 ) : base(null, Anchor, Margin, Size, zNear, zFar) { ShaderCode[] shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"01Renderer\Simple.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"01Renderer\Simple.frag"), ShaderType.FragmentShader); var propertyNameMap = new PropertyNameMap(); propertyNameMap.Add("in_Position", "position"); propertyNameMap.Add("in_Color", "color"); PickableRenderer pickableRenderer = PickableRendererFactory.GetRenderer( new Axis(), shaderCodes, propertyNameMap, "position"); pickableRenderer.Name = string.Format("Pickable: [{0}]", "Axis"); pickableRenderer.Initialize(); { GLSwitch lineWidthSwitch = new LineWidthSwitch(10); pickableRenderer.SwitchList.Add(lineWidthSwitch); GLSwitch pointSizeSwitch = new PointSizeSwitch(10); pickableRenderer.SwitchList.Add(pointSizeSwitch); GLSwitch polygonModeSwitch = new PolygonModeSwitch(PolygonModes.Filled); pickableRenderer.SwitchList.Add(polygonModeSwitch); if (pickableRenderer is OneIndexRenderer) { GLSwitch primitiveRestartSwitch = new PrimitiveRestartSwitch((pickableRenderer as OneIndexRenderer).IndexBufferPtr); pickableRenderer.SwitchList.Add(primitiveRestartSwitch); } } this.renderer = pickableRenderer; this.textList.Add(new Tuple <vec3, string, Font, Color>(new vec3(offset, 0, 0), "X", new Font("Courier New", fontSize), Color.Red)); this.textList.Add(new Tuple <vec3, string, Font, Color>(new vec3(0, offset, 0), "Y", new Font("Courier New", fontSize), Color.Green)); this.textList.Add(new Tuple <vec3, string, Font, Color>(new vec3(0, 0, offset), "Z", new Font("Courier New", fontSize), Color.Blue)); }
/// <summary> /// opengl UI for Axis /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public GLAxis( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(null, anchor, margin, size, zNear, zFar) { this.Name = "GLAxis"; var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.GLAxis.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.GLAxis.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("in_Position", "position"); map.Add("in_Color", "color"); //PickableRenderer renderer = (new Axis()).GetRenderer(shaderCodes, map, "position"); PickableRenderer renderer = new PickableRenderer(new Axis(), shaderCodes, map, "position"); this.Renderer = renderer; }
/// <summary> /// Root view port that should never take part in rendering. /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> public SceneRootViewPort( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size) : base(null, anchor, margin, size) { }
public virtual Tuple <HorizontalAlignment, VerticalAlignment> Parse(System.Windows.Forms.AnchorStyles anchor) { if (anchor == (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Left, VerticalAlignment.Top)); } if (anchor == (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Left, VerticalAlignment.Bottom)); } if (anchor == (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.None)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Left, VerticalAlignment.Center)); } if (anchor == (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Left, VerticalAlignment.Fill)); } if (anchor == (System.Windows.Forms.AnchorStyles.None | System.Windows.Forms.AnchorStyles.Top)) { new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Top); } if (anchor == (System.Windows.Forms.AnchorStyles.None | System.Windows.Forms.AnchorStyles.Bottom)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); } if (anchor == (System.Windows.Forms.AnchorStyles.None | System.Windows.Forms.AnchorStyles.None)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Center)); } if (anchor == (System.Windows.Forms.AnchorStyles.None | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Fill)); } if (anchor == (System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Right, VerticalAlignment.Top)); } if (anchor == (System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Bottom)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Right, VerticalAlignment.Bottom)); } if (anchor == (System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.None)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Right, VerticalAlignment.Center)); } if (anchor == (System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Right, VerticalAlignment.Fill)); } if (anchor == (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Fill, VerticalAlignment.Top)); } if (anchor == (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Bottom)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Fill, VerticalAlignment.Bottom)); } if (anchor == (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.None)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Fill, VerticalAlignment.Center)); } if (anchor == (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)) { return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Fill, VerticalAlignment.Fill)); } return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Left, VerticalAlignment.Top)); }
/// <summary> /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIColorPaletteRenderer(int maxMarkerCount, CodedColor[] codedColors, System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(anchor, margin, size, zNear, zFar) { this.maxMarkerCount = maxMarkerCount; this.currentMarkersCount = maxMarkerCount; //// display this UI control's area. //this.SwitchList.Add(new ClearColorSwitch()); // color bar using texture. { var bar = new UIColorPaletteBarRenderer( codedColors, System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right, new System.Windows.Forms.Padding(marginLeft, 1, marginRight, 0), new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 3), zNear, zFar); //this.SwitchList.Add(new ClearColorSwitch(Color.Blue)); this.Children.Add(bar); this.colorPaletteBar = bar; } // color bar using vec3 color(hidden as default state) // just to compare with color bar using texture. { var bar = new UIColorPaletteColoredBarRenderer( maxMarkerCount, codedColors, System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right, new System.Windows.Forms.Padding(marginLeft, 1 + size.Height / 3, marginRight, 0), new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 3), zNear, zFar); //this.SwitchList.Add(new ClearColorSwitch(Color.Blue)); this.Children.Add(bar); this.colorPaletteBar2 = bar; bar.Enabled = false; } // white vertical lines. { var markers = new UIColorPaletteMarkersRenderer(maxMarkerCount, System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right, new System.Windows.Forms.Padding(marginLeft, 1, marginRight, 0), new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 2), zNear, zFar); //markers.SwitchList.Add(new ClearColorSwitch(Color.Red)); this.Children.Add(markers); this.markers = markers; } // labels that display values(float values) { int length = maxMarkerCount; var font = new Font("Arial", 32); for (int i = 0; i < length; i++) { const int width = 100; float distance = marginLeft; distance += 2.0f * (float)i / (float)length * (float)(this.Size.Width - marginLeft - marginRight); distance -= width / 2; var label = new UIText( System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom, new System.Windows.Forms.Padding((int)distance, 0, 0, 0), new System.Drawing.Size(width, size.Height / 2), zNear, zFar, font.GetFontBitmap("0123456789.eE+-").GetFontTexture(), 100); label.Initialize(); //label.SwitchList.Add(new ClearColorSwitch(Color.Green)); label.Text = ((float)i).ToShortString(); label.BeforeLayout += label_beforeLayout; this.Children.Add(label); this.labelList.Add(label); } this.currentMarkersCount = 2; } }
// 判断停靠位置 private void mStopAnthor() { if (this.Top < screenRect.Bottom / 2) { if (this.Left < screenRect.Right / 2) { if (this.Top < this.Left) StopAanhor = System.Windows.Forms.AnchorStyles.Top; else StopAanhor = System.Windows.Forms.AnchorStyles.Left; } else { if (this.Top < (screenRect.Right - this.Left + this.Width)) StopAanhor = System.Windows.Forms.AnchorStyles.Top; else StopAanhor = System.Windows.Forms.AnchorStyles.Right; } } else { if (this.Left < screenRect.Right / 2) { if ((screenRect.Bottom - this.Top - this.Height) < this.Left) StopAanhor = System.Windows.Forms.AnchorStyles.Bottom; else StopAanhor = System.Windows.Forms.AnchorStyles.Left; } else { if ((screenRect.Bottom - this.Top - this.Height) < (screenRect.Right - this.Left + this.Width)) StopAanhor = System.Windows.Forms.AnchorStyles.Bottom; else StopAanhor = System.Windows.Forms.AnchorStyles.Right; } } }