I want to aplly image texture to a mesh,and use the code below,but return nothing,Can you help me?@Dale
mesh.stl (7.8 MB)
var go = new GetObject();
go.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh;
go.SetCommandPrompt("Select mesh");
var res = go.Get();
if (go.ObjectCount == 0) return Result.Failure;
Mesh targetMesh = go.Object(0).Mesh();
if(targetMesh ==null) return Result.Failure;
string imagePath = "C:\\Users\\Administrator\\Desktop\\texture.jpg";
Bitmap bitmap = new Bitmap(imagePath);
Rhino.Render.RenderTexture texture = RenderTexture.NewBitmapTexture(bitmap,doc);
MeshDisplacementInfo info = new MeshDisplacementInfo(texture,TextureMapping.CreateCustomMeshMapping(targetMesh));
info.FaceLimit = int.MaxValue;
info.BlackMove = 0.5;
info.MemoryLimit = int.MaxValue;
Mesh newMesh = targetMesh.WithDisplacement(info);
doc.Objects.AddMesh(newMesh);
doc.Views.Redraw();
return Result.Success;