/// <summary> /// Adds a cube face. /// </summary> /// <param name="normal"> /// The normal. /// </param> /// <param name="up"> /// The up vector. /// </param> /// <param name="b"> /// The brush. /// </param> /// <param name="text"> /// The text. /// </param> private void AddCubeFace(Vector3D normal, Vector3D up, Brush b, string text) { const int faceWidth = 20; const int faceHeight = 20; var face = new TextBlock { Width = faceWidth, Height = faceHeight, Text = text, TextAlignment = TextAlignment.Center, FontSize = 15, Foreground = Brushes.White, Background = b, }; face.Arrange(new Rect(new Point(0, 0), new Size(faceWidth, faceHeight))); var bmp = new RenderTargetBitmap(faceWidth, faceHeight, 96, 96, PixelFormats.Default); bmp.Render(face); var material = MaterialHelper.CreateMaterial(new ImageBrush(bmp)); double a = this.Size; var builder = new MeshBuilder(false, true); builder.AddCubeFace(this.Center, normal, up, a, a, a); var geometry = builder.ToMesh(true); var model = new GeometryModel3D { Geometry = geometry, Material = material }; var element = new ModelUIElement3D { Model = model }; element.MouseLeftButtonDown += this.FaceMouseLeftButtonDown; this.faceNormals.Add(element, normal); this.faceUpVectors.Add(element, up); this.Children.Add(element); }
/// <summary> /// The Fill property was changed. /// </summary> protected virtual void OnFillChanged() { this.Material = MaterialHelper.CreateMaterial(this.Fill); this.BackMaterial = this.Material; }