objc2-model-io 0.3.2

Bindings to the ModelIO framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// MDLCamera
///
/// MDLCamera models a physically plausible camera.
///
///
/// Values are represented as float in MDLCamera as it offers sufficient
/// precision, and because calculations will be identical on any processor
/// architecture. This consistency is a requirement of the model.
///
/// MDLCamera provides the a model of the parameters governing the physical process
/// of transforming a scene into an image.
///
/// This process is modeled as a series of steps, each governed by the physical
/// properties of real world cameras.
///
/// 1. The position and orientation of the camera
///
/// See: MDLObject transform property
///
/// The MDLTransformComponent on an MDLCamera is an MDLTransform.
///
/// 2. Visible Objects and Lights
///
/// visible object
///
/// visible object
///
/// Those objects existing between nearVisibilityDistance and farVisibilityDistance
/// are considered to be visible. All lights are considered, irrespective of
/// nearVisibilityDistance and farVisibilityDistance, to compute scene luminance.
///
///
/// Some calculations, such as the calculation of stereo view matrices, require
/// calculations to occur in world space. Significant quantities measured in mm
/// therefore use this conversion scale to perform the calculation. The default
/// value is 1.0.
///
/// 3. Scene Luminance through the lens
///
///
///
/// Illuminated objects result in scene luminance, which passes through the lens.
/// All lenses impose some amount of radial distortion which can be computed from
/// focal length. However, some lenses introduce error, and radial distortion can
/// be used as an aesthetic control as well. Therefore radial distortion is
/// provided as a property. If r is the radial distance of a pixel from the center
/// of the projection, then radial distortion is computed as
///
/// r' = r * (1 + barrelDistorion * r^2 + fisheyeDistortion * r^4)
///
/// radialDistortion sufficiently describes the distortion characteristic of most
/// lenses. In order to simulate certain other lenses, such as those found in
/// security cameras, fisheye lenses, plastic toy lenses, sport cameras, or some
/// VR headsets, radialDistortion2 is introduced.
///
/// The default for the radial distortion parameters is zero, resulting in a
/// rectilinear projection.
///
///
/// Optical vignetting occurs to some degree in all lenses. It results from light
/// at the edge of an image being blocked as it travels past the lens hood and
/// the internal lens apertures. It is more prevalent with wide apertures. A
/// value of zero indicates no optical vignetting is occuring, and a value of one
/// indicates that vignetting affects all locations in the image according to
/// radial distance. Optical vignetting also occurs in head mounted displays, and
/// the value here can be used as an intended amount of vignetting to apply to an
/// image.
///
///
/// Chromatic aberration occurs to some degree in all lenses. It results from a
/// lens bringing different wavelengths of light to focus at different places on
/// the image plane. A value of zero indicates no chromatic aberration is
/// occurring, and one indicates maximum. Chromatic aberration affects all
/// locations in the image according to radial distance. Chromatic aberration
/// also occurs in head mounted displays, and the value here can be used as an
/// intended amount of chromatic aberration to apply to an image.
///
/// 4. Geometry of the lens
///
/// This is a thin lens model.
///
///
/// The default focal length is 50mm, corresponding to a field of view of 54
/// degrees, and vertical sensor aperture of 24mm. Changing focalLength will
/// update the field of view property.
///
///
/// The distance, in meters, at which the lens is focused. The default is 2.5m.
///
///
/// The field of view is calculated from the focal length and sensor aperture.
/// Changing the field of view will update the focalLength property with respect
/// to the sensor aperture. The default is 54 degrees, corresponding to a focal
/// length of 50mm, and a vertical sensor aperture of 24mm.
///
///
/// The f-stop is the ratio of the lens' focal length to the diameter of the
/// entrance pupil. The default is 5.6. It controls the amount of light that
/// reaches the sensor, as well as the size of out of focus parts of the image.
/// The diameter of the entrance pupil, is therefore obtained
/// by dividing the fStop by the focalLength.
///
/// 5. Lens exit aperture
///
///
/// The shape of out of focus highlights in a scene is commonly known as "bokeh".
/// The aesthetic quality of a lens' bokeh is one of the characteristics that
/// drives the choice of a lens for a particular scene. To a large degree, the
/// appearance of bokeh is governed by the shape of the lens aperture. Typical
/// lens apertures are controlled by a series of overlapping blades that can be
/// irised open and closed. A lens with a five blade aperture will yield a five
/// sided bokeh. The default is zero, which is to be interpreted as a perfectly
/// round aperture.
///
/// Note that the effect of a filter on the front of the lens can be modeled
/// equivalently at the exit aperture. The MIOCamera does not explicitly provide
/// specification of such effects, but a simulation could incorporate them at
/// this stage.
///
///
/// Although the size of an out of focus bokeh highlight can be computed from
/// other camera properties, it is often necessary to limit the size of the
/// circle of confusion for aesthetic reasons. The circle of confusion is
/// specified in mm, and the default is 0.05mm. The units are mm on the sensor
/// plane.
///
///
/// The length of time in seconds the shutter is open, impacting the amount of
/// light that reaches the sensor and also the length of motion blur trails. The
/// shutter time is not the same thing as scene frame rate. The rule of thumb for
/// movies is that the shutter time should be half the frame rate, so to achieve
/// a "filmic" look, the shutter time choice might be 1/48 of a second, since
/// films are usually projected at 24 frames per second. Shutter time is
/// independent of simulation frame rate because motion blur trails and exposure
/// times should be held constant in order to avoid flicker artifacts.
///
/// 6. Sensor illuminance
///
///
/// The default aperture is 24mm, corresponding to a 35mm stills camera.
/// _____________________
/// [][][][][][][][][][][              ^
/// \
/// |         |
/// \
/// ^       |
/// \
/// |         |
/// \
/// 24mm   35mm
/// \
/// |         |
/// \
/// v       |
/// ][][][][][][][][][][]           v
/// ---------------------
/// <
/// - 36mm -->
///
/// Changing the aperture will update the field of view property with respect to
/// the focal length. The horizontal aperture can be calculated from the aspect
/// property.
///
///
/// aspect ratio of width versus height of the sensor aperture. The default is
/// 36mm/24mm, ie: 1.5.
///
///
/// The sensor enlargment property scales the active region of the sensor. A
/// zoom factor of 2 will result in the central portion of the image being
/// cropped and expanded to fill the image plane. The default is 1.
///
///
/// The sensor shift property moves the center of the sensor relative to the
/// lens. This is useful in certain calculations, such as shadow or reflection
/// projections, as well as to provide vergence in a parallel stereoscopic camera.
///
/// 7. Exposure
///
/// Finally, the sensor values need to be converted for display.
///
///
/// Flashing is applied to a film stock some time before processing. It is a
/// small and even level of exposure added to the entire image intended shift
/// the brightness and color of darker areas of the image. Since exposure is
/// logarithmic, flash does not affect midtones or highlights.
///
/// The equivalent to flash in a color grading system is known as lift. Typically
/// red, green, and blue can be controlled independently.
///
/// A negative value for flash can be used to subtract color.
///
///
/// Finally, exposure should be applied to the compressed value. Red,
/// green, and blue exposure can be specified separately. The default is 1.0.
///
///
/// Gamma curve compression where values below the x value are to be passed through,
/// about the y value, values are to be clamped at maximum display brightness,
/// and a function such as a logarithmic ramp is to be applied in between. The
/// default is (1,0, 1.0).
///
/// A displayable value is therefore obtained via
/// pow(exposureCompression((sensor value + flash) * exposure), displayGamma)
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlcameraprojection?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MDLCameraProjection(pub NSUInteger);
impl MDLCameraProjection {
    #[doc(alias = "MDLCameraProjectionPerspective")]
    pub const Perspective: Self = Self(0);
    #[doc(alias = "MDLCameraProjectionOrthographic")]
    pub const Orthographic: Self = Self(1);
}

unsafe impl Encode for MDLCameraProjection {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MDLCameraProjection {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlcamera?language=objc)
    #[unsafe(super(MDLObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "MDLObject")]
    pub struct MDLCamera;
);

#[cfg(all(feature = "MDLObject", feature = "MDLTypes"))]
extern_conformance!(
    unsafe impl MDLNamed for MDLCamera {}
);

#[cfg(feature = "MDLObject")]
extern_conformance!(
    unsafe impl NSObjectProtocol for MDLCamera {}
);

#[cfg(feature = "MDLObject")]
impl MDLCamera {
    extern_methods!(
        #[unsafe(method(projection))]
        #[unsafe(method_family = none)]
        pub unsafe fn projection(&self) -> MDLCameraProjection;

        /// Setter for [`projection`][Self::projection].
        #[unsafe(method(setProjection:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setProjection(&self, projection: MDLCameraProjection);

        /// Bounding distance for visible objects
        #[unsafe(method(nearVisibilityDistance))]
        #[unsafe(method_family = none)]
        pub unsafe fn nearVisibilityDistance(&self) -> c_float;

        /// Setter for [`nearVisibilityDistance`][Self::nearVisibilityDistance].
        #[unsafe(method(setNearVisibilityDistance:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setNearVisibilityDistance(&self, near_visibility_distance: c_float);

        #[unsafe(method(farVisibilityDistance))]
        #[unsafe(method_family = none)]
        pub unsafe fn farVisibilityDistance(&self) -> c_float;

        /// Setter for [`farVisibilityDistance`][Self::farVisibilityDistance].
        #[unsafe(method(setFarVisibilityDistance:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFarVisibilityDistance(&self, far_visibility_distance: c_float);

        /// World to meters conversion scale. Required for certain calculations.
        #[unsafe(method(worldToMetersConversionScale))]
        #[unsafe(method_family = none)]
        pub unsafe fn worldToMetersConversionScale(&self) -> c_float;

        /// Setter for [`worldToMetersConversionScale`][Self::worldToMetersConversionScale].
        #[unsafe(method(setWorldToMetersConversionScale:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setWorldToMetersConversionScale(
            &self,
            world_to_meters_conversion_scale: c_float,
        );

        /// Radial distortion of the lens, second order term
        #[unsafe(method(barrelDistortion))]
        #[unsafe(method_family = none)]
        pub unsafe fn barrelDistortion(&self) -> c_float;

        /// Setter for [`barrelDistortion`][Self::barrelDistortion].
        #[unsafe(method(setBarrelDistortion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBarrelDistortion(&self, barrel_distortion: c_float);

        /// Radial distortion of the lens, fourth order term
        #[unsafe(method(fisheyeDistortion))]
        #[unsafe(method_family = none)]
        pub unsafe fn fisheyeDistortion(&self) -> c_float;

        /// Setter for [`fisheyeDistortion`][Self::fisheyeDistortion].
        #[unsafe(method(setFisheyeDistortion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFisheyeDistortion(&self, fisheye_distortion: c_float);

        /// Amount of optical vignetting, rom zero to one.
        #[unsafe(method(opticalVignetting))]
        #[unsafe(method_family = none)]
        pub unsafe fn opticalVignetting(&self) -> c_float;

        /// Setter for [`opticalVignetting`][Self::opticalVignetting].
        #[unsafe(method(setOpticalVignetting:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setOpticalVignetting(&self, optical_vignetting: c_float);

        /// Amount of chromatic abberation, from zero to one.
        #[unsafe(method(chromaticAberration))]
        #[unsafe(method_family = none)]
        pub unsafe fn chromaticAberration(&self) -> c_float;

        /// Setter for [`chromaticAberration`][Self::chromaticAberration].
        #[unsafe(method(setChromaticAberration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setChromaticAberration(&self, chromatic_aberration: c_float);

        /// Lens focal length in mm.
        ///
        /// See: fieldOfView
        #[unsafe(method(focalLength))]
        #[unsafe(method_family = none)]
        pub unsafe fn focalLength(&self) -> c_float;

        /// Setter for [`focalLength`][Self::focalLength].
        #[unsafe(method(setFocalLength:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFocalLength(&self, focal_length: c_float);

        /// Focus distance
        #[unsafe(method(focusDistance))]
        #[unsafe(method_family = none)]
        pub unsafe fn focusDistance(&self) -> c_float;

        /// Setter for [`focusDistance`][Self::focusDistance].
        #[unsafe(method(setFocusDistance:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFocusDistance(&self, focus_distance: c_float);

        /// The field of view, in degrees.
        ///
        /// See: focalLength
        #[unsafe(method(fieldOfView))]
        #[unsafe(method_family = none)]
        pub unsafe fn fieldOfView(&self) -> c_float;

        /// Setter for [`fieldOfView`][Self::fieldOfView].
        #[unsafe(method(setFieldOfView:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFieldOfView(&self, field_of_view: c_float);

        /// f-stop, default is 5.6
        #[unsafe(method(fStop))]
        #[unsafe(method_family = none)]
        pub unsafe fn fStop(&self) -> c_float;

        /// Setter for [`fStop`][Self::fStop].
        #[unsafe(method(setFStop:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFStop(&self, f_stop: c_float);

        /// Aperture blade count, where zero indicates a circle.
        #[unsafe(method(apertureBladeCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn apertureBladeCount(&self) -> NSUInteger;

        /// Setter for [`apertureBladeCount`][Self::apertureBladeCount].
        #[unsafe(method(setApertureBladeCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setApertureBladeCount(&self, aperture_blade_count: NSUInteger);

        /// Maximum circle of confusion size in mm on the image plane
        #[unsafe(method(maximumCircleOfConfusion))]
        #[unsafe(method_family = none)]
        pub unsafe fn maximumCircleOfConfusion(&self) -> c_float;

        /// Setter for [`maximumCircleOfConfusion`][Self::maximumCircleOfConfusion].
        #[unsafe(method(setMaximumCircleOfConfusion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaximumCircleOfConfusion(&self, maximum_circle_of_confusion: c_float);

        /// Shutter open interval, in seconds
        #[unsafe(method(shutterOpenInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn shutterOpenInterval(&self) -> NSTimeInterval;

        /// Setter for [`shutterOpenInterval`][Self::shutterOpenInterval].
        #[unsafe(method(setShutterOpenInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShutterOpenInterval(&self, shutter_open_interval: NSTimeInterval);

        /// vertical aperture of the sensor or film gate, default is 24mm
        ///
        /// See: sensorAspect
        #[unsafe(method(sensorVerticalAperture))]
        #[unsafe(method_family = none)]
        pub unsafe fn sensorVerticalAperture(&self) -> c_float;

        /// Setter for [`sensorVerticalAperture`][Self::sensorVerticalAperture].
        #[unsafe(method(setSensorVerticalAperture:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSensorVerticalAperture(&self, sensor_vertical_aperture: c_float);

        /// Sensor or film gate aperture aspect ratio, default is 1.5
        ///
        /// See: sensorVerticalAperture
        #[unsafe(method(sensorAspect))]
        #[unsafe(method_family = none)]
        pub unsafe fn sensorAspect(&self) -> c_float;

        /// Setter for [`sensorAspect`][Self::sensorAspect].
        #[unsafe(method(setSensorAspect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSensorAspect(&self, sensor_aspect: c_float);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLCamera {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlstereoscopiccamera?language=objc)
    #[unsafe(super(MDLCamera, MDLObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "MDLObject")]
    pub struct MDLStereoscopicCamera;
);

#[cfg(all(feature = "MDLObject", feature = "MDLTypes"))]
extern_conformance!(
    unsafe impl MDLNamed for MDLStereoscopicCamera {}
);

#[cfg(feature = "MDLObject")]
extern_conformance!(
    unsafe impl NSObjectProtocol for MDLStereoscopicCamera {}
);

#[cfg(feature = "MDLObject")]
impl MDLStereoscopicCamera {
    extern_methods!(
        /// Inter-pupillary distance in mm.
        /// Default is 63mm.
        #[unsafe(method(interPupillaryDistance))]
        #[unsafe(method_family = none)]
        pub unsafe fn interPupillaryDistance(&self) -> c_float;

        /// Setter for [`interPupillaryDistance`][Self::interPupillaryDistance].
        #[unsafe(method(setInterPupillaryDistance:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInterPupillaryDistance(&self, inter_pupillary_distance: c_float);

        /// Vergence in a stereoscopic camera can be controlled in two ways. A toed-in
        /// binocular stereoscopic camera rotates the lens and sensor together such that a
        /// ray projected from the center of either sensor and lens meets at a point. A
        /// parallel binocular stereoscopic camera accomplishes the same thing by shifting
        /// the relative centers of the sensor and lens.
        ///
        /// If a parallel binocular stereoscopic camera is modeled, the sensor should be
        /// considered to have shifted by an amount h. If left and right vergence are equal,
        /// h = (focal length * interOcularDistance) / distance to vergence point.
        ///
        /// Vergence is measured in degrees towards center and is usually positive.
        #[unsafe(method(leftVergence))]
        #[unsafe(method_family = none)]
        pub unsafe fn leftVergence(&self) -> c_float;

        /// Setter for [`leftVergence`][Self::leftVergence].
        #[unsafe(method(setLeftVergence:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLeftVergence(&self, left_vergence: c_float);

        #[unsafe(method(rightVergence))]
        #[unsafe(method_family = none)]
        pub unsafe fn rightVergence(&self) -> c_float;

        /// Setter for [`rightVergence`][Self::rightVergence].
        #[unsafe(method(setRightVergence:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRightVergence(&self, right_vergence: c_float);

        /// The amount, as a percentage of image width to offset an image towards the other
        /// camera. This value is used in a stereo grade to enhance or reduce the intensity
        /// of the stereoscopic effect
        #[unsafe(method(overlap))]
        #[unsafe(method_family = none)]
        pub unsafe fn overlap(&self) -> c_float;

        /// Setter for [`overlap`][Self::overlap].
        #[unsafe(method(setOverlap:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setOverlap(&self, overlap: c_float);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLStereoscopicCamera {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}