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
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
//! 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!(
/// convenience object to quickly access vertex attribute data
///
/// created by MDLMesh's vertexAttributeData selector
/// Setting values on this object has no effect on the
/// underlying objects.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributedata?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MDLVertexAttributeData;
);
extern_conformance!(
unsafe impl NSObjectProtocol for MDLVertexAttributeData {}
);
impl MDLVertexAttributeData {
extern_methods!(
#[cfg(feature = "MDLMeshBuffer")]
#[unsafe(method(map))]
#[unsafe(method_family = none)]
pub unsafe fn map(&self) -> Retained<MDLMeshBufferMap>;
#[cfg(feature = "MDLMeshBuffer")]
/// Setter for [`map`][Self::map].
#[unsafe(method(setMap:))]
#[unsafe(method_family = none)]
pub unsafe fn setMap(&self, map: &MDLMeshBufferMap);
#[unsafe(method(dataStart))]
#[unsafe(method_family = none)]
pub unsafe fn dataStart(&self) -> NonNull<c_void>;
/// Setter for [`dataStart`][Self::dataStart].
///
/// # Safety
///
/// `data_start` must be a valid pointer.
#[unsafe(method(setDataStart:))]
#[unsafe(method_family = none)]
pub unsafe fn setDataStart(&self, data_start: NonNull<c_void>);
#[unsafe(method(stride))]
#[unsafe(method_family = none)]
pub unsafe fn stride(&self) -> NSUInteger;
/// Setter for [`stride`][Self::stride].
#[unsafe(method(setStride:))]
#[unsafe(method_family = none)]
pub unsafe fn setStride(&self, stride: NSUInteger);
#[cfg(feature = "MDLVertexDescriptor")]
#[unsafe(method(format))]
#[unsafe(method_family = none)]
pub unsafe fn format(&self) -> MDLVertexFormat;
#[cfg(feature = "MDLVertexDescriptor")]
/// Setter for [`format`][Self::format].
#[unsafe(method(setFormat:))]
#[unsafe(method_family = none)]
pub unsafe fn setFormat(&self, format: MDLVertexFormat);
#[unsafe(method(bufferSize))]
#[unsafe(method_family = none)]
pub unsafe fn bufferSize(&self) -> NSUInteger;
/// Setter for [`bufferSize`][Self::bufferSize].
#[unsafe(method(setBufferSize:))]
#[unsafe(method_family = none)]
pub unsafe fn setBufferSize(&self, buffer_size: NSUInteger);
);
}
/// Methods declared on superclass `NSObject`.
impl MDLVertexAttributeData {
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 vertex buffer with info to interpret vertex data
///
/// Includes a collection of submeshs which have indexbuffer and
/// material information
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlmesh?language=objc)
#[unsafe(super(MDLObject, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "MDLObject")]
pub struct MDLMesh;
);
#[cfg(all(feature = "MDLObject", feature = "MDLTypes"))]
extern_conformance!(
unsafe impl MDLNamed for MDLMesh {}
);
#[cfg(feature = "MDLObject")]
extern_conformance!(
unsafe impl NSObjectProtocol for MDLMesh {}
);
#[cfg(feature = "MDLObject")]
impl MDLMesh {
extern_methods!(
#[cfg(feature = "MDLMeshBuffer")]
/// Initialize a mesh with an allocator
///
/// Returns: An empty mesh
#[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 = "MDLSubmesh",
feature = "MDLVertexDescriptor"
))]
/// Initialize object with a vertex buffer and a collection of submeshes
///
/// Returns: Initialized mesh or nil if descriptor's layout array does not describe
/// a single buffer
///
/// Parameter `vertexBuffer`: MDLMeshBuffer object containing all vertex data for the mesh
///
/// Parameter `vertexCount`: Number of vertices in the vertexBuffer
///
/// Parameter `descriptor`: VertexDescriptor specifying how to interpret vertex data
///
/// Parameter `submeshes`: Array of submeshes with index buffers referencing vertex data
/// and/or materials to be applied to mesh
#[unsafe(method(initWithVertexBuffer:vertexCount:descriptor:submeshes:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithVertexBuffer_vertexCount_descriptor_submeshes(
this: Allocated<Self>,
vertex_buffer: &ProtocolObject<dyn MDLMeshBuffer>,
vertex_count: NSUInteger,
descriptor: &MDLVertexDescriptor,
submeshes: &NSArray<MDLSubmesh>,
) -> Retained<Self>;
#[cfg(all(
feature = "MDLMeshBuffer",
feature = "MDLSubmesh",
feature = "MDLVertexDescriptor"
))]
/// Initialize object with an array of vertex buffers (Structure of
/// Arrays) and a collection of submeshes
///
/// Returns: Initialized mesh or nil if descriptor's layout array is incompatible
/// with vertexBuffers array
///
/// Parameter `vertexCount`: Number of vertices in vertexBuffers
///
/// Parameter `descriptor`: VertexDescriptor specifying how to interpret vertex data
///
/// Parameter `submeshes`: Array of submeshes with index buffers referencing vertex data
/// and/or materials to be applied to mesh
///
/// Allows initialization with the layout of the vertexBuffers in a
/// structure-of-arrays form, in other words, non-interleaved vertex attributes
#[unsafe(method(initWithVertexBuffers:vertexCount:descriptor:submeshes:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithVertexBuffers_vertexCount_descriptor_submeshes(
this: Allocated<Self>,
vertex_buffers: &NSArray<ProtocolObject<dyn MDLMeshBuffer>>,
vertex_count: NSUInteger,
descriptor: &MDLVertexDescriptor,
submeshes: &NSArray<MDLSubmesh>,
) -> Retained<Self>;
/// convenience selector to get quick access to vertex attribute data
///
/// the vertex buffer will remain mapped until the MDLVertexAttributeData
/// is freed.
#[unsafe(method(vertexAttributeDataForAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn vertexAttributeDataForAttributeNamed(
&self,
name: &NSString,
) -> Option<Retained<MDLVertexAttributeData>>;
#[cfg(feature = "MDLVertexDescriptor")]
/// convenience selector to get quick access to vertex attribute data
/// reformatted to the requested format if necessary.
///
/// If the desired format has less elements than the source attribute
/// elements, excess elements will be discarded. If the desired format
/// has more elements than the source attribute, then the destination
/// elements will be set to zero.
/// The vertex buffer will remain mapped until the MDLVertexAttributeData
/// is freed.
#[unsafe(method(vertexAttributeDataForAttributeNamed:asFormat:))]
#[unsafe(method_family = none)]
pub unsafe fn vertexAttributeDataForAttributeNamed_asFormat(
&self,
name: &NSString,
format: MDLVertexFormat,
) -> Option<Retained<MDLVertexAttributeData>>;
#[cfg(feature = "MDLVertexDescriptor")]
/// Immutable vertex descriptor for interpreting data in vertexBuffers
///
/// Setting this applies the new layout in 'vertexBuffers' thus is a
/// heavyweight operation as structured copies of almost all vertex
/// buffer data could be made. Additionally, if the new vertexDescriptor
/// does not have an attribute in the original vertexDescriptor, that
/// attribute will be deleted. If the original vertexDescriptor does
/// not have an attribute in the new vertexDescriptor, the data for the
/// added attribute set as the added attribute's initializationValue
/// property.
///
/// The allocator associated with each original meshbuffer is used to
/// reallocate the corresponding resultant meshbuffer.
#[unsafe(method(vertexDescriptor))]
#[unsafe(method_family = none)]
pub unsafe fn vertexDescriptor(&self) -> Retained<MDLVertexDescriptor>;
#[cfg(feature = "MDLVertexDescriptor")]
/// Setter for [`vertexDescriptor`][Self::vertexDescriptor].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setVertexDescriptor:))]
#[unsafe(method_family = none)]
pub unsafe fn setVertexDescriptor(&self, vertex_descriptor: &MDLVertexDescriptor);
/// Number of vertices in the vertexBuffers
///
/// The size of vertex data in each buffer can be computed by multiplying
/// this value with the stride of the buffer in the vertexDescriptor's
/// layout
#[unsafe(method(vertexCount))]
#[unsafe(method_family = none)]
pub unsafe fn vertexCount(&self) -> NSUInteger;
/// Setter for [`vertexCount`][Self::vertexCount].
#[unsafe(method(setVertexCount:))]
#[unsafe(method_family = none)]
pub unsafe fn setVertexCount(&self, vertex_count: NSUInteger);
#[cfg(feature = "MDLMeshBuffer")]
/// Array of buffers containing vertex data
///
/// The vertex buffers in this array are indexed by the vertex descriptor.
#[unsafe(method(vertexBuffers))]
#[unsafe(method_family = none)]
pub unsafe fn vertexBuffers(&self) -> Retained<NSArray<ProtocolObject<dyn MDLMeshBuffer>>>;
#[cfg(feature = "MDLMeshBuffer")]
/// Setter for [`vertexBuffers`][Self::vertexBuffers].
#[unsafe(method(setVertexBuffers:))]
#[unsafe(method_family = none)]
pub unsafe fn setVertexBuffers(
&self,
vertex_buffers: &NSArray<ProtocolObject<dyn MDLMeshBuffer>>,
);
#[cfg(feature = "MDLSubmesh")]
/// Array of submeshes containing an indexbuffer referencing the vertex
/// data and material to be applied when the mesh is rendered
#[unsafe(method(submeshes))]
#[unsafe(method_family = none)]
pub unsafe fn submeshes(&self) -> Option<Retained<NSMutableArray<MDLSubmesh>>>;
#[cfg(feature = "MDLSubmesh")]
/// Setter for [`submeshes`][Self::submeshes].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setSubmeshes:))]
#[unsafe(method_family = none)]
pub unsafe fn setSubmeshes(&self, submeshes: Option<&NSMutableArray<MDLSubmesh>>);
#[cfg(feature = "MDLMeshBuffer")]
/// allocator used to allocate contained mesh buffers
#[unsafe(method(allocator))]
#[unsafe(method_family = none)]
pub unsafe fn allocator(&self) -> Retained<ProtocolObject<dyn MDLMeshBufferAllocator>>;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLMesh {
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>;
);
}
/// Modifiers.
#[cfg(feature = "MDLObject")]
impl MDLMesh {
extern_methods!(
#[cfg(feature = "MDLVertexDescriptor")]
/// Convenience method to add an attribute
///
/// The mesh's allocator will be used to create storage for the new
/// attribute.
#[unsafe(method(addAttributeWithName:format:))]
#[unsafe(method_family = none)]
pub unsafe fn addAttributeWithName_format(&self, name: &NSString, format: MDLVertexFormat);
#[cfg(feature = "MDLVertexDescriptor")]
/// Create a new vertex attribute including an associated buffer with
/// a copy of the supplied data, and update the vertex descriptor accordingly
///
/// Parameter `name`: The name the attribute can be found by
///
/// Parameter `format`: Format of the data, such as MDLVertexFormatFloat3
///
/// Parameter `type`: The usage of the attribute, such as MDLVertexAttributePosition
///
/// Parameter `data`: Object containing the data to be used in the new vertex buffer
///
/// Parameter `stride`: The increment in bytes from the start of one data entry to
/// the next.
#[unsafe(method(addAttributeWithName:format:type:data:stride:))]
#[unsafe(method_family = none)]
pub unsafe fn addAttributeWithName_format_type_data_stride(
&self,
name: &NSString,
format: MDLVertexFormat,
r#type: &NSString,
data: &NSData,
stride: NSInteger,
);
#[cfg(feature = "MDLVertexDescriptor")]
/// Create a new vertex attribute including an associated buffer with
/// a copy of the supplied data, and update the vertex descriptor accordingly
///
/// Parameter `name`: The name the attribute can be found by
///
/// Parameter `format`: Format of the data, such as MDLVertexFormatFloat3
///
/// Parameter `type`: The usage of the attribute, such as MDLVertexAttributePosition
///
/// Parameter `data`: Object containing the data to be used in the new vertex buffer
///
/// Parameter `stride`: The increment in bytes from the start of one data entry to
/// the next.
///
/// Parameter `time`: The time the attribute is to be invoked at.
///
/// Adding an attribute, such as position data, at multiple times will
/// result in attributes being created for each of those times.
/// Attributes corresponding to multiple times can be retrieved from
/// the vertex descriptor.
#[unsafe(method(addAttributeWithName:format:type:data:stride:time:))]
#[unsafe(method_family = none)]
pub unsafe fn addAttributeWithName_format_type_data_stride_time(
&self,
name: &NSString,
format: MDLVertexFormat,
r#type: &NSString,
data: &NSData,
stride: NSInteger,
time: NSTimeInterval,
);
/// Calculate and add vertex normal data
///
/// Parameter `attributeName`: Name is the attribute name of vertex normal attribute. If nil, vertex normals
/// will be added with the MDLVertexAttributeNormal name string
///
/// Parameter `creaseThreshold`: Threshold of the dot product between the 2 triangles after which
/// their face normal will be smoothed out. Therefore, a threshold of 0 will
/// smooth everything and a threshold of 1 won't smooth anything.
///
/// Uses the attribute named MDLVertexAttributePosition to calculate
/// vertex normals. If the mesh does not have an attribute with
/// 'attributeName', it will be added, otherwise the attribute name will
/// be overwritten with vertex normal data. 'vertexDescriptor' will be
/// updated to reflect the new attribute.
#[unsafe(method(addNormalsWithAttributeNamed:creaseThreshold:))]
#[unsafe(method_family = none)]
pub unsafe fn addNormalsWithAttributeNamed_creaseThreshold(
&self,
attribute_name: Option<&NSString>,
crease_threshold: c_float,
);
/// Create a shader basis where the tangent and bitangent span the uv -> object space transform
///
/// Parameter `textureCoordinateAttributeName`: Name of texture coordinates to use in calculations
///
/// Parameter `tangentAttributeName`: Name of vertex tangent attribute.
///
/// Parameter `bitangentAttributeName`: Name of vertex bitangent attribute.
///
/// Uses the attribute named MDLVertexAttributePosition and
/// textureCoordinateAttributeName to calculate tangent and bitangent
/// attributes. The mesh's vertexDescriptor will be updated to reflect
/// the new attributes if necessary. The basis may not be orthogonal; to gaurantee an orthogonal
/// tangent basis please use addOrthTanBasisForTextureCoordinateAttibuteNamed selector.
#[unsafe(method(addTangentBasisForTextureCoordinateAttributeNamed:tangentAttributeNamed:bitangentAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn addTangentBasisForTextureCoordinateAttributeNamed_tangentAttributeNamed_bitangentAttributeNamed(
&self,
texture_coordinate_attribute_name: &NSString,
tangent_attribute_name: &NSString,
bitangent_attribute_name: Option<&NSString>,
);
/// Create tangents which are orthogonal to the normal
///
/// Parameter `textureCoordinateAttributeName`: texture coordinates to use in calculations
///
/// Parameter `normalAttributeName`: normals to use in calculations
///
/// Parameter `tangentAttributeName`: Name of a four component vertex tangent attribute.
///
/// Uses the attribute named MDLVertexAttributePosition and
/// textureCoordinateAttributeName and the specified normals to calculate
/// tangent information. The mesh's vertexDescriptor will be updated to
/// reflect the new attribute if necessary.
/// Note that this method does NOT produce a T.w component which is used in B = (N x T) * T.w
/// Please use addOrthTanBasisForTextureCoordinateAttributeNamed.
#[unsafe(method(addTangentBasisForTextureCoordinateAttributeNamed:normalAttributeNamed:tangentAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn addTangentBasisForTextureCoordinateAttributeNamed_normalAttributeNamed_tangentAttributeNamed(
&self,
texture_coordinate_attribute_name: &NSString,
normal_attribute_name: &NSString,
tangent_attribute_name: &NSString,
);
#[unsafe(method(addOrthTanBasisForTextureCoordinateAttributeNamed:normalAttributeNamed:tangentAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn addOrthTanBasisForTextureCoordinateAttributeNamed_normalAttributeNamed_tangentAttributeNamed(
&self,
texture_coordinate_attribute_name: &NSString,
normal_attribute_name: &NSString,
tangent_attribute_name: &NSString,
);
/// Creates texture coordinates by unwrapping the mesh
///
/// Parameter `textureCoordinateAttributeName`: texture coordinates to modify or create
///
/// Uses the attribute named MDLVertexAttributePosition and if available,
/// the attribute named MDLVertexAttributeNormal to calculate texture coordinates
#[unsafe(method(addUnwrappedTextureCoordinatesForAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn addUnwrappedTextureCoordinatesForAttributeNamed(
&self,
texture_coordinate_attribute_name: &NSString,
);
/// Flips texture coordinates by performing the operation (u,v) = (u, 1-v)
///
/// Parameter `textureCoordinateAttributeName`: texture coordinates to modify
///
/// Many application generate model files with texture coordinate mapping
/// assuming a bottom left bitmap origin. It can be more convenient to
/// have texture coordinates corresponding to an upper left bitmap origin.
/// This selector will perform the flip operation if the requested texture
/// coordinate attribute exists on the mesh. An exception will be raised if
/// the attribute cannot be found
#[unsafe(method(flipTextureCoordinatesInAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn flipTextureCoordinatesInAttributeNamed(
&self,
texture_coordinate_attribute_name: &NSString,
);
/// Deindexes the vertex array
///
/// If any vertices are shared on multiple faces, duplicate those
/// vertices so faces do not share vertices. The vertex buffer and index
/// buffers on submeshes may grow to accomadate any vertices added.
#[deprecated]
#[unsafe(method(makeVerticesUnique))]
#[unsafe(method_family = none)]
pub unsafe fn makeVerticesUnique(&self);
/// Deindexes the vertex array
///
/// If any vertices are shared on multiple faces, duplicate those
/// vertices so faces do not share vertices. The vertex buffer and index
/// buffers on submeshes may grow to accomadate any vertices added.
#[unsafe(method(makeVerticesUniqueAndReturnError:_))]
#[unsafe(method_family = none)]
pub unsafe fn makeVerticesUniqueAndReturnError(&self) -> Result<(), Retained<NSError>>;
/// replace existing attribute data with new attribute data retaining
/// the format of the replacement data.
///
/// If the specified attribute does not already exist, it will be
/// created.
#[unsafe(method(replaceAttributeNamed:withData:))]
#[unsafe(method_family = none)]
pub unsafe fn replaceAttributeNamed_withData(
&self,
name: &NSString,
new_data: &MDLVertexAttributeData,
);
/// update existing attribute data with new attribute data retaining
/// the format of the existing data.
///
/// If the specified attribute does not already exist, it will be
/// created with the same format as the newData.
#[unsafe(method(updateAttributeNamed:withData:))]
#[unsafe(method_family = none)]
pub unsafe fn updateAttributeNamed_withData(
&self,
name: &NSString,
new_data: &MDLVertexAttributeData,
);
/// remove an attribute
///
/// if the named attribute does not exist, nothing happens.
#[unsafe(method(removeAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn removeAttributeNamed(&self, name: &NSString);
);
}
/// Generators.
#[cfg(feature = "MDLObject")]
impl MDLMesh {
extern_methods!(
#[cfg(feature = "MDLMeshBuffer")]
/// Factory method that generates a subdivided mesh from a source mesh
///
/// Parameter `mesh`: Mesh from which to generate a subdivided mesh
///
/// Parameter `submeshIndex`: Index of submesh in Mesh's submesh array from which to
/// generate a subdivided mesh
///
/// Parameter `subdivisionLevels`: The number of levels to subdivide mesh
///
/// Subdivision levels over four are likely to generate more triangles
/// than can be reasonably displayed. Index and vertex data will use
/// the same allocator used for the source mesh. Loading an asset
/// using the topology preservation flag set to YES will result in the
/// best subdivision results.
///
/// Returns: Returns a mesh subdivided to index level, unless subdivision is
/// impossible.
#[unsafe(method(initMeshBySubdividingMesh:submeshIndex:subdivisionLevels:allocator:))]
#[unsafe(method_family = init)]
pub unsafe fn initMeshBySubdividingMesh_submeshIndex_subdivisionLevels_allocator(
this: Allocated<Self>,
mesh: &MDLMesh,
submesh_index: c_int,
subdivision_levels: c_uint,
allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
) -> Retained<Self>;
#[cfg(all(feature = "MDLMeshBuffer", feature = "MDLTypes"))]
#[unsafe(method(newIcosahedronWithRadius:inwardNormals:geometryType:allocator:))]
#[unsafe(method_family = new)]
pub unsafe fn newIcosahedronWithRadius_inwardNormals_geometryType_allocator(
radius: c_float,
inward_normals: bool,
geometry_type: MDLGeometryType,
allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
) -> Retained<Self>;
#[cfg(feature = "MDLMeshBuffer")]
#[unsafe(method(newIcosahedronWithRadius:inwardNormals:allocator:))]
#[unsafe(method_family = new)]
pub unsafe fn newIcosahedronWithRadius_inwardNormals_allocator(
radius: c_float,
inward_normals: bool,
allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
) -> Retained<Self>;
#[unsafe(method(newSubdividedMesh:submeshIndex:subdivisionLevels:))]
#[unsafe(method_family = new)]
pub unsafe fn newSubdividedMesh_submeshIndex_subdivisionLevels(
mesh: &MDLMesh,
submesh_index: NSUInteger,
subdivision_levels: NSUInteger,
) -> Option<Retained<Self>>;
);
}
/// MDLLightBaking.
#[cfg(feature = "MDLObject")]
impl MDLMesh {
extern_methods!(
/// Creates an Ambient Occlusion texture, returns true upon success, false
/// upon failure
///
/// Parameter `bakeQuality`: Float between 0 and 1 that defines quality of the bake process.
/// 0 is of lower quality but bakes faster and uses less memory, where 1 is
/// of higher quality.
///
/// Parameter `attenuationFactor`: Float between 0 to 1 that defines how to attenuate the
/// AO value. 0 doesn't change it, and at 1, all AO values are white except
/// if they are originally completely black. Quadratic attenuation in between.
///
/// Parameter `objectsToConsider`: NSArray of MDLMeshes containing the objects to raytrace
/// against
///
/// Parameter `vertexAttributeName`: NSString of the MDLVertexAttribute where the vertex
/// texture UVs will be stored. Creates it if it doesn't exist, otherwise
/// overwrites current values.
///
/// Parameter `materialPropertyName`: NSString of the MDLMaterialProperty that will store
/// the texture in the Mesh.
///
/// Returns: Success or failure of the baking process.
#[unsafe(method(generateAmbientOcclusionTextureWithQuality:attenuationFactor:objectsToConsider:vertexAttributeNamed:materialPropertyNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn generateAmbientOcclusionTextureWithQuality_attenuationFactor_objectsToConsider_vertexAttributeNamed_materialPropertyNamed(
&self,
bake_quality: c_float,
attenuation_factor: c_float,
objects_to_consider: &NSArray<MDLObject>,
vertex_attribute_name: &NSString,
material_property_name: &NSString,
) -> bool;
#[unsafe(method(generateAmbientOcclusionVertexColorsWithRaysPerSample:attenuationFactor:objectsToConsider:vertexAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn generateAmbientOcclusionVertexColorsWithRaysPerSample_attenuationFactor_objectsToConsider_vertexAttributeNamed(
&self,
rays_per_sample: NSInteger,
attenuation_factor: c_float,
objects_to_consider: &NSArray<MDLObject>,
vertex_attribute_name: &NSString,
) -> bool;
#[unsafe(method(generateAmbientOcclusionVertexColorsWithQuality:attenuationFactor:objectsToConsider:vertexAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn generateAmbientOcclusionVertexColorsWithQuality_attenuationFactor_objectsToConsider_vertexAttributeNamed(
&self,
bake_quality: c_float,
attenuation_factor: c_float,
objects_to_consider: &NSArray<MDLObject>,
vertex_attribute_name: &NSString,
) -> bool;
#[cfg(feature = "MDLLight")]
#[unsafe(method(generateLightMapTextureWithQuality:lightsToConsider:objectsToConsider:vertexAttributeNamed:materialPropertyNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn generateLightMapTextureWithQuality_lightsToConsider_objectsToConsider_vertexAttributeNamed_materialPropertyNamed(
&self,
bake_quality: c_float,
lights_to_consider: &NSArray<MDLLight>,
objects_to_consider: &NSArray<MDLObject>,
vertex_attribute_name: &NSString,
material_property_name: &NSString,
) -> bool;
#[cfg(feature = "MDLLight")]
#[unsafe(method(generateLightMapVertexColorsWithLightsToConsider:objectsToConsider:vertexAttributeNamed:))]
#[unsafe(method_family = none)]
pub unsafe fn generateLightMapVertexColorsWithLightsToConsider_objectsToConsider_vertexAttributeNamed(
&self,
lights_to_consider: &NSArray<MDLLight>,
objects_to_consider: &NSArray<MDLObject>,
vertex_attribute_name: &NSString,
) -> bool;
);
}