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
//! 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::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/modelio/mdllighttype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MDLLightType(pub NSUInteger);
impl MDLLightType {
    #[doc(alias = "MDLLightTypeUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "MDLLightTypeAmbient")]
    pub const Ambient: Self = Self(1);
    #[doc(alias = "MDLLightTypeDirectional")]
    pub const Directional: Self = Self(2);
    #[doc(alias = "MDLLightTypeSpot")]
    pub const Spot: Self = Self(3);
    #[doc(alias = "MDLLightTypePoint")]
    pub const Point: Self = Self(4);
    #[doc(alias = "MDLLightTypeLinear")]
    pub const Linear: Self = Self(5);
    #[doc(alias = "MDLLightTypeDiscArea")]
    pub const DiscArea: Self = Self(6);
    #[doc(alias = "MDLLightTypeRectangularArea")]
    pub const RectangularArea: Self = Self(7);
    #[doc(alias = "MDLLightTypeSuperElliptical")]
    pub const SuperElliptical: Self = Self(8);
    #[doc(alias = "MDLLightTypePhotometric")]
    pub const Photometric: Self = Self(9);
    #[doc(alias = "MDLLightTypeProbe")]
    pub const Probe: Self = Self(10);
    #[doc(alias = "MDLLightTypeEnvironment")]
    pub const Environment: Self = Self(11);
}

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

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

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

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

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

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

        /// Setter for [`lightType`][Self::lightType].
        #[unsafe(method(setLightType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLightType(&self, light_type: MDLLightType);

        #[unsafe(method(colorSpace))]
        #[unsafe(method_family = none)]
        pub unsafe fn colorSpace(&self) -> Retained<NSString>;

        /// Setter for [`colorSpace`][Self::colorSpace].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setColorSpace:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setColorSpace(&self, color_space: &NSString);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLLight {
    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!(
    /// A light with characteristics representing plausible real world lights
    ///
    ///
    ///
    ///
    ///
    /// quadratically attenuates to zero.
    ///
    /// light is maximally bright.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlphysicallyplausiblelight?language=objc)
    #[unsafe(super(MDLLight, MDLObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "MDLObject")]
    pub struct MDLPhysicallyPlausibleLight;
);

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

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

#[cfg(feature = "MDLObject")]
impl MDLPhysicallyPlausibleLight {
    extern_methods!(
        /// Light color specified by color temperature, in degrees Kelvin
        ///
        /// default color is 6500K, cool daylight.
        #[unsafe(method(setColorByTemperature:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setColorByTemperature(&self, temperature: c_float);

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(color))]
        #[unsafe(method_family = none)]
        pub unsafe fn color(&self) -> Option<Retained<CGColor>>;

        #[cfg(feature = "objc2-core-graphics")]
        /// Setter for [`color`][Self::color].
        #[unsafe(method(setColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setColor(&self, color: Option<&CGColor>);

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

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

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

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

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

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

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

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

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

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

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLPhysicallyPlausibleLight {
    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/mdlarealight?language=objc)
    #[unsafe(super(MDLPhysicallyPlausibleLight, MDLLight, MDLObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "MDLObject")]
    pub struct MDLAreaLight;
);

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

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

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

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

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

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

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLAreaLight {
    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!(
    /// A light created from measurements at various angles.
    ///
    ///
    /// learn the intensity of the light in that direction.
    ///
    /// used to calculate the spherical harmonics coefficients
    ///
    /// calculated by generateSphericalHarmonicsFromLight:
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlphotometriclight?language=objc)
    #[unsafe(super(MDLPhysicallyPlausibleLight, MDLLight, MDLObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "MDLObject")]
    pub struct MDLPhotometricLight;
);

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

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

#[cfg(feature = "MDLObject")]
impl MDLPhotometricLight {
    extern_methods!(
        #[unsafe(method(initWithIESProfile:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIESProfile(
            this: Allocated<Self>,
            url: &NSURL,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(generateSphericalHarmonicsFromLight:))]
        #[unsafe(method_family = none)]
        pub unsafe fn generateSphericalHarmonicsFromLight(
            &self,
            spherical_harmonics_level: NSUInteger,
        );

        #[unsafe(method(generateCubemapFromLight:))]
        #[unsafe(method_family = none)]
        pub unsafe fn generateCubemapFromLight(&self, texture_size: NSUInteger);

        #[cfg(feature = "MDLTexture")]
        /// Generate an IES compliant MDLTexture
        /// 1D when the number of horizontal angles is one and the innerConeAngle is
        /// <
        /// 180
        /// 2D when the previous statement fails and innerConeAngle
        /// <
        /// 89
        /// 3D in all other cases
        /// the parameter textureSize is the size in pixels of the texture image. For a size of N,
        /// 1D generates an Nx1 image, 2D generates an NxN image, 3D generates an Nx(N*6) image (i.e. cubemap).
        #[unsafe(method(generateTexture:))]
        #[unsafe(method_family = none)]
        pub unsafe fn generateTexture(&self, texture_size: NSUInteger) -> Retained<MDLTexture>;

        #[cfg(feature = "MDLTexture")]
        #[unsafe(method(lightCubeMap))]
        #[unsafe(method_family = none)]
        pub unsafe fn lightCubeMap(&self) -> Option<Retained<MDLTexture>>;

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

        #[unsafe(method(sphericalHarmonicsCoefficients))]
        #[unsafe(method_family = none)]
        pub unsafe fn sphericalHarmonicsCoefficients(&self) -> Option<Retained<NSData>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLPhotometricLight {
    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/mdllightprobe?language=objc)
    #[unsafe(super(MDLLight, MDLObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "MDLObject")]
    pub struct MDLLightProbe;
);

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

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

#[cfg(feature = "MDLObject")]
impl MDLLightProbe {
    extern_methods!(
        #[cfg(feature = "MDLTexture")]
        #[unsafe(method(initWithReflectiveTexture:irradianceTexture:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithReflectiveTexture_irradianceTexture(
            this: Allocated<Self>,
            reflective_texture: Option<&MDLTexture>,
            irradiance_texture: Option<&MDLTexture>,
        ) -> Retained<Self>;

        #[unsafe(method(generateSphericalHarmonicsFromIrradiance:))]
        #[unsafe(method_family = none)]
        pub unsafe fn generateSphericalHarmonicsFromIrradiance(
            &self,
            spherical_harmonics_level: NSUInteger,
        );

        #[cfg(feature = "MDLTexture")]
        #[unsafe(method(reflectiveTexture))]
        #[unsafe(method_family = none)]
        pub unsafe fn reflectiveTexture(&self) -> Option<Retained<MDLTexture>>;

        #[cfg(feature = "MDLTexture")]
        #[unsafe(method(irradianceTexture))]
        #[unsafe(method_family = none)]
        pub unsafe fn irradianceTexture(&self) -> Option<Retained<MDLTexture>>;

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

        #[unsafe(method(sphericalHarmonicsCoefficients))]
        #[unsafe(method_family = none)]
        pub unsafe fn sphericalHarmonicsCoefficients(&self) -> Option<Retained<NSData>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLLightProbe {
    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>;
    );
}

/// MDLLightBaking.
#[cfg(feature = "MDLObject")]
impl MDLLightProbe {
    extern_methods!(
        #[cfg(all(feature = "MDLTexture", feature = "MDLTransform"))]
        #[unsafe(method(lightProbeWithTextureSize:forLocation:lightsToConsider:objectsToConsider:reflectiveCubemap:irradianceCubemap:))]
        #[unsafe(method_family = none)]
        pub unsafe fn lightProbeWithTextureSize_forLocation_lightsToConsider_objectsToConsider_reflectiveCubemap_irradianceCubemap(
            texture_size: NSInteger,
            transform: &MDLTransform,
            lights_to_consider: &NSArray<MDLLight>,
            objects_to_consider: &NSArray<MDLObject>,
            reflective_cubemap: Option<&MDLTexture>,
            irradiance_cubemap: Option<&MDLTexture>,
        ) -> Option<Retained<MDLLightProbe>>;
    );
}