Package apple.modelio

Class MDLMesh

  • All Implemented Interfaces:
    MDLNamed, NSObject

    public class MDLMesh
    extends MDLObject
    MDLMesh A vertex buffer with info to interpret vertex data Includes a collection of submeshs which have indexbuffer and material information
    • Constructor Detail

      • MDLMesh

        protected MDLMesh​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • alloc

        public static MDLMesh alloc()
      • allocWithZone

        public static java.lang.Object allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(java.lang.Object aTarget,
                                                                                 org.moe.natj.objc.SEL aSelector,
                                                                                 java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        public static org.moe.natj.objc.Class classForKeyedUnarchiver()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • hash_static

        public static long hash_static()
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(java.lang.String key)
      • meshWithSCNGeometry

        public static MDLMesh meshWithSCNGeometry​(SCNGeometry scnGeometry)
      • new_objc

        public static java.lang.Object new_objc()
      • newIcosahedronWithRadiusInwardNormalsAllocator

        public static java.lang.Object newIcosahedronWithRadiusInwardNormalsAllocator​(float radius,
                                                                                      boolean inwardNormals,
                                                                                      MDLMeshBufferAllocator allocator)
      • newIcosahedronWithRadiusInwardNormalsGeometryTypeAllocator

        public static java.lang.Object newIcosahedronWithRadiusInwardNormalsGeometryTypeAllocator​(float radius,
                                                                                                  boolean inwardNormals,
                                                                                                  long geometryType,
                                                                                                  MDLMeshBufferAllocator allocator)
      • newSubdividedMeshSubmeshIndexSubdivisionLevels

        public static java.lang.Object newSubdividedMeshSubmeshIndexSubdivisionLevels​(MDLMesh mesh,
                                                                                      long submeshIndex,
                                                                                      long subdivisionLevels)
      • objectWithSCNNode

        public static MDLMesh objectWithSCNNode​(SCNNode scnNode)
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • version_static

        public static long version_static()
      • addAttributeWithNameFormat

        public void addAttributeWithNameFormat​(java.lang.String name,
                                               long format)
        addAttributeWithName:format Convenience method to add an attribute The mesh's allocator will be used to create storage for the new attribute.
      • addAttributeWithNameFormatTypeDataStride

        public void addAttributeWithNameFormatTypeDataStride​(java.lang.String name,
                                                             long format,
                                                             java.lang.String type,
                                                             NSData data,
                                                             long stride)
        addAttributeWithName:format:type:data:stride Create a new vertex attribute including an associated buffer with a copy of the supplied data, and update the vertex descriptor accordingly
        Parameters:
        name - The name the attribute can be found by
        format - Format of the data, such as MDLVertexFormatFloat3
        type - The usage of the attribute, such as MDLVertexAttributePosition
        data - Object containing the data to be used in the new vertex buffer
        stride - The increment in bytes from the start of one data entry to the next.
      • addAttributeWithNameFormatTypeDataStrideTime

        public void addAttributeWithNameFormatTypeDataStrideTime​(java.lang.String name,
                                                                 long format,
                                                                 java.lang.String type,
                                                                 NSData data,
                                                                 long stride,
                                                                 double time)
        addAttributeWithName:format:type:data:stride:time Create a new vertex attribute including an associated buffer with a copy of the supplied data, and update the vertex descriptor accordingly 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.
        Parameters:
        name - The name the attribute can be found by
        format - Format of the data, such as MDLVertexFormatFloat3
        type - The usage of the attribute, such as MDLVertexAttributePosition
        data - Object containing the data to be used in the new vertex buffer
        stride - The increment in bytes from the start of one data entry to the next.
        time - The time the attribute is to be invoked at.
      • addNormalsWithAttributeNamedCreaseThreshold

        public void addNormalsWithAttributeNamedCreaseThreshold​(java.lang.String attributeName,
                                                                float creaseThreshold)
        addNormalsWithAttributeNamed:creaseThreshold: Calculate and add vertex normal data 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.
        Parameters:
        attributeName - Name is the attribute name of vertex normal attribute. If nil, vertex normals will be added with the MDLVertexAttributeNormal name string
        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.
      • addTangentBasisForTextureCoordinateAttributeNamedNormalAttributeNamedTangentAttributeNamed

        public void addTangentBasisForTextureCoordinateAttributeNamedNormalAttributeNamedTangentAttributeNamed​(java.lang.String textureCoordinateAttributeName,
                                                                                                               java.lang.String normalAttributeName,
                                                                                                               java.lang.String tangentAttributeName)
        addTangentBasisForTextureCoordinateAttributeNamed:normalAttributeNamed:tangentAttributeNamed Create tangents which are orthogonal to the normal 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.
        Parameters:
        textureCoordinateAttributeName - texture coordinates to use in calculations
        normalAttributeName - normals to use in calculations
        tangentAttributeName - Name of a four component vertex tangent attribute.
      • addTangentBasisForTextureCoordinateAttributeNamedTangentAttributeNamedBitangentAttributeNamed

        public void addTangentBasisForTextureCoordinateAttributeNamedTangentAttributeNamedBitangentAttributeNamed​(java.lang.String textureCoordinateAttributeName,
                                                                                                                  java.lang.String tangentAttributeName,
                                                                                                                  java.lang.String bitangentAttributeName)
        addTangentBasisForTextureCoordinateAttributeNamed:tangentAttributeNamed:bitangentAttributeNamed Create a shader basis where the tangent and bitangent span the uv -> object space transform 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.
        Parameters:
        textureCoordinateAttributeName - Name of texture coordinates to use in calculations
        tangentAttributeName - Name of vertex tangent attribute.
        bitangentAttributeName - Name of vertex bitangent attribute.
      • addUnwrappedTextureCoordinatesForAttributeNamed

        public void addUnwrappedTextureCoordinatesForAttributeNamed​(java.lang.String textureCoordinateAttributeName)
        addTextureCoordinatesForAttributeNamed:textureCoordinateAttributeName Creates texture coordinates by unwrapping the mesh Uses the attribute named MDLVertexAttributePosition and if available, the attribute named MDLVertexAttributeNormal to calculate texture coordinates
        Parameters:
        textureCoordinateAttributeName - texture coordinates to modify or create
      • allocator

        public MDLMeshBufferAllocator allocator()
        [@property] allocator allocator used to allocate contained mesh buffers
      • generateAmbientOcclusionTextureWithQualityAttenuationFactorObjectsToConsiderVertexAttributeNamedMaterialPropertyNamed

        public boolean generateAmbientOcclusionTextureWithQualityAttenuationFactorObjectsToConsiderVertexAttributeNamedMaterialPropertyNamed​(float bakeQuality,
                                                                                                                                             float attenuationFactor,
                                                                                                                                             NSArray<? extends MDLObject> objectsToConsider,
                                                                                                                                             java.lang.String vertexAttributeName,
                                                                                                                                             java.lang.String materialPropertyName)
        generateAmbientOcclusionTextureWithQuality: Creates an Ambient Occlusion texture, returns true upon success, false upon failure
        Parameters:
        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.
        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.
        objectsToConsider - NSArray of MDLMeshes containing the objects to raytrace against
        vertexAttributeName - NSString of the MDLVertexAttribute where the vertex texture UVs will be stored. Creates it if it doesn't exist, otherwise overwrites current values.
        materialPropertyName - NSString of the MDLMaterialProperty that will store the texture in the Mesh.
        Returns:
        Success or failure of the baking process.
      • generateAmbientOcclusionVertexColorsWithQualityAttenuationFactorObjectsToConsiderVertexAttributeNamed

        public boolean generateAmbientOcclusionVertexColorsWithQualityAttenuationFactorObjectsToConsiderVertexAttributeNamed​(float bakeQuality,
                                                                                                                             float attenuationFactor,
                                                                                                                             NSArray<? extends MDLObject> objectsToConsider,
                                                                                                                             java.lang.String vertexAttributeName)
      • generateAmbientOcclusionVertexColorsWithRaysPerSampleAttenuationFactorObjectsToConsiderVertexAttributeNamed

        public boolean generateAmbientOcclusionVertexColorsWithRaysPerSampleAttenuationFactorObjectsToConsiderVertexAttributeNamed​(long raysPerSample,
                                                                                                                                   float attenuationFactor,
                                                                                                                                   NSArray<? extends MDLObject> objectsToConsider,
                                                                                                                                   java.lang.String vertexAttributeName)
      • generateLightMapTextureWithQualityLightsToConsiderObjectsToConsiderVertexAttributeNamedMaterialPropertyNamed

        public boolean generateLightMapTextureWithQualityLightsToConsiderObjectsToConsiderVertexAttributeNamedMaterialPropertyNamed​(float bakeQuality,
                                                                                                                                    NSArray<? extends MDLLight> lightsToConsider,
                                                                                                                                    NSArray<? extends MDLObject> objectsToConsider,
                                                                                                                                    java.lang.String vertexAttributeName,
                                                                                                                                    java.lang.String materialPropertyName)
      • generateLightMapVertexColorsWithLightsToConsiderObjectsToConsiderVertexAttributeNamed

        public boolean generateLightMapVertexColorsWithLightsToConsiderObjectsToConsiderVertexAttributeNamed​(NSArray<? extends MDLLight> lightsToConsider,
                                                                                                             NSArray<? extends MDLObject> objectsToConsider,
                                                                                                             java.lang.String vertexAttributeName)
      • initMeshBySubdividingMeshSubmeshIndexSubdivisionLevelsAllocator

        public MDLMesh initMeshBySubdividingMeshSubmeshIndexSubdivisionLevelsAllocator​(MDLMesh mesh,
                                                                                       int submeshIndex,
                                                                                       int subdivisionLevels,
                                                                                       MDLMeshBufferAllocator allocator)
        initMeshBySubdividingMesh:submeshIndex:subdivisionLevels:allocator Factory method that generates a subdivided mesh from a source 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.
        Parameters:
        mesh - Mesh from which to generate a subdivided mesh
        submeshIndex - Index of submesh in Mesh's submesh array from which to generate a subdivided mesh
        subdivisionLevels - The number of levels to subdivide mesh
        Returns:
        Returns a mesh subdivided to index level, unless subdivision is impossible.
      • initWithBufferAllocator

        public MDLMesh initWithBufferAllocator​(MDLMeshBufferAllocator bufferAllocator)
        initWithAllocator: Initialize a mesh with an allocator
        Returns:
        An empty mesh
      • initWithVertexBufferVertexCountDescriptorSubmeshes

        public MDLMesh initWithVertexBufferVertexCountDescriptorSubmeshes​(MDLMeshBuffer vertexBuffer,
                                                                          long vertexCount,
                                                                          MDLVertexDescriptor descriptor,
                                                                          NSArray<? extends MDLSubmesh> submeshes)
        initWithVertexBuffer:vertexCount:descriptor:submeshes: Initialize object with a vertex buffer and a collection of submeshes
        Parameters:
        vertexBuffer - MDLMeshBuffer object containing all vertex data for the mesh
        vertexCount - Number of vertices in the vertexBuffer
        descriptor - VertexDescriptor specifying how to interpret vertex data
        submeshes - Array of submeshes with index buffers referencing vertex data and/or materials to be applied to mesh
        Returns:
        Initialized mesh or nil if descriptor's layout array does not describe a single buffer
      • initWithVertexBuffersVertexCountDescriptorSubmeshes

        public MDLMesh initWithVertexBuffersVertexCountDescriptorSubmeshes​(NSArray<?> vertexBuffers,
                                                                           long vertexCount,
                                                                           MDLVertexDescriptor descriptor,
                                                                           NSArray<? extends MDLSubmesh> submeshes)
        initWithVertexBuffer:vertexCount:descriptor:submeshes: Initialize object with an array of vertex buffers (Structure of Arrays) and a collection of submeshes Allows initialization with the layout of the vertexBuffers in a structure-of-arrays form, in other words, non-interleaved vertex attributes
        Parameters:
        vertexCount - Number of vertices in vertexBuffers
        descriptor - VertexDescriptor specifying how to interpret vertex data
        submeshes - Array of submeshes with index buffers referencing vertex data and/or materials to be applied to mesh
        Returns:
        Initialized mesh or nil if descriptor's layout array is incompatible with vertexBuffers array
      • makeVerticesUnique

        public void makeVerticesUnique()
        makeVerticesUnique: 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.
      • removeAttributeNamed

        public void removeAttributeNamed​(java.lang.String name)
        removeAttributeNamed: remove an attribute if the named attribute does not exist, nothing happens.
      • replaceAttributeNamedWithData

        public void replaceAttributeNamedWithData​(java.lang.String name,
                                                  MDLVertexAttributeData newData)
        replaceAttributeNamed:withData 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.
      • setSubmeshes

        public void setSubmeshes​(NSMutableArray<MDLSubmesh> value)
        [@property] submeshes Array of submeshes containing an indexbuffer referencing the vertex data and material to be applied when the mesh is rendered
      • setVertexBuffers

        public void setVertexBuffers​(NSArray<?> value)
        [@property] vertexBuffers Array of buffers containing vertex data The vertex buffers in this array are indexed by the vertex descriptor.
      • setVertexCount

        public void setVertexCount​(long value)
        [@property] vertexCount 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
      • setVertexDescriptor

        public void setVertexDescriptor​(MDLVertexDescriptor value)
        [@property] vertexDescriptor 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.
      • submeshes

        public NSMutableArray<MDLSubmesh> submeshes()
        [@property] submeshes Array of submeshes containing an indexbuffer referencing the vertex data and material to be applied when the mesh is rendered
      • updateAttributeNamedWithData

        public void updateAttributeNamedWithData​(java.lang.String name,
                                                 MDLVertexAttributeData newData)
        updateAttributeNamed:withData 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.
      • vertexAttributeDataForAttributeNamed

        public MDLVertexAttributeData vertexAttributeDataForAttributeNamed​(java.lang.String name)
        vertexAttributeDataForAttributeNamed: convenience selector to get quick access to vertex attribute data the vertex buffer will remain mapped until the MDLVertexAttributeData is freed.
      • vertexAttributeDataForAttributeNamedAsFormat

        public MDLVertexAttributeData vertexAttributeDataForAttributeNamedAsFormat​(java.lang.String name,
                                                                                   long format)
        vertexAttributeDataForAttributeNamed:asFormat 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.
      • vertexBuffers

        public NSArray<?> vertexBuffers()
        [@property] vertexBuffers Array of buffers containing vertex data The vertex buffers in this array are indexed by the vertex descriptor.
      • vertexCount

        public long vertexCount()
        [@property] vertexCount 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
      • vertexDescriptor

        public MDLVertexDescriptor vertexDescriptor()
        [@property] vertexDescriptor 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.
      • addOrthTanBasisForTextureCoordinateAttributeNamedNormalAttributeNamedTangentAttributeNamed

        public void addOrthTanBasisForTextureCoordinateAttributeNamedNormalAttributeNamedTangentAttributeNamed​(java.lang.String textureCoordinateAttributeName,
                                                                                                               java.lang.String normalAttributeName,
                                                                                                               java.lang.String tangentAttributeName)
        addOrthTanBasisForTextureCoordinateAttributeNamed:normalAttributeNamed:tangentAttributeNamed Create an orthonormal tangent basis with tangent specified 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 the bitangent can be calculated from the normal and tangent by B = (N x T) * T.w
        Parameters:
        textureCoordinateAttributeName - texture coordinates to use in calculations
        normalAttributeName - normals to use in calculations
        tangentAttributeName - Name of a three/four component vertex tangent attribute.
      • flipTextureCoordinatesInAttributeNamed

        public void flipTextureCoordinatesInAttributeNamed​(java.lang.String textureCoordinateAttributeName)
        flipTextureCoordinatesInAttributeNamed: Flips texture coordinates by performing the operation (u,v) = (u, 1-v) 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
        Parameters:
        textureCoordinateAttributeName - texture coordinates to modify
      • makeVerticesUniqueAndReturnError

        public boolean makeVerticesUniqueAndReturnError​(org.moe.natj.general.ptr.Ptr<NSError> error)
        makeVerticesUniqueAndReturnError: 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.