AppleSCNMaterialProperty - UBogun/Xojo-iosLib GitHub Wiki

Inherits from AppleObject
Memory leak check: not yet done.
Status: incomplete, materialWithMDLMaterial Constructor missing.

An SCNMaterialProperty object represents the contents—color, texture, or other visual elements—of one of a material’s visual properties. For material properties with texture contents, the SCNMaterialProperty class also controls texturing options such as wrapping, filtering, and texture coordinate transformation.

A material has several visual properties that together determine its appearance under lighting and shading. SceneKit renders each pixel in the scene by combining the information from material properties with the locations, intensities, and colors of lights.

A material property’s contents can be either a color, which provides a uniform effect across the surface of a material, or a texture, which SceneKit maps across the surface of a material using texture coordinates provided by the geometry object the material is attached to. A texture, in turn, can come from any of several sources:

  • An image object, or a path or URL to an image file
  • An array of six images to be used as a cube map
  • A Core Animation layer or layer hierarchy, which itself may contain animated content
  • A Sprite Kit texture providing a static image, or an entire Sprite Kit scene rendering animated 2D content.

SCNMaterialProperty includes the SCNAnimatable Interface, which means you can use AppleCAAnimations to animate these properties. Convenience methods have not been introduced to this class. Please check out the Animate… methods of the AppleView class to get an idea of how to create own property animations for this class.

Constructors

Constructor (Contents As AppleGeneralObject): Creates a new material property object with the specified contents. Contents can be one of the following objects:

  • A color (AppleColor or AppleCGColor), specifying a constant color across the material’s surface
  • An image (AppleImage or AppleCGImage), specifying a texture to be mapped across the material’s surface
  • An Text or AppleURL object specifying the location of an image file
  • An Applearray of six images, specifying the faces of a cube map
  • A Core Animation layer (AppleCALayer)
  • A texture (AppleSKTexture, MDLTexture, MTLTexture, or GLKTextureInfo) – the three latter ones not yet included in iOSLib.
  • A Sprite Kit scene (AppleSKScene)

Properties

AnimationKeys As AppleArray Of CFStringRef: An array containing the keys of all animations currently attached to the object. (read-only)

BorderColor As AppleColor: A color used to fill in areas of a material’s surface not covered by the material property’s image contents.

Please note this property does not have to be an AppleColor. Use the external getBorderColor and SetBorderColor methods of this class to create methods or properties for CGColors.

Contents As AppleGeneralObject: The visual contents of the material property—a color, image, or source of animated content. Animatable.

See the constructor for possible object types. You can use the getContents and setContents private methods of this class to develop custom computed properties delivering the exact kind of object if you like.

ContentsTransform As SCNMatrix4: The transformation applied to the material property’s visual contents. Animatable.

Intensity As Double: A number between 0.0 and 1.0 that modulates the effect of the material property. Animatable.

MagnifcationFilter As SCNFilterMode: Texture filtering for rendering the material property’s image contents at a size larger than that of the original image. Default Linear.

SCNFilterMode Definition
None No texture filtering is applied. Only valid for the mipFilter property, specifying that SceneKit should not use mip mapping.
Nearest Texture filtering returns the color from only one texel, whose location is nearest to the coordinates being sampled.
Linear Texture filtering sample texels from the neighborhood of the coordinates being sampled and linearly interpolates their colors.

MappingChannel As Integer: The source of texture coordinates for mapping the material property’s image contents.

MaxAnisotropy As Double: The amount of anisotropic texture filtering to be used when rendering the material property’s image contents.

MinifcationFilter As SCNFilterMode: Texture filtering for rendering the material property’s image contents at a size smaller than that of the original image. Default Linear.

MipFilter As SCNFilterMode: Texture filtering for using mipmaps to render the material property’s image contents at a size smaller than that of the original image. Default None.

WrapS As SCNWrapMode: The wrapping behavior for the S texture coordinate.

SCNWrapMode Definition
Clamp Texture coordinates are clamped to the range from 0.0 to 1.0, inclusive. If the contents do not fill the surface then, the rest shows the BorderColor property.
Repeat Texture coordinates are clamped to the range from 0.0 to 1.0, inclusive. The image is tiled to fill the surface.
ClampToBorder Texture sampling uses texture colors for coordinates in the range from 0.0 to 1.0 (inclusive) and the material property’s borderColor value otherwise. The image is scaled and possibly only part of it shows.
Mirror Texture sampling of texture coordinates outside range from 0.0 to 1.0 should behave as if the range reverses before repeating.

WrapT As SCNWrapMode: The wrapping behavior for the T texture coordinate.

Methods

AddAnimation (Animation As AppleCAAnimation, Key As Text): Adds an animation object for the specified key.

Animation (Key as Text) As AppleCAAnimation: Returns the animation with the specified key.

AnimationPaused (Key As Text) As Boolean: Returns a Boolean value indicating whether the animation attached to the object with the specified key is paused.

PauseAnimation (Key As Text): Pauses the animation attached to the object with the specified key.

RemoveAllAnimations(): Removes all the animations currently attached to the object.

RemoveAnimation (Key As Text, opt. FadeOutDuration As Double): Removes the animation attached to the object with the specified key. If you specify a FadeOutDuration, smoothly transitioning out of the animation’s effect.

ResumeAnimation (Key As Text): Resumes a previously paused animation attached to the object with the specified key.