Instance Method

textureCoordinatesWithMappingChannel:

Returns the texture coordinates at the point of intersection for the specified texture mapping channel.

Declaration

- (CGPoint)textureCoordinatesWithMappingChannel:(NSInteger)channel;

Parameters

channel

The index of the mapping channel in which to look up texture coordinates.

Return Value

The texture coordinates at the point of intersection, or CGPointZero if the geometry does not have a texture coordinate source for the specified channel.

Discussion

An SCNGeometry object can contain multiple sources of texture coordinates, or texture mapping channels. (With multiple channels, you can map texture images for different material properties in different ways.) To use the texture coordinates of a hit-test result, specify which texture coordinate source to look up coordinates in.

For example, to add “scorch marks” to a game character hit by a laser, you might modify a texture image mapped to the multiply property of the geometry’s material. Use the mappingChannel index from that material property as the channel parameter when calling textureCoordinatesWithMappingChannel: to ensure that you modify the correct location in the texture image.

See Also

Retrieving Information About a Hit-Test Result

node

The node whose geometry intersects the search ray.

geometryIndex

The index of the geometry element whose surface the search ray intersects.

faceIndex

The index of the primitive in the geometry element intersected by the search ray.

localCoordinates

The point of intersection between the geometry and the search ray, in the local coordinate system of the node containing the geometry.

worldCoordinates

The point of intersection between the geometry and the search ray, in the scene’s world coordinate system.

localNormal

The surface normal vector at the point of intersection, in the local coordinate system of the node containing the geometry intersected by the search ray.

worldNormal

The surface normal vector at the point of intersection, in the scene’s world coordinate system.

modelTransform

The world transform matrix of the node containing the intersection.