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