Apply texture mapping for surfaces



Is it possible to apply texture mapping to surfaces?

For meshes there is something like this in RhinoCommon:

Is there similar thingy for breps/surfaces?

I tried this

private void RunScript(Guid x, Brep y, Plane p, ref object A)
  Rhino.Render.TextureMapping textureMapping = Rhino.Render.TextureMapping.CreatePlaneMapping(p, new Interval(-400, 400), new Interval(-400, 400), new Interval(0, 1));
  Rhino.DocObjects.Tables.ObjectTable.ModifyTextureMapping(x, 1, textureMapping);
But I get error:
Error (CS0120): An object reference is required for the non-static field, method, or property ‘Rhino.DocObjects.Tables.ObjectTable.ModifyTextureMapping(System.Guid, int, Rhino.Render.TextureMapping)’ (line 74)
What does this error mean?

(Dale Fugier) #2

Hi Tom,

Texture mapping is applied to a surface or polysurface’s render mesh during rendering.

Your code does not work because you are not working with the document’s object table.

I’m thinking something like this might work:

private bool ApplyPlaneMapping(RhinoDoc doc, Guid id, Plane plane)
  var mapping = TextureMapping.CreatePlaneMapping(
    new Interval(-400, 400), 
    new Interval(-400, 400), 
    new Interval(0, 1)
  return doc.Objects.ModifyTextureMapping(id, 1, mapping);