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"))]
244extern_conformance!(
245 unsafe impl MDLNamed for MDLCamera {}
246);
247
248#[cfg(feature = "MDLObject")]
249extern_conformance!(
250 unsafe impl NSObjectProtocol for MDLCamera {}
251);
252
253#[cfg(feature = "MDLObject")]
254impl MDLCamera {
255 extern_methods!(
256 #[unsafe(method(projection))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn projection(&self) -> MDLCameraProjection;
259
260 /// Setter for [`projection`][Self::projection].
261 #[unsafe(method(setProjection:))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn setProjection(&self, projection: MDLCameraProjection);
264
265 /// Bounding distance for visible objects
266 #[unsafe(method(nearVisibilityDistance))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn nearVisibilityDistance(&self) -> c_float;
269
270 /// Setter for [`nearVisibilityDistance`][Self::nearVisibilityDistance].
271 #[unsafe(method(setNearVisibilityDistance:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn setNearVisibilityDistance(&self, near_visibility_distance: c_float);
274
275 #[unsafe(method(farVisibilityDistance))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn farVisibilityDistance(&self) -> c_float;
278
279 /// Setter for [`farVisibilityDistance`][Self::farVisibilityDistance].
280 #[unsafe(method(setFarVisibilityDistance:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn setFarVisibilityDistance(&self, far_visibility_distance: c_float);
283
284 /// World to meters conversion scale. Required for certain calculations.
285 #[unsafe(method(worldToMetersConversionScale))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn worldToMetersConversionScale(&self) -> c_float;
288
289 /// Setter for [`worldToMetersConversionScale`][Self::worldToMetersConversionScale].
290 #[unsafe(method(setWorldToMetersConversionScale:))]
291 #[unsafe(method_family = none)]
292 pub unsafe fn setWorldToMetersConversionScale(
293 &self,
294 world_to_meters_conversion_scale: c_float,
295 );
296
297 /// Radial distortion of the lens, second order term
298 #[unsafe(method(barrelDistortion))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn barrelDistortion(&self) -> c_float;
301
302 /// Setter for [`barrelDistortion`][Self::barrelDistortion].
303 #[unsafe(method(setBarrelDistortion:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn setBarrelDistortion(&self, barrel_distortion: c_float);
306
307 /// Radial distortion of the lens, fourth order term
308 #[unsafe(method(fisheyeDistortion))]
309 #[unsafe(method_family = none)]
310 pub unsafe fn fisheyeDistortion(&self) -> c_float;
311
312 /// Setter for [`fisheyeDistortion`][Self::fisheyeDistortion].
313 #[unsafe(method(setFisheyeDistortion:))]
314 #[unsafe(method_family = none)]
315 pub unsafe fn setFisheyeDistortion(&self, fisheye_distortion: c_float);
316
317 /// Amount of optical vignetting, rom zero to one.
318 #[unsafe(method(opticalVignetting))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn opticalVignetting(&self) -> c_float;
321
322 /// Setter for [`opticalVignetting`][Self::opticalVignetting].
323 #[unsafe(method(setOpticalVignetting:))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn setOpticalVignetting(&self, optical_vignetting: c_float);
326
327 /// Amount of chromatic abberation, from zero to one.
328 #[unsafe(method(chromaticAberration))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn chromaticAberration(&self) -> c_float;
331
332 /// Setter for [`chromaticAberration`][Self::chromaticAberration].
333 #[unsafe(method(setChromaticAberration:))]
334 #[unsafe(method_family = none)]
335 pub unsafe fn setChromaticAberration(&self, chromatic_aberration: c_float);
336
337 /// Lens focal length in mm.
338 ///
339 /// See: fieldOfView
340 #[unsafe(method(focalLength))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn focalLength(&self) -> c_float;
343
344 /// Setter for [`focalLength`][Self::focalLength].
345 #[unsafe(method(setFocalLength:))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn setFocalLength(&self, focal_length: c_float);
348
349 /// Focus distance
350 #[unsafe(method(focusDistance))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn focusDistance(&self) -> c_float;
353
354 /// Setter for [`focusDistance`][Self::focusDistance].
355 #[unsafe(method(setFocusDistance:))]
356 #[unsafe(method_family = none)]
357 pub unsafe fn setFocusDistance(&self, focus_distance: c_float);
358
359 /// The field of view, in degrees.
360 ///
361 /// See: focalLength
362 #[unsafe(method(fieldOfView))]
363 #[unsafe(method_family = none)]
364 pub unsafe fn fieldOfView(&self) -> c_float;
365
366 /// Setter for [`fieldOfView`][Self::fieldOfView].
367 #[unsafe(method(setFieldOfView:))]
368 #[unsafe(method_family = none)]
369 pub unsafe fn setFieldOfView(&self, field_of_view: c_float);
370
371 /// f-stop, default is 5.6
372 #[unsafe(method(fStop))]
373 #[unsafe(method_family = none)]
374 pub unsafe fn fStop(&self) -> c_float;
375
376 /// Setter for [`fStop`][Self::fStop].
377 #[unsafe(method(setFStop:))]
378 #[unsafe(method_family = none)]
379 pub unsafe fn setFStop(&self, f_stop: c_float);
380
381 /// Aperture blade count, where zero indicates a circle.
382 #[unsafe(method(apertureBladeCount))]
383 #[unsafe(method_family = none)]
384 pub unsafe fn apertureBladeCount(&self) -> NSUInteger;
385
386 /// Setter for [`apertureBladeCount`][Self::apertureBladeCount].
387 #[unsafe(method(setApertureBladeCount:))]
388 #[unsafe(method_family = none)]
389 pub unsafe fn setApertureBladeCount(&self, aperture_blade_count: NSUInteger);
390
391 /// Maximum circle of confusion size in mm on the image plane
392 #[unsafe(method(maximumCircleOfConfusion))]
393 #[unsafe(method_family = none)]
394 pub unsafe fn maximumCircleOfConfusion(&self) -> c_float;
395
396 /// Setter for [`maximumCircleOfConfusion`][Self::maximumCircleOfConfusion].
397 #[unsafe(method(setMaximumCircleOfConfusion:))]
398 #[unsafe(method_family = none)]
399 pub unsafe fn setMaximumCircleOfConfusion(&self, maximum_circle_of_confusion: c_float);
400
401 /// Shutter open interval, in seconds
402 #[unsafe(method(shutterOpenInterval))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn shutterOpenInterval(&self) -> NSTimeInterval;
405
406 /// Setter for [`shutterOpenInterval`][Self::shutterOpenInterval].
407 #[unsafe(method(setShutterOpenInterval:))]
408 #[unsafe(method_family = none)]
409 pub unsafe fn setShutterOpenInterval(&self, shutter_open_interval: NSTimeInterval);
410
411 /// vertical aperture of the sensor or film gate, default is 24mm
412 ///
413 /// See: sensorAspect
414 #[unsafe(method(sensorVerticalAperture))]
415 #[unsafe(method_family = none)]
416 pub unsafe fn sensorVerticalAperture(&self) -> c_float;
417
418 /// Setter for [`sensorVerticalAperture`][Self::sensorVerticalAperture].
419 #[unsafe(method(setSensorVerticalAperture:))]
420 #[unsafe(method_family = none)]
421 pub unsafe fn setSensorVerticalAperture(&self, sensor_vertical_aperture: c_float);
422
423 /// Sensor or film gate aperture aspect ratio, default is 1.5
424 ///
425 /// See: sensorVerticalAperture
426 #[unsafe(method(sensorAspect))]
427 #[unsafe(method_family = none)]
428 pub unsafe fn sensorAspect(&self) -> c_float;
429
430 /// Setter for [`sensorAspect`][Self::sensorAspect].
431 #[unsafe(method(setSensorAspect:))]
432 #[unsafe(method_family = none)]
433 pub unsafe fn setSensorAspect(&self, sensor_aspect: c_float);
434 );
435}
436
437/// Methods declared on superclass `NSObject`.
438#[cfg(feature = "MDLObject")]
439impl MDLCamera {
440 extern_methods!(
441 #[unsafe(method(init))]
442 #[unsafe(method_family = init)]
443 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
444
445 #[unsafe(method(new))]
446 #[unsafe(method_family = new)]
447 pub unsafe fn new() -> Retained<Self>;
448 );
449}
450
451extern_class!(
452 /// [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlstereoscopiccamera?language=objc)
453 #[unsafe(super(MDLCamera, MDLObject, NSObject))]
454 #[derive(Debug, PartialEq, Eq, Hash)]
455 #[cfg(feature = "MDLObject")]
456 pub struct MDLStereoscopicCamera;
457);
458
459#[cfg(all(feature = "MDLObject", feature = "MDLTypes"))]
460extern_conformance!(
461 unsafe impl MDLNamed for MDLStereoscopicCamera {}
462);
463
464#[cfg(feature = "MDLObject")]
465extern_conformance!(
466 unsafe impl NSObjectProtocol for MDLStereoscopicCamera {}
467);
468
469#[cfg(feature = "MDLObject")]
470impl MDLStereoscopicCamera {
471 extern_methods!(
472 /// Inter-pupillary distance in mm.
473 /// Default is 63mm.
474 #[unsafe(method(interPupillaryDistance))]
475 #[unsafe(method_family = none)]
476 pub unsafe fn interPupillaryDistance(&self) -> c_float;
477
478 /// Setter for [`interPupillaryDistance`][Self::interPupillaryDistance].
479 #[unsafe(method(setInterPupillaryDistance:))]
480 #[unsafe(method_family = none)]
481 pub unsafe fn setInterPupillaryDistance(&self, inter_pupillary_distance: c_float);
482
483 /// Vergence in a stereoscopic camera can be controlled in two ways. A toed-in
484 /// binocular stereoscopic camera rotates the lens and sensor together such that a
485 /// ray projected from the center of either sensor and lens meets at a point. A
486 /// parallel binocular stereoscopic camera accomplishes the same thing by shifting
487 /// the relative centers of the sensor and lens.
488 ///
489 /// If a parallel binocular stereoscopic camera is modeled, the sensor should be
490 /// considered to have shifted by an amount h. If left and right vergence are equal,
491 /// h = (focal length * interOcularDistance) / distance to vergence point.
492 ///
493 /// Vergence is measured in degrees towards center and is usually positive.
494 #[unsafe(method(leftVergence))]
495 #[unsafe(method_family = none)]
496 pub unsafe fn leftVergence(&self) -> c_float;
497
498 /// Setter for [`leftVergence`][Self::leftVergence].
499 #[unsafe(method(setLeftVergence:))]
500 #[unsafe(method_family = none)]
501 pub unsafe fn setLeftVergence(&self, left_vergence: c_float);
502
503 #[unsafe(method(rightVergence))]
504 #[unsafe(method_family = none)]
505 pub unsafe fn rightVergence(&self) -> c_float;
506
507 /// Setter for [`rightVergence`][Self::rightVergence].
508 #[unsafe(method(setRightVergence:))]
509 #[unsafe(method_family = none)]
510 pub unsafe fn setRightVergence(&self, right_vergence: c_float);
511
512 /// The amount, as a percentage of image width to offset an image towards the other
513 /// camera. This value is used in a stereo grade to enhance or reduce the intensity
514 /// of the stereoscopic effect
515 #[unsafe(method(overlap))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn overlap(&self) -> c_float;
518
519 /// Setter for [`overlap`][Self::overlap].
520 #[unsafe(method(setOverlap:))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn setOverlap(&self, overlap: c_float);
523 );
524}
525
526/// Methods declared on superclass `NSObject`.
527#[cfg(feature = "MDLObject")]
528impl MDLStereoscopicCamera {
529 extern_methods!(
530 #[unsafe(method(init))]
531 #[unsafe(method_family = init)]
532 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
533
534 #[unsafe(method(new))]
535 #[unsafe(method_family = new)]
536 pub unsafe fn new() -> Retained<Self>;
537 );
538}