objc2_model_io/generated/MDLMesh.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
10extern_class!(
11 /// convenience object to quickly access vertex attribute data
12 ///
13 /// created by MDLMesh's vertexAttributeData selector
14 /// Setting values on this object has no effect on the
15 /// underlying objects.
16 ///
17 /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributedata?language=objc)
18 #[unsafe(super(NSObject))]
19 #[derive(Debug, PartialEq, Eq, Hash)]
20 pub struct MDLVertexAttributeData;
21);
22
23unsafe impl NSObjectProtocol for MDLVertexAttributeData {}
24
25impl MDLVertexAttributeData {
26 extern_methods!(
27 #[cfg(feature = "MDLMeshBuffer")]
28 #[unsafe(method(map))]
29 #[unsafe(method_family = none)]
30 pub unsafe fn map(&self) -> Retained<MDLMeshBufferMap>;
31
32 #[cfg(feature = "MDLMeshBuffer")]
33 /// Setter for [`map`][Self::map].
34 #[unsafe(method(setMap:))]
35 #[unsafe(method_family = none)]
36 pub unsafe fn setMap(&self, map: &MDLMeshBufferMap);
37
38 #[unsafe(method(dataStart))]
39 #[unsafe(method_family = none)]
40 pub unsafe fn dataStart(&self) -> NonNull<c_void>;
41
42 /// Setter for [`dataStart`][Self::dataStart].
43 #[unsafe(method(setDataStart:))]
44 #[unsafe(method_family = none)]
45 pub unsafe fn setDataStart(&self, data_start: NonNull<c_void>);
46
47 #[unsafe(method(stride))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn stride(&self) -> NSUInteger;
50
51 /// Setter for [`stride`][Self::stride].
52 #[unsafe(method(setStride:))]
53 #[unsafe(method_family = none)]
54 pub unsafe fn setStride(&self, stride: NSUInteger);
55
56 #[cfg(feature = "MDLVertexDescriptor")]
57 #[unsafe(method(format))]
58 #[unsafe(method_family = none)]
59 pub unsafe fn format(&self) -> MDLVertexFormat;
60
61 #[cfg(feature = "MDLVertexDescriptor")]
62 /// Setter for [`format`][Self::format].
63 #[unsafe(method(setFormat:))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn setFormat(&self, format: MDLVertexFormat);
66
67 #[unsafe(method(bufferSize))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn bufferSize(&self) -> NSUInteger;
70
71 /// Setter for [`bufferSize`][Self::bufferSize].
72 #[unsafe(method(setBufferSize:))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn setBufferSize(&self, buffer_size: NSUInteger);
75 );
76}
77
78/// Methods declared on superclass `NSObject`.
79impl MDLVertexAttributeData {
80 extern_methods!(
81 #[unsafe(method(init))]
82 #[unsafe(method_family = init)]
83 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
84
85 #[unsafe(method(new))]
86 #[unsafe(method_family = new)]
87 pub unsafe fn new() -> Retained<Self>;
88 );
89}
90
91extern_class!(
92 /// A vertex buffer with info to interpret vertex data
93 ///
94 /// Includes a collection of submeshs which have indexbuffer and
95 /// material information
96 ///
97 /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlmesh?language=objc)
98 #[unsafe(super(MDLObject, NSObject))]
99 #[derive(Debug, PartialEq, Eq, Hash)]
100 #[cfg(feature = "MDLObject")]
101 pub struct MDLMesh;
102);
103
104#[cfg(all(feature = "MDLObject", feature = "MDLTypes"))]
105unsafe impl MDLNamed for MDLMesh {}
106
107#[cfg(feature = "MDLObject")]
108unsafe impl NSObjectProtocol for MDLMesh {}
109
110#[cfg(feature = "MDLObject")]
111impl MDLMesh {
112 extern_methods!(
113 #[cfg(feature = "MDLMeshBuffer")]
114 /// Initialize a mesh with an allocator
115 ///
116 /// Returns: An empty mesh
117 #[unsafe(method(initWithBufferAllocator:))]
118 #[unsafe(method_family = init)]
119 pub unsafe fn initWithBufferAllocator(
120 this: Allocated<Self>,
121 buffer_allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
122 ) -> Retained<Self>;
123
124 #[cfg(all(
125 feature = "MDLMeshBuffer",
126 feature = "MDLSubmesh",
127 feature = "MDLVertexDescriptor"
128 ))]
129 /// Initialize object with a vertex buffer and a collection of submeshes
130 ///
131 /// Returns: Initialized mesh or nil if descriptor's layout array does not describe
132 /// a single buffer
133 ///
134 /// Parameter `vertexBuffer`: MDLMeshBuffer object containing all vertex data for the mesh
135 ///
136 /// Parameter `vertexCount`: Number of vertices in the vertexBuffer
137 ///
138 /// Parameter `descriptor`: VertexDescriptor specifying how to interpret vertex data
139 ///
140 /// Parameter `submeshes`: Array of submeshes with index buffers referencing vertex data
141 /// and/or materials to be applied to mesh
142 #[unsafe(method(initWithVertexBuffer:vertexCount:descriptor:submeshes:))]
143 #[unsafe(method_family = init)]
144 pub unsafe fn initWithVertexBuffer_vertexCount_descriptor_submeshes(
145 this: Allocated<Self>,
146 vertex_buffer: &ProtocolObject<dyn MDLMeshBuffer>,
147 vertex_count: NSUInteger,
148 descriptor: &MDLVertexDescriptor,
149 submeshes: &NSArray<MDLSubmesh>,
150 ) -> Retained<Self>;
151
152 #[cfg(all(
153 feature = "MDLMeshBuffer",
154 feature = "MDLSubmesh",
155 feature = "MDLVertexDescriptor"
156 ))]
157 /// Initialize object with an array of vertex buffers (Structure of
158 /// Arrays) and a collection of submeshes
159 ///
160 /// Returns: Initialized mesh or nil if descriptor's layout array is incompatible
161 /// with vertexBuffers array
162 ///
163 /// Parameter `vertexCount`: Number of vertices in vertexBuffers
164 ///
165 /// Parameter `descriptor`: VertexDescriptor specifying how to interpret vertex data
166 ///
167 /// Parameter `submeshes`: Array of submeshes with index buffers referencing vertex data
168 /// and/or materials to be applied to mesh
169 ///
170 /// Allows initialization with the layout of the vertexBuffers in a
171 /// structure-of-arrays form, in other words, non-interleaved vertex attributes
172 #[unsafe(method(initWithVertexBuffers:vertexCount:descriptor:submeshes:))]
173 #[unsafe(method_family = init)]
174 pub unsafe fn initWithVertexBuffers_vertexCount_descriptor_submeshes(
175 this: Allocated<Self>,
176 vertex_buffers: &NSArray<ProtocolObject<dyn MDLMeshBuffer>>,
177 vertex_count: NSUInteger,
178 descriptor: &MDLVertexDescriptor,
179 submeshes: &NSArray<MDLSubmesh>,
180 ) -> Retained<Self>;
181
182 /// convenience selector to get quick access to vertex attribute data
183 ///
184 /// the vertex buffer will remain mapped until the MDLVertexAttributeData
185 /// is freed.
186 #[unsafe(method(vertexAttributeDataForAttributeNamed:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn vertexAttributeDataForAttributeNamed(
189 &self,
190 name: &NSString,
191 ) -> Option<Retained<MDLVertexAttributeData>>;
192
193 #[cfg(feature = "MDLVertexDescriptor")]
194 /// convenience selector to get quick access to vertex attribute data
195 /// reformatted to the requested format if necessary.
196 ///
197 /// If the desired format has less elements than the source attribute
198 /// elements, excess elements will be discarded. If the desired format
199 /// has more elements than the source attribute, then the destination
200 /// elements will be set to zero.
201 /// The vertex buffer will remain mapped until the MDLVertexAttributeData
202 /// is freed.
203 #[unsafe(method(vertexAttributeDataForAttributeNamed:asFormat:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn vertexAttributeDataForAttributeNamed_asFormat(
206 &self,
207 name: &NSString,
208 format: MDLVertexFormat,
209 ) -> Option<Retained<MDLVertexAttributeData>>;
210
211 #[cfg(feature = "MDLVertexDescriptor")]
212 /// Immutable vertex descriptor for interpreting data in vertexBuffers
213 ///
214 /// Setting this applies the new layout in 'vertexBuffers' thus is a
215 /// heavyweight operation as structured copies of almost all vertex
216 /// buffer data could be made. Additionally, if the new vertexDescriptor
217 /// does not have an attribute in the original vertexDescriptor, that
218 /// attribute will be deleted. If the original vertexDescriptor does
219 /// not have an attribute in the new vertexDescriptor, the data for the
220 /// added attribute set as the added attribute's initializationValue
221 /// property.
222 ///
223 /// The allocator associated with each original meshbuffer is used to
224 /// reallocate the corresponding resultant meshbuffer.
225 #[unsafe(method(vertexDescriptor))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn vertexDescriptor(&self) -> Retained<MDLVertexDescriptor>;
228
229 #[cfg(feature = "MDLVertexDescriptor")]
230 /// Setter for [`vertexDescriptor`][Self::vertexDescriptor].
231 #[unsafe(method(setVertexDescriptor:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn setVertexDescriptor(&self, vertex_descriptor: &MDLVertexDescriptor);
234
235 /// Number of vertices in the vertexBuffers
236 ///
237 /// The size of vertex data in each buffer can be computed by multiplying
238 /// this value with the stride of the buffer in the vertexDescriptor's
239 /// layout
240 #[unsafe(method(vertexCount))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn vertexCount(&self) -> NSUInteger;
243
244 /// Setter for [`vertexCount`][Self::vertexCount].
245 #[unsafe(method(setVertexCount:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn setVertexCount(&self, vertex_count: NSUInteger);
248
249 #[cfg(feature = "MDLMeshBuffer")]
250 /// Array of buffers containing vertex data
251 ///
252 /// The vertex buffers in this array are indexed by the vertex descriptor.
253 #[unsafe(method(vertexBuffers))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn vertexBuffers(&self) -> Retained<NSArray<ProtocolObject<dyn MDLMeshBuffer>>>;
256
257 #[cfg(feature = "MDLMeshBuffer")]
258 /// Setter for [`vertexBuffers`][Self::vertexBuffers].
259 #[unsafe(method(setVertexBuffers:))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn setVertexBuffers(
262 &self,
263 vertex_buffers: &NSArray<ProtocolObject<dyn MDLMeshBuffer>>,
264 );
265
266 #[cfg(feature = "MDLSubmesh")]
267 /// Array of submeshes containing an indexbuffer referencing the vertex
268 /// data and material to be applied when the mesh is rendered
269 #[unsafe(method(submeshes))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn submeshes(&self) -> Option<Retained<NSMutableArray<MDLSubmesh>>>;
272
273 #[cfg(feature = "MDLSubmesh")]
274 /// Setter for [`submeshes`][Self::submeshes].
275 #[unsafe(method(setSubmeshes:))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn setSubmeshes(&self, submeshes: Option<&NSMutableArray<MDLSubmesh>>);
278
279 #[cfg(feature = "MDLMeshBuffer")]
280 /// allocator used to allocate contained mesh buffers
281 #[unsafe(method(allocator))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn allocator(&self) -> Retained<ProtocolObject<dyn MDLMeshBufferAllocator>>;
284 );
285}
286
287/// Methods declared on superclass `NSObject`.
288#[cfg(feature = "MDLObject")]
289impl MDLMesh {
290 extern_methods!(
291 #[unsafe(method(init))]
292 #[unsafe(method_family = init)]
293 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
294
295 #[unsafe(method(new))]
296 #[unsafe(method_family = new)]
297 pub unsafe fn new() -> Retained<Self>;
298 );
299}
300
301/// Modifiers.
302#[cfg(feature = "MDLObject")]
303impl MDLMesh {
304 extern_methods!(
305 #[cfg(feature = "MDLVertexDescriptor")]
306 /// Convenience method to add an attribute
307 ///
308 /// The mesh's allocator will be used to create storage for the new
309 /// attribute.
310 #[unsafe(method(addAttributeWithName:format:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn addAttributeWithName_format(&self, name: &NSString, format: MDLVertexFormat);
313
314 #[cfg(feature = "MDLVertexDescriptor")]
315 /// Create a new vertex attribute including an associated buffer with
316 /// a copy of the supplied data, and update the vertex descriptor accordingly
317 ///
318 /// Parameter `name`: The name the attribute can be found by
319 ///
320 /// Parameter `format`: Format of the data, such as MDLVertexFormatFloat3
321 ///
322 /// Parameter `type`: The usage of the attribute, such as MDLVertexAttributePosition
323 ///
324 /// Parameter `data`: Object containing the data to be used in the new vertex buffer
325 ///
326 /// Parameter `stride`: The increment in bytes from the start of one data entry to
327 /// the next.
328 #[unsafe(method(addAttributeWithName:format:type:data:stride:))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn addAttributeWithName_format_type_data_stride(
331 &self,
332 name: &NSString,
333 format: MDLVertexFormat,
334 r#type: &NSString,
335 data: &NSData,
336 stride: NSInteger,
337 );
338
339 #[cfg(feature = "MDLVertexDescriptor")]
340 /// Create a new vertex attribute including an associated buffer with
341 /// a copy of the supplied data, and update the vertex descriptor accordingly
342 ///
343 /// Parameter `name`: The name the attribute can be found by
344 ///
345 /// Parameter `format`: Format of the data, such as MDLVertexFormatFloat3
346 ///
347 /// Parameter `type`: The usage of the attribute, such as MDLVertexAttributePosition
348 ///
349 /// Parameter `data`: Object containing the data to be used in the new vertex buffer
350 ///
351 /// Parameter `stride`: The increment in bytes from the start of one data entry to
352 /// the next.
353 ///
354 /// Parameter `time`: The time the attribute is to be invoked at.
355 ///
356 /// Adding an attribute, such as position data, at multiple times will
357 /// result in attributes being created for each of those times.
358 /// Attributes corresponding to multiple times can be retrieved from
359 /// the vertex descriptor.
360 #[unsafe(method(addAttributeWithName:format:type:data:stride:time:))]
361 #[unsafe(method_family = none)]
362 pub unsafe fn addAttributeWithName_format_type_data_stride_time(
363 &self,
364 name: &NSString,
365 format: MDLVertexFormat,
366 r#type: &NSString,
367 data: &NSData,
368 stride: NSInteger,
369 time: NSTimeInterval,
370 );
371
372 /// Calculate and add vertex normal data
373 ///
374 /// Parameter `attributeName`: Name is the attribute name of vertex normal attribute. If nil, vertex normals
375 /// will be added with the MDLVertexAttributeNormal name string
376 ///
377 /// Parameter `creaseThreshold`: Threshold of the dot product between the 2 triangles after which
378 /// their face normal will be smoothed out. Therefore, a threshold of 0 will
379 /// smooth everything and a threshold of 1 won't smooth anything.
380 ///
381 /// Uses the attribute named MDLVertexAttributePosition to calculate
382 /// vertex normals. If the mesh does not have an attribute with
383 /// 'attributeName', it will be added, otherwise the attribute name will
384 /// be overwritten with vertex normal data. 'vertexDescriptor' will be
385 /// updated to reflect the new attribute.
386 #[unsafe(method(addNormalsWithAttributeNamed:creaseThreshold:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn addNormalsWithAttributeNamed_creaseThreshold(
389 &self,
390 attribute_name: Option<&NSString>,
391 crease_threshold: c_float,
392 );
393
394 /// Create a shader basis where the tangent and bitangent span the uv -> object space transform
395 ///
396 /// Parameter `textureCoordinateAttributeName`: Name of texture coordinates to use in calculations
397 ///
398 /// Parameter `tangentAttributeName`: Name of vertex tangent attribute.
399 ///
400 /// Parameter `bitangentAttributeName`: Name of vertex bitangent attribute.
401 ///
402 /// Uses the attribute named MDLVertexAttributePosition and
403 /// textureCoordinateAttributeName to calculate tangent and bitangent
404 /// attributes. The mesh's vertexDescriptor will be updated to reflect
405 /// the new attributes if necessary. The basis may not be orthogonal; to gaurantee an orthogonal
406 /// tangent basis please use addOrthTanBasisForTextureCoordinateAttibuteNamed selector.
407 #[unsafe(method(addTangentBasisForTextureCoordinateAttributeNamed:tangentAttributeNamed:bitangentAttributeNamed:))]
408 #[unsafe(method_family = none)]
409 pub unsafe fn addTangentBasisForTextureCoordinateAttributeNamed_tangentAttributeNamed_bitangentAttributeNamed(
410 &self,
411 texture_coordinate_attribute_name: &NSString,
412 tangent_attribute_name: &NSString,
413 bitangent_attribute_name: Option<&NSString>,
414 );
415
416 /// Create tangents which are orthogonal to the normal
417 ///
418 /// Parameter `textureCoordinateAttributeName`: texture coordinates to use in calculations
419 ///
420 /// Parameter `normalAttributeName`: normals to use in calculations
421 ///
422 /// Parameter `tangentAttributeName`: Name of a four component vertex tangent attribute.
423 ///
424 /// Uses the attribute named MDLVertexAttributePosition and
425 /// textureCoordinateAttributeName and the specified normals to calculate
426 /// tangent information. The mesh's vertexDescriptor will be updated to
427 /// reflect the new attribute if necessary.
428 /// Note that this method does NOT produce a T.w component which is used in B = (N x T) * T.w
429 /// Please use addOrthTanBasisForTextureCoordinateAttributeNamed.
430 #[unsafe(method(addTangentBasisForTextureCoordinateAttributeNamed:normalAttributeNamed:tangentAttributeNamed:))]
431 #[unsafe(method_family = none)]
432 pub unsafe fn addTangentBasisForTextureCoordinateAttributeNamed_normalAttributeNamed_tangentAttributeNamed(
433 &self,
434 texture_coordinate_attribute_name: &NSString,
435 normal_attribute_name: &NSString,
436 tangent_attribute_name: &NSString,
437 );
438
439 #[unsafe(method(addOrthTanBasisForTextureCoordinateAttributeNamed:normalAttributeNamed:tangentAttributeNamed:))]
440 #[unsafe(method_family = none)]
441 pub unsafe fn addOrthTanBasisForTextureCoordinateAttributeNamed_normalAttributeNamed_tangentAttributeNamed(
442 &self,
443 texture_coordinate_attribute_name: &NSString,
444 normal_attribute_name: &NSString,
445 tangent_attribute_name: &NSString,
446 );
447
448 /// Creates texture coordinates by unwrapping the mesh
449 ///
450 /// Parameter `textureCoordinateAttributeName`: texture coordinates to modify or create
451 ///
452 /// Uses the attribute named MDLVertexAttributePosition and if available,
453 /// the attribute named MDLVertexAttributeNormal to calculate texture coordinates
454 #[unsafe(method(addUnwrappedTextureCoordinatesForAttributeNamed:))]
455 #[unsafe(method_family = none)]
456 pub unsafe fn addUnwrappedTextureCoordinatesForAttributeNamed(
457 &self,
458 texture_coordinate_attribute_name: &NSString,
459 );
460
461 /// Flips texture coordinates by performing the operation (u,v) = (u, 1-v)
462 ///
463 /// Parameter `textureCoordinateAttributeName`: texture coordinates to modify
464 ///
465 /// Many application generate model files with texture coordinate mapping
466 /// assuming a bottom left bitmap origin. It can be more convenient to
467 /// have texture coordinates corresponding to an upper left bitmap origin.
468 /// This selector will perform the flip operation if the requested texture
469 /// coordinate attribute exists on the mesh. An exception will be raised if
470 /// the attribute cannot be found
471 #[unsafe(method(flipTextureCoordinatesInAttributeNamed:))]
472 #[unsafe(method_family = none)]
473 pub unsafe fn flipTextureCoordinatesInAttributeNamed(
474 &self,
475 texture_coordinate_attribute_name: &NSString,
476 );
477
478 /// Deindexes the vertex array
479 ///
480 /// If any vertices are shared on multiple faces, duplicate those
481 /// vertices so faces do not share vertices. The vertex buffer and index
482 /// buffers on submeshes may grow to accomadate any vertices added.
483 #[deprecated]
484 #[unsafe(method(makeVerticesUnique))]
485 #[unsafe(method_family = none)]
486 pub unsafe fn makeVerticesUnique(&self);
487
488 /// Deindexes the vertex array
489 ///
490 /// If any vertices are shared on multiple faces, duplicate those
491 /// vertices so faces do not share vertices. The vertex buffer and index
492 /// buffers on submeshes may grow to accomadate any vertices added.
493 #[unsafe(method(makeVerticesUniqueAndReturnError:_))]
494 #[unsafe(method_family = none)]
495 pub unsafe fn makeVerticesUniqueAndReturnError(&self) -> Result<(), Retained<NSError>>;
496
497 /// replace existing attribute data with new attribute data retaining
498 /// the format of the replacement data.
499 ///
500 /// If the specified attribute does not already exist, it will be
501 /// created.
502 #[unsafe(method(replaceAttributeNamed:withData:))]
503 #[unsafe(method_family = none)]
504 pub unsafe fn replaceAttributeNamed_withData(
505 &self,
506 name: &NSString,
507 new_data: &MDLVertexAttributeData,
508 );
509
510 /// update existing attribute data with new attribute data retaining
511 /// the format of the existing data.
512 ///
513 /// If the specified attribute does not already exist, it will be
514 /// created with the same format as the newData.
515 #[unsafe(method(updateAttributeNamed:withData:))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn updateAttributeNamed_withData(
518 &self,
519 name: &NSString,
520 new_data: &MDLVertexAttributeData,
521 );
522
523 /// remove an attribute
524 ///
525 /// if the named attribute does not exist, nothing happens.
526 #[unsafe(method(removeAttributeNamed:))]
527 #[unsafe(method_family = none)]
528 pub unsafe fn removeAttributeNamed(&self, name: &NSString);
529 );
530}
531
532/// Generators.
533#[cfg(feature = "MDLObject")]
534impl MDLMesh {
535 extern_methods!(
536 #[cfg(feature = "MDLMeshBuffer")]
537 /// Factory method that generates a subdivided mesh from a source mesh
538 ///
539 /// Parameter `mesh`: Mesh from which to generate a subdivided mesh
540 ///
541 /// Parameter `submeshIndex`: Index of submesh in Mesh's submesh array from which to
542 /// generate a subdivided mesh
543 ///
544 /// Parameter `subdivisionLevels`: The number of levels to subdivide mesh
545 ///
546 /// Subdivision levels over four are likely to generate more triangles
547 /// than can be reasonably displayed. Index and vertex data will use
548 /// the same allocator used for the source mesh. Loading an asset
549 /// using the topology preservation flag set to YES will result in the
550 /// best subdivision results.
551 ///
552 /// Returns: Returns a mesh subdivided to index level, unless subdivision is
553 /// impossible.
554 #[unsafe(method(initMeshBySubdividingMesh:submeshIndex:subdivisionLevels:allocator:))]
555 #[unsafe(method_family = init)]
556 pub unsafe fn initMeshBySubdividingMesh_submeshIndex_subdivisionLevels_allocator(
557 this: Allocated<Self>,
558 mesh: &MDLMesh,
559 submesh_index: c_int,
560 subdivision_levels: c_uint,
561 allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
562 ) -> Retained<Self>;
563
564 #[cfg(all(feature = "MDLMeshBuffer", feature = "MDLTypes"))]
565 #[unsafe(method(newIcosahedronWithRadius:inwardNormals:geometryType:allocator:))]
566 #[unsafe(method_family = new)]
567 pub unsafe fn newIcosahedronWithRadius_inwardNormals_geometryType_allocator(
568 radius: c_float,
569 inward_normals: bool,
570 geometry_type: MDLGeometryType,
571 allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
572 ) -> Retained<Self>;
573
574 #[cfg(feature = "MDLMeshBuffer")]
575 #[unsafe(method(newIcosahedronWithRadius:inwardNormals:allocator:))]
576 #[unsafe(method_family = new)]
577 pub unsafe fn newIcosahedronWithRadius_inwardNormals_allocator(
578 radius: c_float,
579 inward_normals: bool,
580 allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
581 ) -> Retained<Self>;
582
583 #[unsafe(method(newSubdividedMesh:submeshIndex:subdivisionLevels:))]
584 #[unsafe(method_family = new)]
585 pub unsafe fn newSubdividedMesh_submeshIndex_subdivisionLevels(
586 mesh: &MDLMesh,
587 submesh_index: NSUInteger,
588 subdivision_levels: NSUInteger,
589 ) -> Option<Retained<Self>>;
590 );
591}
592
593/// MDLLightBaking.
594#[cfg(feature = "MDLObject")]
595impl MDLMesh {
596 extern_methods!(
597 /// Creates an Ambient Occlusion texture, returns true upon success, false
598 /// upon failure
599 ///
600 /// Parameter `bakeQuality`: Float between 0 and 1 that defines quality of the bake process.
601 /// 0 is of lower quality but bakes faster and uses less memory, where 1 is
602 /// of higher quality.
603 ///
604 /// Parameter `attenuationFactor`: Float between 0 to 1 that defines how to attenuate the
605 /// AO value. 0 doesn't change it, and at 1, all AO values are white except
606 /// if they are originally completely black. Quadratic attenuation in between.
607 ///
608 /// Parameter `objectsToConsider`: NSArray of MDLMeshes containing the objects to raytrace
609 /// against
610 ///
611 /// Parameter `vertexAttributeName`: NSString of the MDLVertexAttribute where the vertex
612 /// texture UVs will be stored. Creates it if it doesn't exist, otherwise
613 /// overwrites current values.
614 ///
615 /// Parameter `materialPropertyName`: NSString of the MDLMaterialProperty that will store
616 /// the texture in the Mesh.
617 ///
618 /// Returns: Success or failure of the baking process.
619 #[unsafe(method(generateAmbientOcclusionTextureWithQuality:attenuationFactor:objectsToConsider:vertexAttributeNamed:materialPropertyNamed:))]
620 #[unsafe(method_family = none)]
621 pub unsafe fn generateAmbientOcclusionTextureWithQuality_attenuationFactor_objectsToConsider_vertexAttributeNamed_materialPropertyNamed(
622 &self,
623 bake_quality: c_float,
624 attenuation_factor: c_float,
625 objects_to_consider: &NSArray<MDLObject>,
626 vertex_attribute_name: &NSString,
627 material_property_name: &NSString,
628 ) -> bool;
629
630 #[unsafe(method(generateAmbientOcclusionVertexColorsWithRaysPerSample:attenuationFactor:objectsToConsider:vertexAttributeNamed:))]
631 #[unsafe(method_family = none)]
632 pub unsafe fn generateAmbientOcclusionVertexColorsWithRaysPerSample_attenuationFactor_objectsToConsider_vertexAttributeNamed(
633 &self,
634 rays_per_sample: NSInteger,
635 attenuation_factor: c_float,
636 objects_to_consider: &NSArray<MDLObject>,
637 vertex_attribute_name: &NSString,
638 ) -> bool;
639
640 #[unsafe(method(generateAmbientOcclusionVertexColorsWithQuality:attenuationFactor:objectsToConsider:vertexAttributeNamed:))]
641 #[unsafe(method_family = none)]
642 pub unsafe fn generateAmbientOcclusionVertexColorsWithQuality_attenuationFactor_objectsToConsider_vertexAttributeNamed(
643 &self,
644 bake_quality: c_float,
645 attenuation_factor: c_float,
646 objects_to_consider: &NSArray<MDLObject>,
647 vertex_attribute_name: &NSString,
648 ) -> bool;
649
650 #[cfg(feature = "MDLLight")]
651 #[unsafe(method(generateLightMapTextureWithQuality:lightsToConsider:objectsToConsider:vertexAttributeNamed:materialPropertyNamed:))]
652 #[unsafe(method_family = none)]
653 pub unsafe fn generateLightMapTextureWithQuality_lightsToConsider_objectsToConsider_vertexAttributeNamed_materialPropertyNamed(
654 &self,
655 bake_quality: c_float,
656 lights_to_consider: &NSArray<MDLLight>,
657 objects_to_consider: &NSArray<MDLObject>,
658 vertex_attribute_name: &NSString,
659 material_property_name: &NSString,
660 ) -> bool;
661
662 #[cfg(feature = "MDLLight")]
663 #[unsafe(method(generateLightMapVertexColorsWithLightsToConsider:objectsToConsider:vertexAttributeNamed:))]
664 #[unsafe(method_family = none)]
665 pub unsafe fn generateLightMapVertexColorsWithLightsToConsider_objectsToConsider_vertexAttributeNamed(
666 &self,
667 lights_to_consider: &NSArray<MDLLight>,
668 objects_to_consider: &NSArray<MDLObject>,
669 vertex_attribute_name: &NSString,
670 ) -> bool;
671 );
672}