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