objc2_model_io/generated/
MDLCamera.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// MDLCamera
11///
12/// MDLCamera models a physically plausible camera.
13///
14///
15/// Values are represented as float in MDLCamera as it offers sufficient
16/// precision, and because calculations will be identical on any processor
17/// architecture. This consistency is a requirement of the model.
18///
19/// MDLCamera provides the a model of the parameters governing the physical process
20/// of transforming a scene into an image.
21///
22/// This process is modeled as a series of steps, each governed by the physical
23/// properties of real world cameras.
24///
25/// 1. The position and orientation of the camera
26///
27/// See: MDLObject transform property
28///
29/// The MDLTransformComponent on an MDLCamera is an MDLTransform.
30///
31/// 2. Visible Objects and Lights
32///
33/// visible object
34///
35/// visible object
36///
37/// Those objects existing between nearVisibilityDistance and farVisibilityDistance
38/// are considered to be visible. All lights are considered, irrespective of
39/// nearVisibilityDistance and farVisibilityDistance, to compute scene luminance.
40///
41///
42/// Some calculations, such as the calculation of stereo view matrices, require
43/// calculations to occur in world space. Significant quantities measured in mm
44/// therefore use this conversion scale to perform the calculation. The default
45/// value is 1.0.
46///
47/// 3. Scene Luminance through the lens
48///
49///
50///
51/// Illuminated objects result in scene luminance, which passes through the lens.
52/// All lenses impose some amount of radial distortion which can be computed from
53/// focal length. However, some lenses introduce error, and radial distortion can
54/// be used as an aesthetic control as well. Therefore radial distortion is
55/// provided as a property. If r is the radial distance of a pixel from the center
56/// of the projection, then radial distortion is computed as
57///
58/// r' = r * (1 + barrelDistorion * r^2 + fisheyeDistortion * r^4)
59///
60/// radialDistortion sufficiently describes the distortion characteristic of most
61/// lenses. In order to simulate certain other lenses, such as those found in
62/// security cameras, fisheye lenses, plastic toy lenses, sport cameras, or some
63/// VR headsets, radialDistortion2 is introduced.
64///
65/// The default for the radial distortion parameters is zero, resulting in a
66/// rectilinear projection.
67///
68///
69/// Optical vignetting occurs to some degree in all lenses. It results from light
70/// at the edge of an image being blocked as it travels past the lens hood and
71/// the internal lens apertures. It is more prevalent with wide apertures. A
72/// value of zero indicates no optical vignetting is occuring, and a value of one
73/// indicates that vignetting affects all locations in the image according to
74/// radial distance. Optical vignetting also occurs in head mounted displays, and
75/// the value here can be used as an intended amount of vignetting to apply to an
76/// image.
77///
78///
79/// Chromatic aberration occurs to some degree in all lenses. It results from a
80/// lens bringing different wavelengths of light to focus at different places on
81/// the image plane. A value of zero indicates no chromatic aberration is
82/// occurring, and one indicates maximum. Chromatic aberration affects all
83/// locations in the image according to radial distance. Chromatic aberration
84/// also occurs in head mounted displays, and the value here can be used as an
85/// intended amount of chromatic aberration to apply to an image.
86///
87/// 4. Geometry of the lens
88///
89/// This is a thin lens model.
90///
91///
92/// The default focal length is 50mm, corresponding to a field of view of 54
93/// degrees, and vertical sensor aperture of 24mm. Changing focalLength will
94/// update the field of view property.
95///
96///
97/// The distance, in meters, at which the lens is focused. The default is 2.5m.
98///
99///
100/// The field of view is calculated from the focal length and sensor aperture.
101/// Changing the field of view will update the focalLength property with respect
102/// to the sensor aperture. The default is 54 degrees, corresponding to a focal
103/// length of 50mm, and a vertical sensor aperture of 24mm.
104///
105///
106/// The f-stop is the ratio of the lens' focal length to the diameter of the
107/// entrance pupil. The default is 5.6. It controls the amount of light that
108/// reaches the sensor, as well as the size of out of focus parts of the image.
109/// The diameter of the entrance pupil, is therefore obtained
110/// by dividing the fStop by the focalLength.
111///
112/// 5. Lens exit aperture
113///
114///
115/// The shape of out of focus highlights in a scene is commonly known as "bokeh".
116/// The aesthetic quality of a lens' bokeh is one of the characteristics that
117/// drives the choice of a lens for a particular scene. To a large degree, the
118/// appearance of bokeh is governed by the shape of the lens aperture. Typical
119/// lens apertures are controlled by a series of overlapping blades that can be
120/// irised open and closed. A lens with a five blade aperture will yield a five
121/// sided bokeh. The default is zero, which is to be interpreted as a perfectly
122/// round aperture.
123///
124/// Note that the effect of a filter on the front of the lens can be modeled
125/// equivalently at the exit aperture. The MIOCamera does not explicitly provide
126/// specification of such effects, but a simulation could incorporate them at
127/// this stage.
128///
129///
130/// Although the size of an out of focus bokeh highlight can be computed from
131/// other camera properties, it is often necessary to limit the size of the
132/// circle of confusion for aesthetic reasons. The circle of confusion is
133/// specified in mm, and the default is 0.05mm. The units are mm on the sensor
134/// plane.
135///
136///
137/// The length of time in seconds the shutter is open, impacting the amount of
138/// light that reaches the sensor and also the length of motion blur trails. The
139/// shutter time is not the same thing as scene frame rate. The rule of thumb for
140/// movies is that the shutter time should be half the frame rate, so to achieve
141/// a "filmic" look, the shutter time choice might be 1/48 of a second, since
142/// films are usually projected at 24 frames per second. Shutter time is
143/// independent of simulation frame rate because motion blur trails and exposure
144/// times should be held constant in order to avoid flicker artifacts.
145///
146/// 6. Sensor illuminance
147///
148///
149/// The default aperture is 24mm, corresponding to a 35mm stills camera.
150/// _____________________
151/// [][][][][][][][][][][              ^
152/// \
153/// |         |
154/// \
155/// ^       |
156/// \
157/// |         |
158/// \
159/// 24mm   35mm
160/// \
161/// |         |
162/// \
163/// v       |
164/// ][][][][][][][][][][]           v
165/// ---------------------
166/// <
167/// - 36mm -->
168///
169/// Changing the aperture will update the field of view property with respect to
170/// the focal length. The horizontal aperture can be calculated from the aspect
171/// property.
172///
173///
174/// aspect ratio of width versus height of the sensor aperture. The default is
175/// 36mm/24mm, ie: 1.5.
176///
177///
178/// The sensor enlargment property scales the active region of the sensor. A
179/// zoom factor of 2 will result in the central portion of the image being
180/// cropped and expanded to fill the image plane. The default is 1.
181///
182///
183/// The sensor shift property moves the center of the sensor relative to the
184/// lens. This is useful in certain calculations, such as shadow or reflection
185/// projections, as well as to provide vergence in a parallel stereoscopic camera.
186///
187/// 7. Exposure
188///
189/// Finally, the sensor values need to be converted for display.
190///
191///
192/// Flashing is applied to a film stock some time before processing. It is a
193/// small and even level of exposure added to the entire image intended shift
194/// the brightness and color of darker areas of the image. Since exposure is
195/// logarithmic, flash does not affect midtones or highlights.
196///
197/// The equivalent to flash in a color grading system is known as lift. Typically
198/// red, green, and blue can be controlled independently.
199///
200/// A negative value for flash can be used to subtract color.
201///
202///
203/// Finally, exposure should be applied to the compressed value. Red,
204/// green, and blue exposure can be specified separately. The default is 1.0.
205///
206///
207/// Gamma curve compression where values below the x value are to be passed through,
208/// about the y value, values are to be clamped at maximum display brightness,
209/// and a function such as a logarithmic ramp is to be applied in between. The
210/// default is (1,0, 1.0).
211///
212/// A displayable value is therefore obtained via
213/// pow(exposureCompression((sensor value + flash) * exposure), displayGamma)
214///
215/// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlcameraprojection?language=objc)
216// NS_ENUM
217#[repr(transparent)]
218#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
219pub struct MDLCameraProjection(pub NSUInteger);
220impl MDLCameraProjection {
221    #[doc(alias = "MDLCameraProjectionPerspective")]
222    pub const Perspective: Self = Self(0);
223    #[doc(alias = "MDLCameraProjectionOrthographic")]
224    pub const Orthographic: Self = Self(1);
225}
226
227unsafe impl Encode for MDLCameraProjection {
228    const ENCODING: Encoding = NSUInteger::ENCODING;
229}
230
231unsafe impl RefEncode for MDLCameraProjection {
232    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
233}
234
235extern_class!(
236    /// [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlcamera?language=objc)
237    #[unsafe(super(MDLObject, NSObject))]
238    #[derive(Debug, PartialEq, Eq, Hash)]
239    #[cfg(feature = "MDLObject")]
240    pub struct MDLCamera;
241);
242
243#[cfg(all(feature = "MDLObject", feature = "MDLTypes"))]
244unsafe impl MDLNamed for MDLCamera {}
245
246#[cfg(feature = "MDLObject")]
247unsafe impl NSObjectProtocol for MDLCamera {}
248
249#[cfg(feature = "MDLObject")]
250impl MDLCamera {
251    extern_methods!(
252        #[unsafe(method(projection))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn projection(&self) -> MDLCameraProjection;
255
256        /// Setter for [`projection`][Self::projection].
257        #[unsafe(method(setProjection:))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn setProjection(&self, projection: MDLCameraProjection);
260
261        /// Bounding distance for visible objects
262        #[unsafe(method(nearVisibilityDistance))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn nearVisibilityDistance(&self) -> c_float;
265
266        /// Setter for [`nearVisibilityDistance`][Self::nearVisibilityDistance].
267        #[unsafe(method(setNearVisibilityDistance:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn setNearVisibilityDistance(&self, near_visibility_distance: c_float);
270
271        #[unsafe(method(farVisibilityDistance))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn farVisibilityDistance(&self) -> c_float;
274
275        /// Setter for [`farVisibilityDistance`][Self::farVisibilityDistance].
276        #[unsafe(method(setFarVisibilityDistance:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn setFarVisibilityDistance(&self, far_visibility_distance: c_float);
279
280        /// World to meters conversion scale. Required for certain calculations.
281        #[unsafe(method(worldToMetersConversionScale))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn worldToMetersConversionScale(&self) -> c_float;
284
285        /// Setter for [`worldToMetersConversionScale`][Self::worldToMetersConversionScale].
286        #[unsafe(method(setWorldToMetersConversionScale:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn setWorldToMetersConversionScale(
289            &self,
290            world_to_meters_conversion_scale: c_float,
291        );
292
293        /// Radial distortion of the lens, second order term
294        #[unsafe(method(barrelDistortion))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn barrelDistortion(&self) -> c_float;
297
298        /// Setter for [`barrelDistortion`][Self::barrelDistortion].
299        #[unsafe(method(setBarrelDistortion:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn setBarrelDistortion(&self, barrel_distortion: c_float);
302
303        /// Radial distortion of the lens, fourth order term
304        #[unsafe(method(fisheyeDistortion))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn fisheyeDistortion(&self) -> c_float;
307
308        /// Setter for [`fisheyeDistortion`][Self::fisheyeDistortion].
309        #[unsafe(method(setFisheyeDistortion:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn setFisheyeDistortion(&self, fisheye_distortion: c_float);
312
313        /// Amount of optical vignetting, rom zero to one.
314        #[unsafe(method(opticalVignetting))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn opticalVignetting(&self) -> c_float;
317
318        /// Setter for [`opticalVignetting`][Self::opticalVignetting].
319        #[unsafe(method(setOpticalVignetting:))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn setOpticalVignetting(&self, optical_vignetting: c_float);
322
323        /// Amount of chromatic abberation, from zero to one.
324        #[unsafe(method(chromaticAberration))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn chromaticAberration(&self) -> c_float;
327
328        /// Setter for [`chromaticAberration`][Self::chromaticAberration].
329        #[unsafe(method(setChromaticAberration:))]
330        #[unsafe(method_family = none)]
331        pub unsafe fn setChromaticAberration(&self, chromatic_aberration: c_float);
332
333        /// Lens focal length in mm.
334        ///
335        /// See: fieldOfView
336        #[unsafe(method(focalLength))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn focalLength(&self) -> c_float;
339
340        /// Setter for [`focalLength`][Self::focalLength].
341        #[unsafe(method(setFocalLength:))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn setFocalLength(&self, focal_length: c_float);
344
345        /// Focus distance
346        #[unsafe(method(focusDistance))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn focusDistance(&self) -> c_float;
349
350        /// Setter for [`focusDistance`][Self::focusDistance].
351        #[unsafe(method(setFocusDistance:))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn setFocusDistance(&self, focus_distance: c_float);
354
355        /// The field of view, in degrees.
356        ///
357        /// See: focalLength
358        #[unsafe(method(fieldOfView))]
359        #[unsafe(method_family = none)]
360        pub unsafe fn fieldOfView(&self) -> c_float;
361
362        /// Setter for [`fieldOfView`][Self::fieldOfView].
363        #[unsafe(method(setFieldOfView:))]
364        #[unsafe(method_family = none)]
365        pub unsafe fn setFieldOfView(&self, field_of_view: c_float);
366
367        /// f-stop, default is 5.6
368        #[unsafe(method(fStop))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn fStop(&self) -> c_float;
371
372        /// Setter for [`fStop`][Self::fStop].
373        #[unsafe(method(setFStop:))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn setFStop(&self, f_stop: c_float);
376
377        /// Aperture blade count, where zero indicates a circle.
378        #[unsafe(method(apertureBladeCount))]
379        #[unsafe(method_family = none)]
380        pub unsafe fn apertureBladeCount(&self) -> NSUInteger;
381
382        /// Setter for [`apertureBladeCount`][Self::apertureBladeCount].
383        #[unsafe(method(setApertureBladeCount:))]
384        #[unsafe(method_family = none)]
385        pub unsafe fn setApertureBladeCount(&self, aperture_blade_count: NSUInteger);
386
387        /// Maximum circle of confusion size in mm on the image plane
388        #[unsafe(method(maximumCircleOfConfusion))]
389        #[unsafe(method_family = none)]
390        pub unsafe fn maximumCircleOfConfusion(&self) -> c_float;
391
392        /// Setter for [`maximumCircleOfConfusion`][Self::maximumCircleOfConfusion].
393        #[unsafe(method(setMaximumCircleOfConfusion:))]
394        #[unsafe(method_family = none)]
395        pub unsafe fn setMaximumCircleOfConfusion(&self, maximum_circle_of_confusion: c_float);
396
397        /// Shutter open interval, in seconds
398        #[unsafe(method(shutterOpenInterval))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn shutterOpenInterval(&self) -> NSTimeInterval;
401
402        /// Setter for [`shutterOpenInterval`][Self::shutterOpenInterval].
403        #[unsafe(method(setShutterOpenInterval:))]
404        #[unsafe(method_family = none)]
405        pub unsafe fn setShutterOpenInterval(&self, shutter_open_interval: NSTimeInterval);
406
407        /// vertical aperture of the sensor or film gate, default is 24mm
408        ///
409        /// See: sensorAspect
410        #[unsafe(method(sensorVerticalAperture))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn sensorVerticalAperture(&self) -> c_float;
413
414        /// Setter for [`sensorVerticalAperture`][Self::sensorVerticalAperture].
415        #[unsafe(method(setSensorVerticalAperture:))]
416        #[unsafe(method_family = none)]
417        pub unsafe fn setSensorVerticalAperture(&self, sensor_vertical_aperture: c_float);
418
419        /// Sensor or film gate aperture aspect ratio, default is 1.5
420        ///
421        /// See: sensorVerticalAperture
422        #[unsafe(method(sensorAspect))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn sensorAspect(&self) -> c_float;
425
426        /// Setter for [`sensorAspect`][Self::sensorAspect].
427        #[unsafe(method(setSensorAspect:))]
428        #[unsafe(method_family = none)]
429        pub unsafe fn setSensorAspect(&self, sensor_aspect: c_float);
430    );
431}
432
433/// Methods declared on superclass `NSObject`.
434#[cfg(feature = "MDLObject")]
435impl MDLCamera {
436    extern_methods!(
437        #[unsafe(method(init))]
438        #[unsafe(method_family = init)]
439        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
440
441        #[unsafe(method(new))]
442        #[unsafe(method_family = new)]
443        pub unsafe fn new() -> Retained<Self>;
444    );
445}
446
447extern_class!(
448    /// [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlstereoscopiccamera?language=objc)
449    #[unsafe(super(MDLCamera, MDLObject, NSObject))]
450    #[derive(Debug, PartialEq, Eq, Hash)]
451    #[cfg(feature = "MDLObject")]
452    pub struct MDLStereoscopicCamera;
453);
454
455#[cfg(all(feature = "MDLObject", feature = "MDLTypes"))]
456unsafe impl MDLNamed for MDLStereoscopicCamera {}
457
458#[cfg(feature = "MDLObject")]
459unsafe impl NSObjectProtocol for MDLStereoscopicCamera {}
460
461#[cfg(feature = "MDLObject")]
462impl MDLStereoscopicCamera {
463    extern_methods!(
464        /// Inter-pupillary distance in mm.
465        /// Default is 63mm.
466        #[unsafe(method(interPupillaryDistance))]
467        #[unsafe(method_family = none)]
468        pub unsafe fn interPupillaryDistance(&self) -> c_float;
469
470        /// Setter for [`interPupillaryDistance`][Self::interPupillaryDistance].
471        #[unsafe(method(setInterPupillaryDistance:))]
472        #[unsafe(method_family = none)]
473        pub unsafe fn setInterPupillaryDistance(&self, inter_pupillary_distance: c_float);
474
475        /// Vergence in a stereoscopic camera can be controlled in two ways. A toed-in
476        /// binocular stereoscopic camera rotates the lens and sensor together such that a
477        /// ray projected from the center of either sensor and lens meets at a point. A
478        /// parallel binocular stereoscopic camera accomplishes the same thing by shifting
479        /// the relative centers of the sensor and lens.
480        ///
481        /// If a parallel binocular stereoscopic camera is modeled, the sensor should be
482        /// considered to have shifted by an amount h. If left and right vergence are equal,
483        /// h = (focal length * interOcularDistance) / distance to vergence point.
484        ///
485        /// Vergence is measured in degrees towards center and is usually positive.
486        #[unsafe(method(leftVergence))]
487        #[unsafe(method_family = none)]
488        pub unsafe fn leftVergence(&self) -> c_float;
489
490        /// Setter for [`leftVergence`][Self::leftVergence].
491        #[unsafe(method(setLeftVergence:))]
492        #[unsafe(method_family = none)]
493        pub unsafe fn setLeftVergence(&self, left_vergence: c_float);
494
495        #[unsafe(method(rightVergence))]
496        #[unsafe(method_family = none)]
497        pub unsafe fn rightVergence(&self) -> c_float;
498
499        /// Setter for [`rightVergence`][Self::rightVergence].
500        #[unsafe(method(setRightVergence:))]
501        #[unsafe(method_family = none)]
502        pub unsafe fn setRightVergence(&self, right_vergence: c_float);
503
504        /// The amount, as a percentage of image width to offset an image towards the other
505        /// camera. This value is used in a stereo grade to enhance or reduce the intensity
506        /// of the stereoscopic effect
507        #[unsafe(method(overlap))]
508        #[unsafe(method_family = none)]
509        pub unsafe fn overlap(&self) -> c_float;
510
511        /// Setter for [`overlap`][Self::overlap].
512        #[unsafe(method(setOverlap:))]
513        #[unsafe(method_family = none)]
514        pub unsafe fn setOverlap(&self, overlap: c_float);
515    );
516}
517
518/// Methods declared on superclass `NSObject`.
519#[cfg(feature = "MDLObject")]
520impl MDLStereoscopicCamera {
521    extern_methods!(
522        #[unsafe(method(init))]
523        #[unsafe(method_family = init)]
524        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
525
526        #[unsafe(method(new))]
527        #[unsafe(method_family = new)]
528        pub unsafe fn new() -> Retained<Self>;
529    );
530}