TextureMapping

class rhino3dm.TextureMapping
TextureMapping()

TextureMapping constructor

RequiresVertexNormals
IsPeriodic
static CreateSurfaceParameterMapping()

Create a mapping that will convert surface parameters into normalized(0,1)x(0,1) texture coordinates.

Returns:

TextureMapping instance or None if failed.

Return type:

TextureMapping

static CreatePlaneMapping(plane, dx, dy, dz)

Create a planar UV projection texture mapping

Parameters:
  • plane (rhino3dm.Plane) – A plane to use for mapping.

  • dx (rhino3dm.Interval) – portion of the plane’s x axis that is mapped to [0,1] (can be a decreasing interval)

  • dy (rhino3dm.Interval) – portion of the plane’s y axis that is mapped to [0,1] (can be a decreasing interval)

  • dz (rhino3dm.Interval) – portion of the plane’s z axis that is mapped to [0,1] (can be a decreasing interval)

Returns:

TextureMapping instance if input is valid

Return type:

TextureMapping

static CreateCylinderMapping(cylinder, capped)

Create a cylindrical projection texture mapping.

Parameters:
  • cylinder (Cylinder) – cylinder in world space used to define a cylindrical coordinate system. The angular parameter maps (0,2pi) to texture “u” (0,1), The height parameter maps (height[0],height[1]) to texture “v” (0,1), and the radial parameter maps (0,r) to texture “w” (0,1).

  • capped (bool) – If true, the cylinder is treated as a finite capped cylinder

Returns:

TextureMapping instance if input is valid

Return type:

TextureMapping

static CreateSphereMapping(sphere)

Create a spherical projection texture mapping.

Parameters:

sphere (rhino3dm.Sphere) – sphere in world space used to define a spherical coordinate system. The longitude parameter maps (0,2pi) to texture “u” (0,1). The latitude parameter maps (-pi/2,+pi/2) to texture “v” (0,1). The radial parameter maps (0,r) to texture “w” (0,1).

Returns:

TextureMapping instance if input is valid

Return type:

TextureMapping

static CreateBoxMapping(plane, dx, dy, dz, capped)

Create a box projection texture mapping.

Parameters:
  • plane (rhino3dm.Plane) – The sides of the box the box are parallel to the plane’s coordinate planes. The dx, dy, dz intervals determine the location of the sides.

  • dx (rhino3dm.Interval) – Determines the location of the front and back planes. The vector plane.xaxis is perpendicular to these planes and they pass through plane.PointAt(dx[0],0,0) and plane.PointAt(dx[1],0,0), respectively.

  • dy (rhino3dm.Interval) – Determines the location of the left and right planes. The vector plane.yaxis is perpendicular to these planes and they pass through plane.PointAt(0,dy[0],0) and plane.PointAt(0,dy[1],0), respectively.

  • dz (rhino3dm.Interval) – Determines the location of the top and bottom planes. The vector plane.zaxis is perpendicular to these planes and they pass through plane.PointAt(0,0,dz[0]) and plane.PointAt(0,0,dz[1]), respectively.

  • capped (bool) – If true, the box is treated as a finite capped box.

Returns:

TextureMapping instance if input is valid

Return type:

TextureMapping

TryGetMappingCylinder()

Get a cylindrical projection parameters from this texture mapping.

Returns:

Returns True if a valid cylinder is returned.

Return type:

bool

TryGetMappingSphere()

Get a spherical projection parameters from this texture mapping.

Returns:

Returns True if a valid sphere is returned.

Return type:

bool

ReverseTextureCoordinate(dir)

[todo] add documentation

SwapTextureCoordinate(i, j)

[todo] add documentation

TileTextureCoordinate(dir, count, offset)

[todo] add documentation

Evaluate(p, n)

Evaluate the mapping to get a texture coordinate

Parameters:
  • p (rhino3dm.Point3d) – Vertex location

  • n (rhino3dm.Vector3d) – If the mapping projection is ray_projection, then this is the vertex unit normal. Otherwise n is ignored.

Returns:

tuple (int, rhino3dm.Point3d)

  • Nonzero if evaluation is successful. When the mapping is a box or capped cylinder mapping, the value indicates which side was evaluated. Cylinder mapping: 1 = cylinder wall, 2 = bottom cap, 3 = top cap Box mapping: 1 = front, 2 = right, 3 = back, 4 = left, 5 = bottom, 6 = top

  • Texture coordinate (u,v,w)

Return type:

(int, rhino3dm.Point3d)