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::DynBlock<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
74extern_conformance!(
75 unsafe impl NSCoding for SCNScene {}
76);
77
78extern_conformance!(
79 unsafe impl NSObjectProtocol for SCNScene {}
80);
81
82extern_conformance!(
83 unsafe impl NSSecureCoding for SCNScene {}
84);
85
86impl SCNScene {
87 extern_methods!(
88 #[unsafe(method(scene))]
89 #[unsafe(method_family = none)]
90 pub unsafe fn scene() -> Retained<Self>;
91
92 #[cfg(feature = "SCNNode")]
93 /// Specifies the root node of the node hierarchy.
94 ///
95 /// Note that we have only one root node, whereas some file formats might have many nodes
96 /// at the root of their hierarchies. The root node(s) of the imported files will therefore be children
97 /// of the SCNScene's root node.
98 #[unsafe(method(rootNode))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn rootNode(&self) -> Retained<SCNNode>;
101
102 #[cfg(feature = "SCNPhysicsWorld")]
103 /// Specifies the physics world of the receiver.
104 ///
105 /// 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.
106 #[unsafe(method(physicsWorld))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn physicsWorld(&self) -> Retained<SCNPhysicsWorld>;
109
110 /// Retrieves a scene attribute.
111 ///
112 /// The available keys are listed in the "Scene attributes" group.
113 ///
114 /// Parameter `key`: An NSString object that specifies the attribute to be read
115 #[unsafe(method(attributeForKey:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn attributeForKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;
118
119 /// Sets a scene attribute
120 ///
121 /// The available keys are listed in the "Scene attributes" group.
122 ///
123 /// Parameter `attribute`: An object that specifies the value of the attribute to be written.
124 ///
125 /// Parameter `key`: An NSString object that specifies the attribute to be written
126 #[unsafe(method(setAttribute:forKey:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn setAttribute_forKey(&self, attribute: Option<&AnyObject>, key: &NSString);
129
130 #[cfg(feature = "SCNMaterialProperty")]
131 /// Specifies the background of the receiver.
132 ///
133 /// The background is rendered before the rest of the scene.
134 /// The background can be rendered as a skybox by setting a cube map as described in SCNMaterialProperty.h
135 /// Colors are supported starting in macOS 10.12 and iOS 10. Prior to that you can use SCNView.backgroundColor.
136 /// MDLSkyCubeTexture is supported starting in macOS 10.13 and iOS 11.
137 #[unsafe(method(background))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn background(&self) -> Retained<SCNMaterialProperty>;
140
141 #[cfg(feature = "SCNMaterialProperty")]
142 /// Specifies the receiver's environment for image-based lighting (IBL).
143 ///
144 /// The environment can be
145 /// - a cube map (as described in SCNMaterialProperty.h)
146 /// - an instance of `MDLSkyCubeTexture` (supported since macOS 10.13 and iOS 11)
147 /// - an object returned by `+[SCNMaterialProperty precomputedLightingEnvironmentContentsWithURL:error:]` or `+[SCNMaterialProperty precomputedLightingEnvironmentContentsWithData:error:]`
148 #[unsafe(method(lightingEnvironment))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn lightingEnvironment(&self) -> Retained<SCNMaterialProperty>;
151
152 /// Creates and returns a scene associated with the specified filename.
153 ///
154 /// Parameter `name`: The name of the file. The method looks for a file with the specified name in the application’s main bundle.
155 ///
156 /// This method initializes with no options and does not check for errors. The resulting object is not cached.
157 #[unsafe(method(sceneNamed:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn sceneNamed(name: &NSString) -> Option<Retained<Self>>;
160
161 #[cfg(feature = "SCNSceneSource")]
162 /// Creates and returns a scene associated with the specified filename.
163 ///
164 /// Parameter `name`: The name of the file. The method looks for a file with the specified name in the application’s main bundle.
165 ///
166 /// Parameter `directory`: The name of the bundle sub-directory to search into.
167 ///
168 /// Parameter `options`: An options dictionary. The relevant keys are documented in the SCNSceneSource class.
169 ///
170 /// This method initializes with no options and does not check for errors. The resulting object is not cached.
171 #[unsafe(method(sceneNamed:inDirectory:options:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn sceneNamed_inDirectory_options(
174 name: &NSString,
175 directory: Option<&NSString>,
176 options: Option<&NSDictionary<SCNSceneSourceLoadingOption, AnyObject>>,
177 ) -> Option<Retained<Self>>;
178
179 #[cfg(feature = "SCNSceneSource")]
180 /// Creates and returns a scene from the specified URL.
181 ///
182 /// Parameter `url`: The URL to the 3D file.
183 ///
184 /// Parameter `options`: An options dictionary. The relevant keys are documented in the SCNSceneSource class.
185 ///
186 /// Parameter `error`: A NSError object passed by reference to get more information about the error when a nil is returned.
187 ///
188 /// This method is here for convenience. It is equivalent to initializing a SCNSceneSource with the specified
189 /// url and options, and asking it for its scene with the same options.
190 #[unsafe(method(sceneWithURL:options:error:_))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn sceneWithURL_options_error(
193 url: &NSURL,
194 options: Option<&NSDictionary<SCNSceneSourceLoadingOption, AnyObject>>,
195 ) -> Result<Retained<Self>, Retained<NSError>>;
196
197 #[cfg(feature = "block2")]
198 /// write the scene to the specified url.
199 ///
200 /// Parameter `url`: the destination url to write the scene to.
201 ///
202 /// Parameter `options`: A dictionary of options. The valid keys are described in the "Scene writing options" section.
203 ///
204 /// Parameter `delegate`: an optional delegate to manage external references such as images.
205 ///
206 /// Parameter `progressHandler`: an optional block to handle the progress of the operation.
207 ///
208 /// Returns: Returns YES if the operation succeeded, NO otherwise. Errors checking can be done via the "error"
209 /// parameter of the 'progressHandler'.
210 ///
211 /// macOS 10.10 and lower only supports exporting to .dae files.
212 /// Starting macOS 10.11 exporting supports .dae, .scn as well as file all formats supported by Model I/O.
213 /// Starting iOS 10 exporting supports .scn as well as all file formats supported by Model I/O.
214 #[unsafe(method(writeToURL:options:delegate:progressHandler:))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn writeToURL_options_delegate_progressHandler(
217 &self,
218 url: &NSURL,
219 options: Option<&NSDictionary<NSString, AnyObject>>,
220 delegate: Option<&ProtocolObject<dyn SCNSceneExportDelegate>>,
221 progress_handler: SCNSceneExportProgressHandler,
222 ) -> bool;
223
224 #[cfg(feature = "objc2-core-foundation")]
225 /// Specifies the receiver's fog start distance. Animatable. Defaults to 0.
226 #[unsafe(method(fogStartDistance))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn fogStartDistance(&self) -> CGFloat;
229
230 #[cfg(feature = "objc2-core-foundation")]
231 /// Setter for [`fogStartDistance`][Self::fogStartDistance].
232 #[unsafe(method(setFogStartDistance:))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn setFogStartDistance(&self, fog_start_distance: CGFloat);
235
236 #[cfg(feature = "objc2-core-foundation")]
237 /// Specifies the receiver's fog end distance. Animatable. Defaults to 0.
238 #[unsafe(method(fogEndDistance))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn fogEndDistance(&self) -> CGFloat;
241
242 #[cfg(feature = "objc2-core-foundation")]
243 /// Setter for [`fogEndDistance`][Self::fogEndDistance].
244 #[unsafe(method(setFogEndDistance:))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn setFogEndDistance(&self, fog_end_distance: CGFloat);
247
248 #[cfg(feature = "objc2-core-foundation")]
249 /// Specifies the receiver's fog power exponent. Animatable. Defaults to 1.
250 ///
251 /// 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.
252 #[unsafe(method(fogDensityExponent))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn fogDensityExponent(&self) -> CGFloat;
255
256 #[cfg(feature = "objc2-core-foundation")]
257 /// Setter for [`fogDensityExponent`][Self::fogDensityExponent].
258 #[unsafe(method(setFogDensityExponent:))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn setFogDensityExponent(&self, fog_density_exponent: CGFloat);
261
262 /// Specifies the receiver's fog color (NSColor or CGColorRef). Animatable. Defaults to white.
263 ///
264 /// The initial value is a NSColor.
265 #[unsafe(method(fogColor))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn fogColor(&self) -> Retained<AnyObject>;
268
269 /// Setter for [`fogColor`][Self::fogColor].
270 #[unsafe(method(setFogColor:))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn setFogColor(&self, fog_color: &AnyObject);
273
274 /// Determines if the scene use screen space reflection.
275 ///
276 /// Defaults to NO.
277 #[unsafe(method(wantsScreenSpaceReflection))]
278 #[unsafe(method_family = none)]
279 pub unsafe fn wantsScreenSpaceReflection(&self) -> bool;
280
281 /// Setter for [`wantsScreenSpaceReflection`][Self::wantsScreenSpaceReflection].
282 #[unsafe(method(setWantsScreenSpaceReflection:))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn setWantsScreenSpaceReflection(&self, wants_screen_space_reflection: bool);
285
286 /// Determines the sample count of the screen space reflection.
287 ///
288 /// Defaults to 64.
289 #[unsafe(method(screenSpaceReflectionSampleCount))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn screenSpaceReflectionSampleCount(&self) -> NSInteger;
292
293 /// Setter for [`screenSpaceReflectionSampleCount`][Self::screenSpaceReflectionSampleCount].
294 #[unsafe(method(setScreenSpaceReflectionSampleCount:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn setScreenSpaceReflectionSampleCount(
297 &self,
298 screen_space_reflection_sample_count: NSInteger,
299 );
300
301 #[cfg(feature = "objc2-core-foundation")]
302 /// Determines the maximum distance in world units.
303 ///
304 /// Defaults to 1000.
305 #[unsafe(method(screenSpaceReflectionMaximumDistance))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn screenSpaceReflectionMaximumDistance(&self) -> CGFloat;
308
309 #[cfg(feature = "objc2-core-foundation")]
310 /// Setter for [`screenSpaceReflectionMaximumDistance`][Self::screenSpaceReflectionMaximumDistance].
311 #[unsafe(method(setScreenSpaceReflectionMaximumDistance:))]
312 #[unsafe(method_family = none)]
313 pub unsafe fn setScreenSpaceReflectionMaximumDistance(
314 &self,
315 screen_space_reflection_maximum_distance: CGFloat,
316 );
317
318 #[cfg(feature = "objc2-core-foundation")]
319 /// Raytracing step size in pixel. The lower the better, the higher the faster.
320 ///
321 /// Defaults to 8.
322 #[unsafe(method(screenSpaceReflectionStride))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn screenSpaceReflectionStride(&self) -> CGFloat;
325
326 #[cfg(feature = "objc2-core-foundation")]
327 /// Setter for [`screenSpaceReflectionStride`][Self::screenSpaceReflectionStride].
328 #[unsafe(method(setScreenSpaceReflectionStride:))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn setScreenSpaceReflectionStride(
331 &self,
332 screen_space_reflection_stride: CGFloat,
333 );
334
335 /// Controls whether or not the scene is paused. Defaults to NO.
336 ///
337 /// Pausing a scene will pause animations, actions, particles and physics.
338 #[unsafe(method(isPaused))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn isPaused(&self) -> bool;
341
342 /// Setter for [`isPaused`][Self::isPaused].
343 #[unsafe(method(setPaused:))]
344 #[unsafe(method_family = none)]
345 pub unsafe fn setPaused(&self, paused: bool);
346 );
347}
348
349/// Methods declared on superclass `NSObject`.
350impl SCNScene {
351 extern_methods!(
352 #[unsafe(method(init))]
353 #[unsafe(method_family = init)]
354 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
355
356 #[unsafe(method(new))]
357 #[unsafe(method_family = new)]
358 pub unsafe fn new() -> Retained<Self>;
359 );
360}
361
362extern_protocol!(
363 /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnsceneexportdelegate?language=objc)
364 pub unsafe trait SCNSceneExportDelegate: NSObjectProtocol {
365 #[cfg(feature = "objc2-app-kit")]
366 #[cfg(target_os = "macos")]
367 /// Invoked on the delegate to write the referenced image and return the destination url.
368 ///
369 /// Parameter `image`: The image to write.
370 ///
371 /// Parameter `documentURL`: The url where the scene is currently exported to.
372 ///
373 /// Parameter `originalImageURL`: The original url for the image. May be nil if the image was not previously loaded from a url.
374 ///
375 /// 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.
376 #[optional]
377 #[unsafe(method(writeImage:withSceneDocumentURL:originalImageURL:))]
378 #[unsafe(method_family = none)]
379 unsafe fn writeImage_withSceneDocumentURL_originalImageURL(
380 &self,
381 image: &NSImage,
382 document_url: &NSURL,
383 original_image_url: Option<&NSURL>,
384 ) -> Option<Retained<NSURL>>;
385 }
386);