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
//! 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::*;
extern_class!(
/// An MDLAsset represents the contents of a model file.
///
///
/// Each asset contains a collection of hierarchies of objects, where
/// each object in the asset is the top level of a hierarchy. Objects
/// include transforms, lights, cameras, and meshes.
///
/// MDLAssets are typically instantiated from NSURLs that refer to a model resource.
///
/// The model resource may represented timed information, for example, a series of
/// mesh morphs. If the asset is timed, then the framerate will be non-zero, and the
/// firstFrame and lastFrame properties will indicate the range for which sample
/// data exists. Samples before or after that range will be clamped. Some model
/// resource representations allow continuous sampling, others are discrete. In the
/// discrete case, if a requested sample time is not on a discrete boundary the
/// returned sample will be the sample exactly on the sample time, or if no such is
/// available, the immediately preceding sample. If no time is specified for a
/// sample, the first data will be returned.
///
/// An asset's bounding box can be queried without traversing the hierarchy of
/// objects.
///
/// Fast enumeration of an MDLAsset iterates the top level objects contained within.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlasset?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MDLAsset;
);
extern_conformance!(
unsafe impl NSCopying for MDLAsset {}
);
unsafe impl CopyingHelper for MDLAsset {
type Result = Self;
}
extern_conformance!(
unsafe impl NSFastEnumeration for MDLAsset {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for MDLAsset {}
);
impl MDLAsset {
extern_methods!(
/// Initialize an MDLAsset using the contents of the resource located at
/// the indicated URL
///
/// Vertex layout (i.e. vertexDescriptor) will be specified by ModelIO
/// depending on attributes of the resource. Buffers will be allocated
/// using a default NSData based allocator
///
/// Submeshes will be converted to triangle topology.
#[unsafe(method(initWithURL:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
#[cfg(all(feature = "MDLMeshBuffer", feature = "MDLVertexDescriptor"))]
/// Initialize an MDLAsset using the contents of the resource located at
/// URL, ensuring that the asset conforms to the supplied vertexDescriptor,
/// and buffers are allocated in the supplied allocator
///
///
/// The default behavior is to triangulate any discovered meshes and to
/// conform the mesh to the supplied vertexDescriptor.
///
/// If nil is passed as the vertexDescriptor, then a vertexDescriptor
/// will be created according to the attributes of the resource.
///
/// If nil is passed as the bufferAllocator, buffers will be allocated
/// using a default NSData based allocator.
///
/// Submeshes will be converted to triangle topology.
#[unsafe(method(initWithURL:vertexDescriptor:bufferAllocator:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithURL_vertexDescriptor_bufferAllocator(
this: Allocated<Self>,
url: Option<&NSURL>,
vertex_descriptor: Option<&MDLVertexDescriptor>,
buffer_allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
) -> Retained<Self>;
#[cfg(feature = "MDLMeshBuffer")]
/// Initialize an empty MDLAsset with a buffer allocator to be used during
/// other operations.
#[unsafe(method(initWithBufferAllocator:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithBufferAllocator(
this: Allocated<Self>,
buffer_allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
) -> Retained<Self>;
#[cfg(all(feature = "MDLMeshBuffer", feature = "MDLVertexDescriptor"))]
/// Same as initWithURL:vertexDescriptor:bufferAllocator: except that
/// if preserveTopology is YES, a topology buffer might be created on the
/// submeshes.
///
///
/// If all faces in a submesh have the same vertex count, then the
/// submesh will a geometry type corresponding to that vertex count.
/// For example, if all faces have four vertices, then the geometry
/// type will be MDLGeometryTypeQuads. If faces have a varying number
/// of vertices, then the the submesh type will be
/// MDLGeometryTypeVariableTopology, and a faceTopologyBuffer will be
/// created.
#[unsafe(method(initWithURL:vertexDescriptor:bufferAllocator:preserveTopology:error:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithURL_vertexDescriptor_bufferAllocator_preserveTopology_error(
this: Allocated<Self>,
url: &NSURL,
vertex_descriptor: Option<&MDLVertexDescriptor>,
buffer_allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
preserve_topology: bool,
error: Option<&mut Option<Retained<NSError>>>,
) -> Retained<Self>;
/// Export an asset to the specified URL.
///
/// Returns: YES is returned if exporting proceeded successfully,
#[unsafe(method(exportAssetToURL:))]
#[unsafe(method_family = none)]
pub unsafe fn exportAssetToURL(&self, url: &NSURL) -> bool;
/// Export an asset to the specified URL.
///
/// Returns: YES is returned if exporting proceeded successfully,
#[unsafe(method(exportAssetToURL:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn exportAssetToURL_error(&self, url: &NSURL) -> Result<(), Retained<NSError>>;
#[cfg(feature = "MDLObject")]
/// Return the object at the specified path, or nil if none exists there
#[unsafe(method(objectAtPath:))]
#[unsafe(method_family = none)]
pub unsafe fn objectAtPath(&self, path: &NSString) -> Retained<MDLObject>;
/// Indicates whether MDLAsset object can be initialized with resource
/// with the given extension
///
/// Returns: YES is returned if MDLAsset is able to load and represent assets with
/// the given extension
#[unsafe(method(canImportFileExtension:))]
#[unsafe(method_family = none)]
pub unsafe fn canImportFileExtension(extension: &NSString) -> bool;
/// Indicates whether MDLAsset object can export asset to resource with
/// the given extension
///
/// Returns: YES is returned if MDLAsset is able is able to export assets to
/// resources with the given extension
#[unsafe(method(canExportFileExtension:))]
#[unsafe(method_family = none)]
pub unsafe fn canExportFileExtension(extension: &NSString) -> bool;
#[cfg(feature = "MDLObject")]
/// Inspects an asset's hierarchy for objects of the specified class type
///
/// Returns: returns an NSArray of all objects in the asset matching the requested class
///
/// This can be used to get references to all MDLMesh objects, MDLLights,
/// etc. if objectClass is not a subclass of MDLObject, an exception will be
/// raised.
///
/// # Safety
///
/// `object_class` probably has further requirements.
#[unsafe(method(childObjectsOfClass:))]
#[unsafe(method_family = none)]
pub unsafe fn childObjectsOfClass(
&self,
object_class: &AnyClass,
) -> Retained<NSArray<MDLObject>>;
/// Iterates over all material properties on all materials. If they are string
/// values or NSURL values, and can be resolved as textures, then the string
/// and NSURL values will be replaced by MDLTextureSampler values.
#[unsafe(method(loadTextures))]
#[unsafe(method_family = none)]
pub unsafe fn loadTextures(&self);
/// Inherent frame rate of an asset
///
/// If no framerate was specified by resource or resource uncapable of
/// specifying framerate, this value defaults to 0
#[unsafe(method(frameInterval))]
#[unsafe(method_family = none)]
pub unsafe fn frameInterval(&self) -> NSTimeInterval;
/// Setter for [`frameInterval`][Self::frameInterval].
#[unsafe(method(setFrameInterval:))]
#[unsafe(method_family = none)]
pub unsafe fn setFrameInterval(&self, frame_interval: NSTimeInterval);
/// Start time bracket of animation data
///
/// If no animation data was specified by resource or resource incapable
/// of specifying animation data, this value defaults to 0. If startTime
/// was set explicitly, then the value of startTime will be the lesser
/// of the set value and the animated values.
#[unsafe(method(startTime))]
#[unsafe(method_family = none)]
pub unsafe fn startTime(&self) -> NSTimeInterval;
/// Setter for [`startTime`][Self::startTime].
#[unsafe(method(setStartTime:))]
#[unsafe(method_family = none)]
pub unsafe fn setStartTime(&self, start_time: NSTimeInterval);
/// End time bracket of animation data
///
/// If no animation data was specified by resource or resource incapable
/// of specifying animation data, this value defaults to 0. If the
/// endTime was set explicitly, then the value of endTime will be the
/// greater of the set value and the animated values.
#[unsafe(method(endTime))]
#[unsafe(method_family = none)]
pub unsafe fn endTime(&self) -> NSTimeInterval;
/// Setter for [`endTime`][Self::endTime].
#[unsafe(method(setEndTime:))]
#[unsafe(method_family = none)]
pub unsafe fn setEndTime(&self, end_time: NSTimeInterval);
/// URL used to create the asset
///
/// If the asset was not created with a URL, nil will be returned.
#[unsafe(method(URL))]
#[unsafe(method_family = none)]
pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "MDLAssetResolver")]
/// Resolver asset that helps find associated files
///
/// The default asset resolver is the RelativeAssetResolver
#[unsafe(method(resolver))]
#[unsafe(method_family = none)]
pub unsafe fn resolver(&self) -> Option<Retained<ProtocolObject<dyn MDLAssetResolver>>>;
#[cfg(feature = "MDLAssetResolver")]
/// Setter for [`resolver`][Self::resolver].
#[unsafe(method(setResolver:))]
#[unsafe(method_family = none)]
pub unsafe fn setResolver(&self, resolver: Option<&ProtocolObject<dyn MDLAssetResolver>>);
#[cfg(feature = "MDLMeshBuffer")]
/// Allocator used to create vertex and index buffers
#[unsafe(method(bufferAllocator))]
#[unsafe(method_family = none)]
pub unsafe fn bufferAllocator(
&self,
) -> Retained<ProtocolObject<dyn MDLMeshBufferAllocator>>;
#[cfg(feature = "MDLVertexDescriptor")]
/// Vertex descriptor set upon asset initialization
///
/// Will be nil if there was no descriptor set
#[unsafe(method(vertexDescriptor))]
#[unsafe(method_family = none)]
pub unsafe fn vertexDescriptor(&self) -> Option<Retained<MDLVertexDescriptor>>;
#[cfg(feature = "MDLObject")]
/// Add a top level object to an asset.
///
/// If the object was already in the asset, this has no effect.
#[unsafe(method(addObject:))]
#[unsafe(method_family = none)]
pub unsafe fn addObject(&self, object: &MDLObject);
#[cfg(feature = "MDLObject")]
/// Remove a top level object from an asset.
///
/// If the object not in the asset, this has no effect.
#[unsafe(method(removeObject:))]
#[unsafe(method_family = none)]
pub unsafe fn removeObject(&self, object: &MDLObject);
/// The number of top level objects
#[unsafe(method(count))]
#[unsafe(method_family = none)]
pub unsafe fn count(&self) -> NSUInteger;
#[cfg(feature = "MDLObject")]
/// return the indexed top level object
#[unsafe(method(objectAtIndexedSubscript:))]
#[unsafe(method_family = none)]
pub unsafe fn objectAtIndexedSubscript(
&self,
index: NSUInteger,
) -> Option<Retained<MDLObject>>;
#[cfg(feature = "MDLObject")]
/// return the indexed top level object
#[unsafe(method(objectAtIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn objectAtIndex(&self, index: NSUInteger) -> Retained<MDLObject>;
#[cfg(feature = "MDLTypes")]
#[deprecated]
#[unsafe(method(masters))]
#[unsafe(method_family = none)]
pub unsafe fn masters(&self) -> Retained<ProtocolObject<dyn MDLObjectContainerComponent>>;
#[cfg(feature = "MDLTypes")]
/// Setter for [`masters`][Self::masters].
#[deprecated]
#[unsafe(method(setMasters:))]
#[unsafe(method_family = none)]
pub unsafe fn setMasters(&self, masters: &ProtocolObject<dyn MDLObjectContainerComponent>);
#[cfg(feature = "MDLTypes")]
/// Original objects that can be instanced into the asset's object hierarchy
///
/// See: MDLObjectContainerComponent
#[unsafe(method(originals))]
#[unsafe(method_family = none)]
pub unsafe fn originals(&self)
-> Retained<ProtocolObject<dyn MDLObjectContainerComponent>>;
#[cfg(feature = "MDLTypes")]
/// Setter for [`originals`][Self::originals].
#[unsafe(method(setOriginals:))]
#[unsafe(method_family = none)]
pub unsafe fn setOriginals(
&self,
originals: &ProtocolObject<dyn MDLObjectContainerComponent>,
);
#[cfg(feature = "MDLTypes")]
/// Animations that can be bound to MDLObjects (
///
/// See: MDLAnimationBindComponent)
///
/// See: MDLObjectContainerComponent
#[unsafe(method(animations))]
#[unsafe(method_family = none)]
pub unsafe fn animations(
&self,
) -> Retained<ProtocolObject<dyn MDLObjectContainerComponent>>;
#[cfg(feature = "MDLTypes")]
/// Setter for [`animations`][Self::animations].
#[unsafe(method(setAnimations:))]
#[unsafe(method_family = none)]
pub unsafe fn setAnimations(
&self,
animations: &ProtocolObject<dyn MDLObjectContainerComponent>,
);
);
}
/// Methods declared on superclass `NSObject`.
impl MDLAsset {
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_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/modelio/mdllightprobeirradiancedatasource?language=objc)
pub unsafe trait MDLLightProbeIrradianceDataSource: NSObjectProtocol {
/// Spherical harmonics level used to calculate the spherical harmonics coefficients.
#[optional]
#[unsafe(method(sphericalHarmonicsLevel))]
#[unsafe(method_family = none)]
unsafe fn sphericalHarmonicsLevel(&self) -> NSUInteger;
/// Setter for [`sphericalHarmonicsLevel`][Self::sphericalHarmonicsLevel].
#[optional]
#[unsafe(method(setSphericalHarmonicsLevel:))]
#[unsafe(method_family = none)]
unsafe fn setSphericalHarmonicsLevel(&self, spherical_harmonics_level: NSUInteger);
}
);
/// MDLLightBaking.
///
/// Given a light probe density, method places light probes in the scene according to the
/// passed in placement heuristic type. The higher the density, the greater the number of
/// light probes placed in the scene.
///
/// Using the placement heuristic MDLProbePlacementUniformGrid places the light probes in the
/// scene as a uniform grid. The placement heuristic MDLProbePlacementIrradianceDistribution
/// places the light probes in areas of greatest irradiance change.
impl MDLAsset {
extern_methods!(
#[cfg(all(feature = "MDLLight", feature = "MDLObject", feature = "MDLTypes"))]
#[unsafe(method(placeLightProbesWithDensity:heuristic:usingIrradianceDataSource:))]
#[unsafe(method_family = none)]
pub unsafe fn placeLightProbesWithDensity_heuristic_usingIrradianceDataSource(
value: c_float,
r#type: MDLProbePlacement,
data_source: &ProtocolObject<dyn MDLLightProbeIrradianceDataSource>,
) -> Retained<NSArray<MDLLightProbe>>;
);
}