public sealed class TextureMapping : ModelComponent
Represents a texture mapping.

Properties

Capped

#Since v8.15
// The m_bCapped applies to planar, cylinder and box mappings. If m_bCapped is false, the cylinder or box is "infinite", if m_bCapped is true, they are finite. In planar mappings, m_bCapped=false means "the Z texture coordinate will always be 0.0" this is now the default behaviour in Rhino 5.0 - it's what users expect apparently.
public bool Capped { get; set; }

ComponentStatus

Gets or sets the component status of the model component.
public virtual ComponentStatus ComponentStatus { get; set; }
inherited fromModelComponent

ComponentType

#Since v6.0
public override ModelComponentType ComponentType { get; }

DeletedName

Gets the name of a component that is deleted.
public string DeletedName { get; }
inherited fromModelComponent

Disposed

Indicates if this object has been disposed or the document it originally belonged to has been disposed.
public bool Disposed { get; }
inherited fromCommonObject

HasId

Returns a value indicating whether the component has an ID.
public bool HasId { get; }
inherited fromModelComponent

HasIndex

Returns a value indicating whether the component has an Index.
public bool HasIndex { get; }
inherited fromModelComponent

HasName

Returns a value indicating whether the component has a Name.
public bool HasName { get; }
inherited fromModelComponent

HasUserData

Gets true if this class has any custom information attached to it through UserData.
public bool HasUserData { get; }
inherited fromCommonObject

Id

#Since v5.10
The unique Id for this texture mapping object.
public override Guid Id { get; }

IdIsLocked

Returns a value indicating whether the component ID is already locked.
public bool IdIsLocked { get; }
inherited fromModelComponent

Index

Gets or sets the model component index attribute.
public virtual int Index { get; set; }
inherited fromModelComponent
InvalidOperationExceptionWhen setting the Index failed. This usually happens because the instance Index is already locked.

IndexIsLocked

Returns a value indicating whether the component Index is already locked.
public bool IndexIsLocked { get; }
inherited fromModelComponent

InstanceDefinitionModelSerialNumber

When a component is in a model as part of the information required for a linked instance definition, this value identifies the linked instance definition reference model.
[CLSCompliant(false)] public virtual uint InstanceDefinitionModelSerialNumber { get; }
inherited fromModelComponent
Remarks: Reference components are not saved in .3dm archives. Typically this value is set and locked by the code that adds a component to a model. This value is not saved in .3dm archives.

IsComponentStatusLocked

The component status itself can be locked. This returns an indication.
public bool IsComponentStatusLocked { get; }
inherited fromModelComponent

IsDeleted

true if the component is deleted. Deleted components are kept by the document for undo purposes.
public virtual bool IsDeleted { get; }
inherited fromModelComponent

IsDocumentControlled

If true this object may not be modified. Any properties or functions that attempt to modify this object when it is set to "IsReadOnly" will throw a NotSupportedException.
public virtual bool IsDocumentControlled { get; }
inherited fromCommonObject

IsReference

Gets a value indicting whether this component is a referenced component. Referenced components are part of referenced documents.
public virtual bool IsReference { get; }
inherited fromModelComponent

IsSystemComponent

True if this model component is a system constant.

An incomplete list of system constant model components is below:

  • ON_ModelComponent::Unset

  • ON_InstanceDefinition::Empty

  • ON_Linetype::Unset
  • ON_Linetype::Continuous
  • ON_Linetype::ByLayer
  • ON_Linetype::ByParent

  • ON_Layer::Unset
  • ON_Layer::Default

  • ON_TextStyle::Unset
  • ON_TextStyle::Default
  • ON_TextStyle::ByLayer
  • ON_TextStyle::ByParent

  • ON_DimStyle::Unset
  • ON_DimStyle::Default
  • ON_DimStyle::DefaultInchDecimal
  • ON_DimStyle::DefaultInchFractional
  • ON_DimStyle::DefaultFootInchArchitecture
  • ON_DimStyle::DefaultMillimeterSmall
  • ON_DimStyle::DefaultMillimeterLarge
  • ON_DimStyle::DefaultMillimeterArchitecture
public bool IsSystemComponent { get; }
inherited fromModelComponent

IsValid

Tests an object to see if it is valid.
public virtual bool IsValid { get; }
inherited fromCommonObject

MappingType

#Since v5.10
Texture mapping type associated with this Mapping object.
public TextureMappingType MappingType { get; }

ModelSerialNumber

A value identifying the model that manages this component.
[CLSCompliant(false)] public virtual uint ModelSerialNumber { get; }
inherited fromModelComponent
Remarks: If the component is being managed by a model, this value identifies the model. In Rhino, this value is the document runtime serial number. Typically this value is set and locked by the code that adds a component to a model. This value is not saved in .3dm archives.

Name

Gets or sets the name
public virtual string Name { get; set; }
inherited fromModelComponent
InvalidOperationExceptionWhen setting the Name failed. This usually happens because the instance Name is already locked.

NameIsLocked

Returns a value indicating whether the component Name is already locked.
public bool NameIsLocked { get; }
inherited fromModelComponent

NormalTransform

#Since v5.10
For primitive based mappings, these transformations are used to map the world coordinate (x,y,z) point P and surface normal N before it is projected to the normalized mapping primitive. The surface normal transformation, m_Nxyz, is always calculated from m_Pxyz. It is a runtime setting that is not saved in 3dm files. If m_type is srfp_mapping, then m_Pxyz and m_Nxyz are ignored.
public Transform NormalTransform { get; set; }

PrimativeTransform

#Since v5.10
For primitive based mappings, these transformations are used to map the world coordinate (x,y,z) point P and surface normal N before it is projected to the normalized mapping primitive. The surface normal transformation, m_Nxyz, is always calculated from m_Pxyz. It is a runtime setting that is not saved in 3dm files. If m_type is srfp_mapping, then m_Pxyz and m_Nxyz are ignored.
public Transform PrimativeTransform { get; set; }
obsoleteSpelling error - use PrimitiveTransform

PrimitiveTransform

#Since v7.5
For primitive based mappings, these transformations are used to map the world coordinate (x,y,z) point P and surface normal N before it is projected to the normalized mapping primitive. The surface normal transformation, m_Nxyz, is always calculated from m_Pxyz. It is a runtime setting that is not saved in 3dm files. If m_type is srfp_mapping, then m_Pxyz and m_Nxyz are ignored.
public Transform PrimitiveTransform { get; set; }

Projection

#Since v8.15
See Projection
public Projection Projection { get; set; }

ReferenceModelSerialNumber

When a component is in a model for reference, this value identifies the reference model.
[CLSCompliant(false)] public virtual uint ReferenceModelSerialNumber { get; }
inherited fromModelComponent
Remarks: Reference components are not saved in .3dm archives. Typically this value is set and locked by the code that adds a component to a model. This value is not saved in .3dm archives.

TextureSpace

#Since v8.15
See TextureSpace
public TextureSpace TextureSpace { get; set; }

UserData

List of custom information that is attached to this class.
public UserDataList UserData { get; }
inherited fromCommonObject

UserDictionary

Dictionary of custom information attached to this class. The dictionary is actually user data provided as an easy to use shareable set of information.
public ArchivableDictionary UserDictionary { get; }
inherited fromCommonObject

UvwTransform

#Since v5.10
Transform applied to mapping coordinate (u,v,w) to convert it into a texture coordinate.
public Transform UvwTransform { get; set; }

Methods

ClearId

Resets the HasId property of the model component to false, if possible.
public void ClearId()
inherited fromModelComponent
InvalidOperationExceptionIf the ID is locked.

ClearIndex

Resets the HasIndex property of the model component to false, if possible.
public void ClearIndex()
inherited fromModelComponent
InvalidOperationExceptionIf the index is locked.

ClearName

Resets the HasName property of the model component to false, if possible.
public void ClearName()
inherited fromModelComponent
InvalidOperationExceptionIf the name is locked.

ConstructConstObject

Assigns a parent object and a sub-object index to this.
protected void ConstructConstObject(
parentObject,
The parent object.
subobjectIndex
The sub-object index.
)
inherited fromCommonObject

CreateBoxMapping

#Since v5.0
Create a box projection texture mapping.
public static TextureMapping CreateBoxMapping(
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,
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,
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,
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
If true, the box is treated as a finite capped box.
)
Remarks: When m_texture_space = divided, the box is mapped to texture space as follows: If the box is not capped, then each side maps to 1/4 of the texture map. v=1+---------+---------+---------+---------+ | x=dx[1] | y=dy[1] | x=dx[0] | y=dy[0] | | Front | Right | Back | Left | | --y-> | <-x-- | <-y-- | --x-> | v=0+---------+---------+---------+---------+ 0/4 <=u<= 1/4 <=u<= 2/4 <=u<= 3/4 <=u<= 4/4 If the box is capped, then each side and cap gets 1/6 of the texture map. v=1+---------+---------+---------+---------+---------+---------+ | x=dx[1] | y=dy[1] | x=dx[0] | y=dy[0] | z=dx[1] | z=dz[0] | | Front | Right | Back | Left | Top | Bottom | | --y-> | <x-- | <-y-- | --x-> | --x-> | --x-> | v=0+---------+---------+---------+---------+---------+---------+ 0/6 <=u<= 1/6 <=u<= 2/6 <=u<= 3/6 <=u<= 4/6 <=u<= 5/6 <=u<= 6/6
TextureMapping instance if input is valid

CreateCustomMeshMapping

#Since v6.15
Create custom mesh mapping
public static TextureMapping CreateCustomMeshMapping(
Mesh
mesh
Mesh with texture coordinates
)
TextureMapping instance

CreateCylinderMapping

#Since v5.0
Create a cylindrical projection texture mapping.
public static TextureMapping CreateCylinderMapping(
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
If true, the cylinder is treated as a finite capped cylinder
)
Remarks: When the cylinder is capped and m_texture_space = divided, the cylinder is mapped to texture space as follows: The side is mapped to 0 <= "u" <= 2/3. The bottom is mapped to 2/3 <= "u" <= 5/6. The top is mapped to 5/6 <= "u" <= 5/6. This is the same convention box mapping uses.
TextureMapping instance if input is valid

CreateOcsMapping

#Since v7.17
Create a Ocs texture mapping. Note that OCS mappings must be placed on mapping channel ON_ObjectRenderingAttributes::OCSMappingChannelId() otherwise they will not work.
public static TextureMapping CreateOcsMapping(
plane
A plane to use for mapping.
)

CreatePlaneMapping

#Since v6.7
Create a planar projection texture mapping
public static TextureMapping CreatePlaneMapping(
plane,
A plane to use for mapping.
dx,
portion of the plane's x axis that is mapped to [0,1] (can be a decreasing interval)
dy,
portion of the plane's y axis that is mapped to [0,1] (can be a decreasing interval)
dz,
portion of the plane's z axis that is mapped to [0,1] (can be a decreasing interval)
capped
set to true if planar UVW is meant, false for planar UV
)
TextureMapping instance if input is valid

CreatePlaneMapping

#Since v5.0
Create a planar UV projection texture mapping
public static TextureMapping CreatePlaneMapping(
plane,
A plane to use for mapping.
dx,
portion of the plane's x axis that is mapped to [0,1] (can be a decreasing interval)
dy,
portion of the plane's y axis that is mapped to [0,1] (can be a decreasing interval)
dz
portion of the plane's z axis that is mapped to [0,1] (can be a decreasing interval)
)
TextureMapping instance if input is valid

CreateSphereMapping

#Since v5.0
Create a spherical projection texture mapping.
public static TextureMapping CreateSphereMapping(
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).
)
TextureMapping instance if input is valid

CreateSurfaceParameterMapping

#Since v7.5
Create a mapping that will convert surface parameters into normalized(0,1)x(0,1) texture coordinates.
public static TextureMapping CreateSurfaceParameterMapping()
TextureMapping instance or null if failed.

DataCRC

Increments the Cyclic Redundancy Check value by this instance.
[CLSCompliant(false)] public uint DataCRC(
currentRemainder
The current remainder value.
)
inherited fromModelComponent
The updated remainder value.

Decompose

#Since v9.0
Gets the same decomposition of the texture mapping transforms as is used in the UI.
[ConstOperation] public void Decompose(
localTransform,
xyz_position,
xyz_scale,
xyz_rotation,
uvw_offset,
uvw_repeat,
uvw_rotation
)

Dispose

Actively reclaims unmanaged resources that this instance uses.
public void Dispose()
inherited fromCommonObject

Dispose

For derived class implementers.

This method is called with argument true when class user calls Dispose(), while with argument false when the Garbage Collector invokes the finalizer, or Finalize() method.

You must reclaim all used unmanaged resources in both cases, and can use this chance to call Dispose on disposable fields if the argument is true.

Also, you must call the base virtual method within your overriding method.

protected virtual void Dispose(
disposing
true if the call comes from the Dispose() method; false if it comes from the Garbage Collector finalizer.
)
inherited fromCommonObject

EnsurePrivateCopy

If you want to keep a copy of this class around by holding onto it in a variable after a command completes, call EnsurePrivateCopy to make sure that this class is not tied to the document. You can call this function as many times as you want.
public void EnsurePrivateCopy()
inherited fromCommonObject

Evaluate

#Since v6.17
Evaluate the mapping to get a texture coordinate
public int Evaluate(
p,
Vertex location
n,
If the mapping projection is ray_projection, then this is the vertex unit normal. Otherwise n is ignored.
out Point3d
t,
Texture coordinate (u,v,w)
pXform,
Transformation to be applied to P before performing the mapping calculation.
nXform
Transformation to be applied to N before performing the mapping calculation. One way to calculate nXxform is to use the call pXform::GetVectorTransform(nXform).
)
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

Evaluate

#Since v6.17
Evaluate the mapping to get a texture coordinate
public int Evaluate(
p,
Vertex location
n,
If the mapping projection is ray_projection, then this is the vertex unit normal. Otherwise n is ignored.
out Point3d
t
Texture coordinate (u,v,w)
)
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

GetObjectData

Populates a System.Runtime.Serialization.SerializationInfo with the data needed to serialize the target object.
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] public virtual void GetObjectData(
info,
The System.Runtime.Serialization.SerializationInfo to populate with data.
context
The destination (see System.Runtime.Serialization.StreamingContext) for this serialization.
)
inherited fromCommonObject

IsValidWithLog

Determines if an object is valid. Also provides a report on errors if this object happens not to be valid.
public bool IsValidWithLog(
out string
log
A textual log. This out parameter is assigned during this call.
)
inherited fromCommonObject
true if this object is valid; false otherwise.

LockId

Locks the component Id property.
public void LockId()
inherited fromModelComponent

LockIndex

Locks the component Index property.
public void LockIndex()
inherited fromModelComponent

LockName

Locks the component Name property.
public void LockName()
inherited fromModelComponent

NonConstOperation

For derived classes implementers.

Defines the necessary implementation to free the instance from being constant.

protected virtual void NonConstOperation()
inherited fromCommonObject

OnSwitchToNonConst

Is called when a non-constant operation first occurs.
protected virtual void OnSwitchToNonConst()
inherited fromCommonObject

ToJSON

Create a JSON string representation of this object
public string ToJSON()
inherited fromCommonObject

ToString

Returns the name of the model component type, and then its name and index.
public override string ToString()
inherited fromModelComponent
Remarks: This is provided as a visual aid. Do not rely on this for serialization.
Object.ToString

TryGetMappingBox

#Since v6.7
Get a box projection from the texture mapping, including capped information
public bool TryGetMappingBox(
out Plane
plane,
The center of the box is at plane.origin and the sides of the box are parallel to the plane's coordinate planes.
dx,
The "front" and "back" sides of the box are in spanned by the vectors plane.yaxis and plane.zaxis. The back plane contains the point plane.PointAt(dx[0],0,0) and the front plane contains the point plane.PointAt(dx[1],0,0).
dy,
The "left" and "right" sides of the box are in spanned by the vectors plane.zaxis and plane.xaxis. The left plane contains the point plane.PointAt(0,dx[0],0) and the back plane contains the point plane.PointAt(0,dy[1],0).
dz,
The "top" and "bottom" sides of the box are in spanned by the vectors plane.xaxis and plane.yaxis. The bottom plane contains the point plane.PointAt(0,0,dz[0]) and the top plane contains the point plane.PointAt(0,0,dz[1]).
out bool
capped
true if box mapping is capped.
)
Remarks: Generally, GetMappingBox will not return the same parameters passed to SetBoxMapping. However, the location of the box will be the same.
Returns true if a valid box is returned.

TryGetMappingBox

#Since v5.10
Get a box projection from the texture mapping.
public bool TryGetMappingBox(
out Plane
plane,
The center of the box is at plane.origin and the sides of the box are parallel to the plane's coordinate planes.
dx,
The "front" and "back" sides of the box are in spanned by the vectors plane.yaxis and plane.zaxis. The back plane contains the point plane.PointAt(dx[0],0,0) and the front plane contains the point plane.PointAt(dx[1],0,0).
dy,
The "left" and "right" sides of the box are in spanned by the vectors plane.zaxis and plane.xaxis. The left plane contains the point plane.PointAt(0,dx[0],0) and the back plane contains the point plane.PointAt(0,dy[1],0).
dz
The "top" and "bottom" sides of the box are in spanned by the vectors plane.xaxis and plane.yaxis. The bottom plane contains the point plane.PointAt(0,0,dz[0]) and the top plane contains the point plane.PointAt(0,0,dz[1]).
)
Remarks: Generally, GetMappingBox will not return the same parameters passed to SetBoxMapping. However, the location of the box will be the same.
Returns true if a valid box is returned.

TryGetMappingCylinder

#Since v6.7
Get a cylindrical projection parameters from this texture mapping.
public bool TryGetMappingCylinder(
cylinder,
out bool
capped
will be true if capped
)
Remarks: Generally, GetMappingCylinder will not return the same parameters passed to SetCylinderMapping. However, the location of the cylinder will be the same. If this mapping is not cylindrical, the cylinder will approximate the actual mapping primitive.
Returns true if a valid cylinder is returned.

TryGetMappingCylinder

#Since v5.10
Get a cylindrical projection parameters from this texture mapping.
public bool TryGetMappingCylinder(
cylinder
)
Remarks: Generally, GetMappingCylinder will not return the same parameters passed to SetCylinderMapping. However, the location of the cylinder will be the same. If this mapping is not cylindrical, the cylinder will approximate the actual mapping primitive.
Returns true if a valid cylinder is returned.

TryGetMappingMesh

#Since v6.18
Get custom mapping mesh from this texture mapping.
public bool TryGetMappingMesh(
out Mesh
mesh
)
True if custom mapping mesh was returned.

TryGetMappingPlane

#Since v6.7
Get plane mapping parameters from this texture mapping, including capping information
public bool TryGetMappingPlane(
out Plane
plane,
dx,
Portion of the plane's x axis that is mapped to [0,1]
dy,
Portion of the plane's y axis that is mapped to [0,1]
dz,
Portion of the plane's z axis that is mapped to [0,1]
out bool
capped
)
Remarks: NOTE WELL: Generally, GetMappingPlane will not return the same parameters passed to SetPlaneMapping. However, the location of the plane will be the same.
Return true if valid plane mapping parameters were returned.

TryGetMappingPlane

#Since v5.10
Get plane mapping parameters from this texture mapping.
public bool TryGetMappingPlane(
out Plane
plane,
dx,
Portion of the plane's x axis that is mapped to [0,1]
dy,
Portion of the plane's y axis that is mapped to [0,1]
dz
Portion of the plane's z axis that is mapped to [0,1]
)
Remarks: NOTE WELL: Generally, GetMappingPlane will not return the same parameters passed to SetPlaneMapping. However, the location of the plane will be the same.
Return true if valid plane mapping parameters were returned.

TryGetMappingSphere

#Since v5.10
Get a spherical projection parameters from this texture mapping.
public bool TryGetMappingSphere(
out Sphere
sphere
///
)
Remarks: Generally, GetMappingShere will not return the same parameters passed to SetSphereMapping. However, the location of the sphere will be the same. If this mapping is not cylindrical, the cylinder will approximate the actual mapping primitive.
Returns true if a valid sphere is returned.