Materials and NURBS Surfaces

(edited the tag on this as it became a developer question)

I have a NURBS surface that is for example 50m squared - and I have an image that represents 100m square. I’ve created a material and set the texture and switched to rendered view. I can see the material but I don’t know how to scale it right so that it’s the central section of the image.

Should I be doing something with the “Apply Surface Mapping” option?

Hi Hannah- I think ApplyPlanarMapping is what you are after- if you do not make the plane the right size initially, you can turn on the mapping widget (MappingWidget command) and move/scale/rotate it after the fact.

-Pascal

Thanks Pascal. I shall take a look.

Yes that’s exactly what I’m after. Is it something I can manipulate via the SDK? (Maybe I should ask that question again and tag it differently.)

I think I’d need to use TextureMapping.CreatePlaneMapping Method. Is there a snippet of this being used anywhere? I can’t find anything in http://wiki.mcneel.com/developer/rhinocommonsamples

I’ve created the surface and the material and applied the material to the surface like so:

int index = doc.Materials.Add();
Rhino.DocObjects.Material mat = doc.Materials[index];
mat.SetBitmapTexture(jpgFile);
mat.CommitChanges();
Rhino.DocObjects.ObjectAttributes attr = new Rhino.DocObjects.ObjectAttributes();
attr.MaterialIndex = index;
attr.MaterialSource = Rhino.DocObjects.ObjectMaterialSource.MaterialFromObject;
ObjRef objref = go.Object(surfaceNumber);
doc.Objects.ModifyAttributes(objref, attr, true);

Then I can imagine creating a TextureMapping something like this…

Rhino.Render.TextureMapping map = Rhino.Render.TextureMapping.CreatePlaneMapping(…);

How would I then apply this TextureMapping to the surface? I’ve checked the Rhino.DocObjects.ObjectAttributes - which has a “HasMapping” method… but no “SetMapping”.

@andy do you have any sample(s) you can share?