pub struct SCNTechnique { /* private fields */ }SCNTechnique only.Expand description
SCNTechnique represents a rendering process that may require multiple passes.
A technique is generally initialized from a Property List file. It can be set to any object that conforms to the SCNTechniqueSupport protocol.
See also Apple’s documentation
Implementations§
Source§impl SCNTechnique
impl SCNTechnique
Sourcepub unsafe fn techniqueWithDictionary(
dictionary: &NSDictionary<NSString, AnyObject>,
) -> Option<Retained<SCNTechnique>>
pub unsafe fn techniqueWithDictionary( dictionary: &NSDictionary<NSString, AnyObject>, ) -> Option<Retained<SCNTechnique>>
Creates and returns a technique instance initialized with the specified dictionary.
Parameter dictionary: The dictionary representation of the technique.
The format of the dictionary is described below. Quoted strings can be any name of your choice. Tags are defined below. The passes are executed sequentially as specified in the “sequence” section. The definition of each pass is within the “passes” section. A pass may have inputs/outputs that reference targets or symbols defined in the “targets” and “symbols” section. The entries of the “symbols” section can be set/get and animated with SCNTechnique’s APIs below.
{ sequence: [“Pass1”, “Pass2”, …], passes: { “Pass1”: { outputs: <outputs
inputs: <inputs
draw:
//optional
bundle: <bundleIdentifier
, metalLibraryName: <metalLibraryName , }
<outputs
: The possible (and optional) keys with their possible associated values are: color: a string referencing a color render target. See
. depth: a string referencing a depth render target. See . stencil: a string referencing a stencil render target. See .
<inputs
: The inputs are listed in a dictionary. The keys are the uniform name as specified in the program of this pass. The values can be a single string referencing a symbol or a semantic or a target OR a dictionary with the following structure:
{
target:
//optional: minificationFilter: linear, nearest magnificationFilter: linear, nearest mipFilter: linear, nearest, none wrapS: clamp, repeat, clampToBorder, mirror wrapT: clamp, repeat, clampToBorder, mirror wrapP: clamp, repeat, clampToBorder, mirror maxAnisotropy: a number }
(See SCNMaterialProperty for more documentation and default values of these optional parameters.)
semantic: vertex, normal, color, texcoord, tangent, time, modelViewProjectionTransform, modelViewTransform, modelTransform, viewTransform, projectionTransform, normalTransform, modelViewProjectionInverseTransform, modelViewInverseTransform, modelInverseTransform, viewInverseTransform, projectionInverseTransform, normalInverseTransform
type: float, vec2, vec3, vec4, mat4, int, ivec2, ivec3, ivec4, mat3, sampler2D, none. Every types can also be an array of the given type by adding [N] where N is the number of elements in the array.
image: name of an image located in the application bundle. (only valid when type is sampler2D)
if a semantic is set, no type is required. Note that with Metal shaders you should not provide any semantic. Instead simply declare a struct in you shader and add the members you need named as specified in SceneKit/scn_metal.
For example for a per-node semantic:
struct MyStruct { float4x4 modelTransform; float4x4 modelViewProjectionTransform; }; then in your function add an argument that must be named “scn_node” to get the members automatically filed with node semantics (see the documentation in scn_metal).
type: a string specifying the type of the render target. It can be one of the following: color, depth, stencil format: a string specifying the format of the render target. It can be:
- for color targets (if not specified defaults to the framebuffer’s pixel format)
- r8
- r16 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- r16f
- r32f // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- rg8 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- rg16
- rg16f // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- rg32f // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- rgba8 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- rgba16 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- rgba16f // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- rgba32f
- rgba (deprecated)
- for depth targets
- depth16 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- depth24
- depth32f // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- for combined depth and stencil targets:
- depth24Unorm_stencil8 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
- depth32Float_stencil8 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9 scaleFactor: a float value (encapsulated in a NSNumber) that controls the size of the render target. Defaults to 1, which means 1x the size of the main viewport. size: a string with the format %dx%d that controls the size of the render target. persistent: a boolean that tells if this target should persist from one frame to the next. It permits to create temporal effects suchs as motion blur. Defaults to NO.
<bundleIdentifier
An optional bundle identifier to load metal programs from
<metalLibraryName
An optional metal library name to load metal programs from. The metallib file is located from the default or specified bundle using NSBundle pathForResource:ofType:.
§Safety
dictionary generic should be of the correct type.
Sourcepub unsafe fn techniqueBySequencingTechniques(
techniques: &NSArray<SCNTechnique>,
) -> Option<Retained<SCNTechnique>>
pub unsafe fn techniqueBySequencingTechniques( techniques: &NSArray<SCNTechnique>, ) -> Option<Retained<SCNTechnique>>
Creates and returns a technique by sequencing the passes from the specified techniques.
Parameter techniques: The techniques to sequence.
The passes from “techniques” are executed sequentially. The symbols and targets are merged. This allows to use the same uniform ad targets across multiple techniques.
Sourcepub unsafe fn handleBindingOfSymbol_usingBlock(
&self,
symbol: &NSString,
block: SCNBindingBlock,
)
Available on crate features SCNNode and SCNRenderer and SCNShadable and block2 only.
pub unsafe fn handleBindingOfSymbol_usingBlock( &self, symbol: &NSString, block: SCNBindingBlock, )
SCNNode and SCNRenderer and SCNShadable and block2 only.Sets the block to call at render time to bind the value for the specified symbol of the receiver.
Parameter symbol: The name of the symbol to bind a value for.
Parameter block: The block to call to bind the specified symbol.
The block will be called at every frame for every pass referencing the specified symbol.
§Safety
block must be a valid pointer or null.
Sourcepub unsafe fn dictionaryRepresentation(
&self,
) -> Retained<NSDictionary<NSString, AnyObject>>
pub unsafe fn dictionaryRepresentation( &self, ) -> Retained<NSDictionary<NSString, AnyObject>>
Returns the dictionary representation of the technique.
Sourcepub unsafe fn objectForKeyedSubscript(
&self,
key: &AnyObject,
) -> Option<Retained<AnyObject>>
pub unsafe fn objectForKeyedSubscript( &self, key: &AnyObject, ) -> Option<Retained<AnyObject>>
§Safety
key should be of the correct type.
Sourcepub unsafe fn setObject_forKeyedSubscript(
&self,
obj: Option<&AnyObject>,
key: &ProtocolObject<dyn NSCopying>,
)
pub unsafe fn setObject_forKeyedSubscript( &self, obj: Option<&AnyObject>, key: &ProtocolObject<dyn NSCopying>, )
§Safety
objshould be of the correct type.keyshould be of the correct type.
Sourcepub unsafe fn library(&self) -> Option<Retained<ProtocolObject<dyn MTLLibrary>>>
Available on crate feature objc2-metal and non-watchOS only.
pub unsafe fn library(&self) -> Option<Retained<ProtocolObject<dyn MTLLibrary>>>
objc2-metal and non-watchOS only.The Metal library to use to load the Metal programs specified in the technique description. Defaults to nil which corresponds to the default Metal library.
Sourcepub unsafe fn setLibrary(
&self,
library: Option<&ProtocolObject<dyn MTLLibrary>>,
)
Available on crate feature objc2-metal and non-watchOS only.
pub unsafe fn setLibrary( &self, library: Option<&ProtocolObject<dyn MTLLibrary>>, )
objc2-metal and non-watchOS only.Setter for library.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for SCNTechnique
impl AsRef<AnyObject> for SCNTechnique
Source§impl AsRef<NSObject> for SCNTechnique
impl AsRef<NSObject> for SCNTechnique
Source§impl AsRef<SCNTechnique> for SCNTechnique
impl AsRef<SCNTechnique> for SCNTechnique
Source§impl Borrow<AnyObject> for SCNTechnique
impl Borrow<AnyObject> for SCNTechnique
Source§impl Borrow<NSObject> for SCNTechnique
impl Borrow<NSObject> for SCNTechnique
Source§impl ClassType for SCNTechnique
impl ClassType for SCNTechnique
Source§const NAME: &'static str = "SCNTechnique"
const NAME: &'static str = "SCNTechnique"
Source§type ThreadKind = <<SCNTechnique as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<SCNTechnique as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for SCNTechnique
impl CopyingHelper for SCNTechnique
Source§type Result = SCNTechnique
type Result = SCNTechnique
Self if the type has no
immutable counterpart. Read moreSource§impl Debug for SCNTechnique
impl Debug for SCNTechnique
Source§impl Deref for SCNTechnique
impl Deref for SCNTechnique
Source§impl Hash for SCNTechnique
impl Hash for SCNTechnique
Source§impl Message for SCNTechnique
impl Message for SCNTechnique
Source§impl NSCoding for SCNTechnique
impl NSCoding for SCNTechnique
Source§impl NSCopying for SCNTechnique
impl NSCopying for SCNTechnique
Source§impl NSObjectProtocol for SCNTechnique
impl NSObjectProtocol for SCNTechnique
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_refSource§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Source§impl NSSecureCoding for SCNTechnique
impl NSSecureCoding for SCNTechnique
Source§impl PartialEq for SCNTechnique
impl PartialEq for SCNTechnique
Source§impl RefEncode for SCNTechnique
impl RefEncode for SCNTechnique
Source§const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
Source§impl SCNAnimatable for SCNTechnique
impl SCNAnimatable for SCNTechnique
Source§unsafe fn addAnimation_forKey(
&self,
animation: &ProtocolObject<dyn SCNAnimationProtocol>,
key: Option<&NSString>,
)
unsafe fn addAnimation_forKey( &self, animation: &ProtocolObject<dyn SCNAnimationProtocol>, key: Option<&NSString>, )
SCNAnimation only.Source§unsafe fn addAnimationPlayer_forKey(
&self,
player: &SCNAnimationPlayer,
key: Option<&NSString>,
)
unsafe fn addAnimationPlayer_forKey( &self, player: &SCNAnimationPlayer, key: Option<&NSString>, )
SCNAnimation only.Source§unsafe fn removeAllAnimations(&self)
unsafe fn removeAllAnimations(&self)
SCNAnimation only.Source§unsafe fn removeAllAnimationsWithBlendOutDuration(&self, duration: CGFloat)
unsafe fn removeAllAnimationsWithBlendOutDuration(&self, duration: CGFloat)
SCNAnimation and objc2-core-foundation only.Source§unsafe fn removeAnimationForKey(&self, key: &NSString)
unsafe fn removeAnimationForKey(&self, key: &NSString)
SCNAnimation only.Source§unsafe fn removeAnimationForKey_blendOutDuration(
&self,
key: &NSString,
duration: CGFloat,
)
unsafe fn removeAnimationForKey_blendOutDuration( &self, key: &NSString, duration: CGFloat, )
SCNAnimation and objc2-core-foundation only.Source§unsafe fn animationKeys(&self) -> Retained<NSArray<NSString>>
unsafe fn animationKeys(&self) -> Retained<NSArray<NSString>>
SCNAnimation only.Source§unsafe fn animationPlayerForKey(
&self,
key: &NSString,
) -> Option<Retained<SCNAnimationPlayer>>
unsafe fn animationPlayerForKey( &self, key: &NSString, ) -> Option<Retained<SCNAnimationPlayer>>
SCNAnimation only.Source§unsafe fn removeAnimationForKey_fadeOutDuration(
&self,
key: &NSString,
duration: CGFloat,
)
unsafe fn removeAnimationForKey_fadeOutDuration( &self, key: &NSString, duration: CGFloat, )
SCNAnimation and objc2-core-foundation only.Source§unsafe fn animationForKey(
&self,
key: &NSString,
) -> Option<Retained<CAAnimation>>
unsafe fn animationForKey( &self, key: &NSString, ) -> Option<Retained<CAAnimation>>
SCNAnimation and crate feature objc2-quartz-core and non-watchOS only.Source§unsafe fn pauseAnimationForKey(&self, key: &NSString)
unsafe fn pauseAnimationForKey(&self, key: &NSString)
SCNAnimation only.Source§unsafe fn resumeAnimationForKey(&self, key: &NSString)
unsafe fn resumeAnimationForKey(&self, key: &NSString)
SCNAnimation only.