internal void AddPreviewItem(string bitmap, Curve c, Rectangle3d bounds) { var mesh = Mesh.CreateFromPlanarBoundary(c, MeshingParameters.FastRenderMesh, 0.1); TextureMapping tm = TextureMapping.CreatePlaneMapping(bounds.Plane, bounds.X, bounds.Y, new Interval(-1, 1)); mesh.SetTextureCoordinates(tm, Transform.Identity, true); var mat = new DisplayMaterial(System.Drawing.Color.White); ///Force bitmap to redraw //string docBitmapName = string.Empty; //var docBitmap = Rhino.RhinoDoc.ActiveDoc.Bitmaps.Find(bitmap, true, out docBitmapName); //mat.SetBitmapTexture(docBitmapName, true); mat.SetBitmapTexture(bitmap, true); _previewItems.Add(new HeronRasterPreviewItem() { mesh = mesh, mat = mat }); ///Use Wait to refresh images ///https://discourse.mcneel.com/t/wish-list-set-bitmap-texture-from-memory-stream/105158/5 ///https://mcneel.myjetbrains.com/youtrack/issue/RH-59416 Rhino.RhinoApp.Wait(); }
internal void AddPreviewItem(string bitmap, Curve c, Rectangle3d bounds) { var mesh = Mesh.CreateFromPlanarBoundary(c, MeshingParameters.FastRenderMesh, 0.1); TextureMapping tm = TextureMapping.CreatePlaneMapping(bounds.Plane, bounds.X, bounds.Y, new Interval(-1, 1)); mesh.SetTextureCoordinates(tm, Transform.Identity, true); var mat = new DisplayMaterial(System.Drawing.Color.White); mat.SetBitmapTexture(bitmap, true); _previewItems.Add(new HeronRasterPreviewItem() { mesh = mesh, mat = mat }); }