Hi, texture mapping coordinates in Rhino8 (Grasshopper) is disabled (For Mesh) by Custom previews Component
But in Rhino7 it is enabled (if you change Geometry to SubD in Rhino 8 it will also be enabled) in Rhino7
in Rhino 8
private void RunScript(Mesh mesh, Box box, string path, double tr, ref object MeshMap, ref object Material)
{
Component.Name = "Texture Maping,Matrial";
if(Component.Params.Input[1].VolatileDataCount != 0 && mesh != null){
var text = TextureMapping.CreateBoxMapping(box.Plane, box.X, box.Y, box.Z, true);
mesh.TextureCoordinates.SetTextureCoordinates(text);
MeshMap = mesh;
Material material = new Material();
if (path != null)
{
material.SetBitmapTexture(path);
material.Transparency = tr;
}
var m = RenderMaterial.CreateBasicMaterial(material, RhinoDoc.ActiveDoc);
Material = new GH_Material(m);}
}
hi @Jussi_Aaltonen
It seems Unweld Mesh at Edges (before set the texture map on mesh) it is possible to show the texture / but it’s slow and don’t need it in Rhino7 to do this!
and no need to use mesh.TextureCoordinates.ReverseTextureCoordinates(1); mesh.TextureCoordinates.TransposeTextureCoordinates(); mesh.TextureCoordinates.NormalizeTextureCoordinates();
private void RunScript(
Mesh mesh,
double present,
ref object a,
ref object count)
{
Mesh unweldedMesh = mesh.DuplicateMesh();
Component.Name="Unweld all edges";
var edge= System.Linq.Enumerable.Range(0,(int)(unweldedMesh.TopologyEdges.Count*persent));
count=edge;
unweldedMesh.UnweldEdge( edge,true);
a =unweldedMesh;
}
In your original texture Mapping.gh add the following line after the call to SetTextureCoordinates: mesh.SetSurfaceParametersFromTextureCoordinates();
That will set up surface parameter data according to your texture coordinates so that the default texture mapping applied will give the right result in the preview.