objc2_scene_kit/generated/
SCNScene.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15/// Signature of a block that will be called repeatedly while the scene is being exported.
16///
17/// Parameter `totalProgress`: is a floating-point number between 0 and 1. 0 means the loading process has just started and 1 that it is complete.
18///
19/// Parameter `error`: Will contain information about the failure if any.
20///
21/// Parameter `stop`: Set *stop to YES if you want to abort the operation.
22///
23/// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnsceneexportprogresshandler?language=objc)
24#[cfg(feature = "block2")]
25pub type SCNSceneExportProgressHandler =
26    *mut block2::Block<dyn Fn(c_float, *mut NSError, NonNull<Bool>)>;
27
28extern "C" {
29    /// Specifies the final destination (as a NSURL) of the scene being exported.
30    ///
31    /// The destination URL is required if the scene is exported to a temporary directory and then moved to a final destination. This enables the exported document to get correct relative paths to referenced images.
32    ///
33    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnsceneexportdestinationurl?language=objc)
34    pub static SCNSceneExportDestinationURL: &'static NSString;
35}
36
37/// Scene attributes
38///
39/// These keys can be used with the -[SCNScene attributeForKey:] method.
40///
41/// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnsceneattribute?language=objc)
42// NS_TYPED_ENUM
43pub type SCNSceneAttribute = NSString;
44
45extern "C" {
46    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnscenestarttimeattributekey?language=objc)
47    pub static SCNSceneStartTimeAttributeKey: &'static SCNSceneAttribute;
48}
49
50extern "C" {
51    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnsceneendtimeattributekey?language=objc)
52    pub static SCNSceneEndTimeAttributeKey: &'static SCNSceneAttribute;
53}
54
55extern "C" {
56    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnsceneframerateattributekey?language=objc)
57    pub static SCNSceneFrameRateAttributeKey: &'static SCNSceneAttribute;
58}
59
60extern "C" {
61    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnsceneupaxisattributekey?language=objc)
62    pub static SCNSceneUpAxisAttributeKey: &'static SCNSceneAttribute;
63}
64
65extern_class!(
66    /// SCNScene is the class that describes a 3d scene. It encapsulates a node hierarchy.
67    ///
68    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnscene?language=objc)
69    #[unsafe(super(NSObject))]
70    #[derive(Debug, PartialEq, Eq, Hash)]
71    pub struct SCNScene;
72);
73
74unsafe impl NSCoding for SCNScene {}
75
76unsafe impl NSObjectProtocol for SCNScene {}
77
78unsafe impl NSSecureCoding for SCNScene {}
79
80impl SCNScene {
81    extern_methods!(
82        #[unsafe(method(scene))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn scene() -> Retained<Self>;
85
86        #[cfg(feature = "SCNNode")]
87        /// Specifies the root node of the node hierarchy.
88        ///
89        /// Note that we have only one root node, whereas some file formats might have many nodes
90        /// at the root of their hierarchies. The root node(s) of the imported files will therefore be children
91        /// of the SCNScene's root node.
92        #[unsafe(method(rootNode))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn rootNode(&self) -> Retained<SCNNode>;
95
96        #[cfg(feature = "SCNPhysicsWorld")]
97        /// Specifies the physics world of the receiver.
98        ///
99        /// Every scene automatically creates a physics world object to simulate physics on nodes in the scene. You use this property to access the scene’s global physics properties, such as gravity. To add physics to a particular node, see physicsBody.
100        #[unsafe(method(physicsWorld))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn physicsWorld(&self) -> Retained<SCNPhysicsWorld>;
103
104        /// Retrieves a scene attribute.
105        ///
106        /// The available keys are listed in the "Scene attributes" group.
107        ///
108        /// Parameter `key`: An NSString object that specifies the attribute to be read
109        #[unsafe(method(attributeForKey:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn attributeForKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;
112
113        /// Sets a scene attribute
114        ///
115        /// The available keys are listed in the "Scene attributes" group.
116        ///
117        /// Parameter `attribute`: An object that specifies the value of the attribute to be written.
118        ///
119        /// Parameter `key`: An NSString object that specifies the attribute to be written
120        #[unsafe(method(setAttribute:forKey:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setAttribute_forKey(&self, attribute: Option<&AnyObject>, key: &NSString);
123
124        #[cfg(feature = "SCNMaterialProperty")]
125        /// Specifies the background of the receiver.
126        ///
127        /// The background is rendered before the rest of the scene.
128        /// The background can be rendered as a skybox by setting a cube map as described in SCNMaterialProperty.h
129        /// Colors are supported starting in macOS 10.12 and iOS 10. Prior to that you can use SCNView.backgroundColor.
130        /// MDLSkyCubeTexture is supported starting in macOS 10.13 and iOS 11.
131        #[unsafe(method(background))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn background(&self) -> Retained<SCNMaterialProperty>;
134
135        #[cfg(feature = "SCNMaterialProperty")]
136        /// Specifies the receiver's environment for image-based lighting (IBL).
137        ///
138        /// The environment can be
139        /// - a cube map (as described in SCNMaterialProperty.h)
140        /// - an instance of `MDLSkyCubeTexture` (supported since macOS 10.13 and iOS 11)
141        /// - an object returned by `+[SCNMaterialProperty precomputedLightingEnvironmentContentsWithURL:error:]` or `+[SCNMaterialProperty precomputedLightingEnvironmentContentsWithData:error:]`
142        #[unsafe(method(lightingEnvironment))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn lightingEnvironment(&self) -> Retained<SCNMaterialProperty>;
145
146        /// Creates and returns a scene associated with the specified filename.
147        ///
148        /// Parameter `name`: The name of the file. The method looks for a file with the specified name in the application’s main bundle.
149        ///
150        /// This method initializes with no options and does not check for errors. The resulting object is not cached.
151        #[unsafe(method(sceneNamed:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn sceneNamed(name: &NSString) -> Option<Retained<Self>>;
154
155        #[cfg(feature = "SCNSceneSource")]
156        /// Creates and returns a scene associated with the specified filename.
157        ///
158        /// Parameter `name`: The name of the file. The method looks for a file with the specified name in the application’s main bundle.
159        ///
160        /// Parameter `directory`: The name of the bundle sub-directory to search into.
161        ///
162        /// Parameter `options`: An options dictionary. The relevant keys are documented in the SCNSceneSource class.
163        ///
164        /// This method initializes with no options and does not check for errors. The resulting object is not cached.
165        #[unsafe(method(sceneNamed:inDirectory:options:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn sceneNamed_inDirectory_options(
168            name: &NSString,
169            directory: Option<&NSString>,
170            options: Option<&NSDictionary<SCNSceneSourceLoadingOption, AnyObject>>,
171        ) -> Option<Retained<Self>>;
172
173        #[cfg(feature = "SCNSceneSource")]
174        /// Creates and returns a scene from the specified URL.
175        ///
176        /// Parameter `url`: The URL to the 3D file.
177        ///
178        /// Parameter `options`: An options dictionary. The relevant keys are documented in the SCNSceneSource class.
179        ///
180        /// Parameter `error`: A NSError object passed by reference to get more information about the error when a nil is returned.
181        ///
182        /// This method is here for convenience. It is equivalent to initializing a SCNSceneSource with the specified
183        /// url and options, and asking it for its scene with the same options.
184        #[unsafe(method(sceneWithURL:options:error:_))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn sceneWithURL_options_error(
187            url: &NSURL,
188            options: Option<&NSDictionary<SCNSceneSourceLoadingOption, AnyObject>>,
189        ) -> Result<Retained<Self>, Retained<NSError>>;
190
191        #[cfg(feature = "block2")]
192        /// write the scene to the specified url.
193        ///
194        /// Parameter `url`: the destination url to write the scene to.
195        ///
196        /// Parameter `options`: A dictionary of options. The valid keys are described in the "Scene writing options" section.
197        ///
198        /// Parameter `delegate`: an optional delegate to manage external references such as images.
199        ///
200        /// Parameter `progressHandler`: an optional block to handle the progress of the operation.
201        ///
202        /// Returns: Returns YES if the operation succeeded, NO otherwise. Errors checking can be done via the "error"
203        /// parameter of the 'progressHandler'.
204        ///
205        /// macOS 10.10 and lower only supports exporting to .dae files.
206        /// Starting macOS 10.11 exporting supports .dae, .scn as well as file all formats supported by Model I/O.
207        /// Starting iOS 10 exporting supports .scn as well as all file formats supported by Model I/O.
208        #[unsafe(method(writeToURL:options:delegate:progressHandler:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn writeToURL_options_delegate_progressHandler(
211            &self,
212            url: &NSURL,
213            options: Option<&NSDictionary<NSString, AnyObject>>,
214            delegate: Option<&ProtocolObject<dyn SCNSceneExportDelegate>>,
215            progress_handler: SCNSceneExportProgressHandler,
216        ) -> bool;
217
218        #[cfg(feature = "objc2-core-foundation")]
219        /// Specifies the receiver's fog start distance. Animatable. Defaults to 0.
220        #[unsafe(method(fogStartDistance))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn fogStartDistance(&self) -> CGFloat;
223
224        #[cfg(feature = "objc2-core-foundation")]
225        /// Setter for [`fogStartDistance`][Self::fogStartDistance].
226        #[unsafe(method(setFogStartDistance:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn setFogStartDistance(&self, fog_start_distance: CGFloat);
229
230        #[cfg(feature = "objc2-core-foundation")]
231        /// Specifies the receiver's fog end distance. Animatable. Defaults to 0.
232        #[unsafe(method(fogEndDistance))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn fogEndDistance(&self) -> CGFloat;
235
236        #[cfg(feature = "objc2-core-foundation")]
237        /// Setter for [`fogEndDistance`][Self::fogEndDistance].
238        #[unsafe(method(setFogEndDistance:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setFogEndDistance(&self, fog_end_distance: CGFloat);
241
242        #[cfg(feature = "objc2-core-foundation")]
243        /// Specifies the receiver's fog power exponent. Animatable. Defaults to 1.
244        ///
245        /// Controls the attenuation between the start and end fog distances. 0 means a constant fog, 1 a linear fog and 2 a quadratic fog, but any positive value will work.
246        #[unsafe(method(fogDensityExponent))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn fogDensityExponent(&self) -> CGFloat;
249
250        #[cfg(feature = "objc2-core-foundation")]
251        /// Setter for [`fogDensityExponent`][Self::fogDensityExponent].
252        #[unsafe(method(setFogDensityExponent:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setFogDensityExponent(&self, fog_density_exponent: CGFloat);
255
256        /// Specifies the receiver's fog color (NSColor or CGColorRef). Animatable. Defaults to white.
257        ///
258        /// The initial value is a NSColor.
259        #[unsafe(method(fogColor))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn fogColor(&self) -> Retained<AnyObject>;
262
263        /// Setter for [`fogColor`][Self::fogColor].
264        #[unsafe(method(setFogColor:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn setFogColor(&self, fog_color: &AnyObject);
267
268        /// Determines if the scene use screen space reflection.
269        ///
270        /// Defaults to NO.
271        #[unsafe(method(wantsScreenSpaceReflection))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn wantsScreenSpaceReflection(&self) -> bool;
274
275        /// Setter for [`wantsScreenSpaceReflection`][Self::wantsScreenSpaceReflection].
276        #[unsafe(method(setWantsScreenSpaceReflection:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn setWantsScreenSpaceReflection(&self, wants_screen_space_reflection: bool);
279
280        /// Determines the sample count of the screen space reflection.
281        ///
282        /// Defaults to 64.
283        #[unsafe(method(screenSpaceReflectionSampleCount))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn screenSpaceReflectionSampleCount(&self) -> NSInteger;
286
287        /// Setter for [`screenSpaceReflectionSampleCount`][Self::screenSpaceReflectionSampleCount].
288        #[unsafe(method(setScreenSpaceReflectionSampleCount:))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn setScreenSpaceReflectionSampleCount(
291            &self,
292            screen_space_reflection_sample_count: NSInteger,
293        );
294
295        #[cfg(feature = "objc2-core-foundation")]
296        /// Determines the maximum distance in world units.
297        ///
298        /// Defaults to 1000.
299        #[unsafe(method(screenSpaceReflectionMaximumDistance))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn screenSpaceReflectionMaximumDistance(&self) -> CGFloat;
302
303        #[cfg(feature = "objc2-core-foundation")]
304        /// Setter for [`screenSpaceReflectionMaximumDistance`][Self::screenSpaceReflectionMaximumDistance].
305        #[unsafe(method(setScreenSpaceReflectionMaximumDistance:))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn setScreenSpaceReflectionMaximumDistance(
308            &self,
309            screen_space_reflection_maximum_distance: CGFloat,
310        );
311
312        #[cfg(feature = "objc2-core-foundation")]
313        /// Raytracing step size in pixel. The lower the better, the higher the faster.
314        ///
315        /// Defaults to 8.
316        #[unsafe(method(screenSpaceReflectionStride))]
317        #[unsafe(method_family = none)]
318        pub unsafe fn screenSpaceReflectionStride(&self) -> CGFloat;
319
320        #[cfg(feature = "objc2-core-foundation")]
321        /// Setter for [`screenSpaceReflectionStride`][Self::screenSpaceReflectionStride].
322        #[unsafe(method(setScreenSpaceReflectionStride:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn setScreenSpaceReflectionStride(
325            &self,
326            screen_space_reflection_stride: CGFloat,
327        );
328
329        /// Controls whether or not the scene is paused. Defaults to NO.
330        ///
331        /// Pausing a scene will pause animations, actions, particles and physics.
332        #[unsafe(method(isPaused))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn isPaused(&self) -> bool;
335
336        /// Setter for [`isPaused`][Self::isPaused].
337        #[unsafe(method(setPaused:))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn setPaused(&self, paused: bool);
340    );
341}
342
343/// Methods declared on superclass `NSObject`.
344impl SCNScene {
345    extern_methods!(
346        #[unsafe(method(init))]
347        #[unsafe(method_family = init)]
348        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
349
350        #[unsafe(method(new))]
351        #[unsafe(method_family = new)]
352        pub unsafe fn new() -> Retained<Self>;
353    );
354}
355
356extern_protocol!(
357    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnsceneexportdelegate?language=objc)
358    pub unsafe trait SCNSceneExportDelegate: NSObjectProtocol {
359        #[cfg(feature = "objc2-app-kit")]
360        #[cfg(target_os = "macos")]
361        /// Invoked on the delegate to write the referenced image and return the destination url.
362        ///
363        /// Parameter `image`: The image to write.
364        ///
365        /// Parameter `documentURL`: The url where the scene is currently exported to.
366        ///
367        /// Parameter `originalImageURL`: The original url for the image. May be nil if the image was not previously loaded from a url.
368        ///
369        /// Returns: The delegate must returns the url of the image that was exported or nil if it didn't export any image. If the returned value is nil, the image will be exported to a default destination in a default format.
370        #[optional]
371        #[unsafe(method(writeImage:withSceneDocumentURL:originalImageURL:))]
372        #[unsafe(method_family = none)]
373        unsafe fn writeImage_withSceneDocumentURL_originalImageURL(
374            &self,
375            image: &NSImage,
376            document_url: &NSURL,
377            original_image_url: Option<&NSURL>,
378        ) -> Option<Retained<NSURL>>;
379    }
380);