AssimpImporter Class Reference

Inherits from NSObject
Declared in AssimpImporter.h
AssimpImporter.m

Overview

An importer that imports the files with formats supported by Assimp and converts the assimp scene graph into a scenekit scene graph.

Creating an importer

– init

Creates an importer to import files supported by AssimpKit.

- (id)init

Return Value

A new importer.

Discussion

Creates an importer to import files supported by AssimpKit.

Declared In

AssimpImporter.h

– importScene:postProcessFlags:

Loads a scene from the specified file path.

- (SCNAssimpScene *)importScene:(NSString *)filePath postProcessFlags:(AssimpKitPostProcessSteps)postProcessFlags

Parameters

filePath

The path to the scene file to load.

postProcessFlags

The flags for all possible post processing steps.

Return Value

A new scene object, or nil if no scene could be loaded.

Discussion

Loads a scene from the specified file path.

Declared In

AssimpImporter.h

Make scenekit scene

– makeSCNSceneFromAssimpScene:atPath:

Creates a scenekit scene from the scene representing the file at a given path.

- (SCNAssimpScene *)makeSCNSceneFromAssimpScene:(const struct aiScene *)aiScene atPath:(NSString *)path

Parameters

aiScene

The assimp scene.

path

The path to the scene file to load.

Return Value

A new scene object.

Discussion

Creates a scenekit scene from the scene representing the file at a given path.

Declared In

AssimpImporter.m

Make a scenekit node

– makeSCNNodeFromAssimpNode:inScene:atPath:

Creates a new scenekit node from the assimp scene node

- (SCNNode *)makeSCNNodeFromAssimpNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene atPath:(NSString *)path

Parameters

aiNode

The assimp scene node.

aiScene

The assimp scene.

path

The path to the scene file to load.

Return Value

A new scene node.

Discussion

Creates a new scenekit node from the assimp scene node

Declared In

AssimpImporter.m

Find the number of vertices, faces and indices of a geometry

– findNumVerticesInNode:inScene:

Finds the total number of vertices in the meshes of the specified node.

- (int)findNumVerticesInNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp scene node.

aiScene

The assimp scene.

Return Value

The number of vertices.

Discussion

Finds the total number of vertices in the meshes of the specified node.

Declared In

AssimpImporter.m

– findNumFacesInNode:inScene:

Finds the total number of faces in the meshes of the specified node.

- (int)findNumFacesInNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp scene node.

aiScene

The assimp scene.

Return Value

The number of faces.

Discussion

Finds the total number of faces in the meshes of the specified node.

Declared In

AssimpImporter.m

– findNumIndicesInMesh:inScene:

Finds the total number of indices in the specified mesh by index.

- (int)findNumIndicesInMesh:(int)aiMeshIndex inScene:(const struct aiScene *)aiScene

Parameters

aiMeshIndex

The assimp mesh index.

aiScene

The assimp scene.

Return Value

The total number of indices.

Discussion

Finds the total number of indices in the specified mesh by index.

Declared In

AssimpImporter.m

Make scenekit geometry sources

– makeVertexGeometrySourceForNode:inScene:withNVertices:

Creates a scenekit geometry source from the vertices of the specified node.

- (SCNGeometrySource *)makeVertexGeometrySourceForNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withNVertices:(int)nVertices

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

nVertices

The total number of vertices in the meshes of the aiNode.

Return Value

A new geometry source whose semantic property is vertex.

Discussion

Creates a scenekit geometry source from the vertices of the specified node.

Declared In

AssimpImporter.m

– makeNormalGeometrySourceForNode:inScene:withNVertices:

Creates a scenekit geometry source from the normals of the specified node.

- (SCNGeometrySource *)makeNormalGeometrySourceForNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withNVertices:(int)nVertices

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

nVertices

The number of vertices in the meshes of the aiNode.

Return Value

A new geometry source whose semantic property is normal.

Discussion

Creates a scenekit geometry source from the normals of the specified node.

Declared In

AssimpImporter.m

– makeTangentGeometrySourceForNode:inScene:withNVertices:

Creates a scenekit geometry source from the tangents of the specified node.

- (SCNGeometrySource *)makeTangentGeometrySourceForNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withNVertices:(int)nVertices

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

nVertices

The number of vertices in the meshes of the aiNode.

Return Value

A new geometry source whose semantic property is tangent.

Discussion

Creates a scenekit geometry source from the tangents of the specified node.

Declared In

AssimpImporter.m

– makeTextureGeometrySourceForNode:inScene:withNVertices:

Creates a scenekit geometry source from the texture coordinates of the specified node.

- (SCNGeometrySource *)makeTextureGeometrySourceForNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withNVertices:(int)nVertices

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

nVertices

The number of vertices in the meshes of the node.

Return Value

A new geometry source whose semantic property is texcoord.

Discussion

Creates a scenekit geometry source from the texture coordinates of the specified node.

Declared In

AssimpImporter.m

– makeGeometrySourcesForNode:inScene:withVertices:

Creates an array of geometry sources for the specifed node describing the vertices in the geometry and their attributes.

- (NSArray *)makeGeometrySourcesForNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withVertices:(int)nVertices

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

nVertices

The number of vertices in the meshes of the node.

Return Value

An array of geometry sources.

Discussion

Creates an array of geometry sources for the specifed node describing the vertices in the geometry and their attributes.

Declared In

AssimpImporter.m

Make scenekit geometry elements

– makeIndicesGeometryElementForMeshIndex:inNode:inScene:withIndexOffset:nFaces:

Creates a scenekit geometry element describing how vertices connect to define a three-dimensional object, or geometry for the specified mesh of a node.

- (SCNGeometryElement *)makeIndicesGeometryElementForMeshIndex:(int)aiMeshIndex inNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withIndexOffset:(short)indexOffset nFaces:(int)nFaces

Parameters

aiMeshIndex

The assimp mesh index.

aiNode

The assimp node of the mesh.

aiScene

The assimp scene.

indexOffset

The total number of indices for the previous meshes.

nFaces

The number of faces in the geometry of the mesh.

Return Value

A new geometry element object.

Discussion

Creates a scenekit geometry element describing how vertices connect to define a three-dimensional object, or geometry for the specified mesh of a node.

Declared In

AssimpImporter.m

– makeGeometryElementsforNode:inScene:

Creates an array of scenekit geometry element obejcts describing how to connect the geometry’s vertices of the specified node.

- (NSArray *)makeGeometryElementsforNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

Return Value

An array of geometry elements.

Discussion

Creates an array of scenekit geometry element obejcts describing how to connect the geometry’s vertices of the specified node.

Declared In

AssimpImporter.m

Make scenekit materials

– makeMaterialPropertyForMaterial:withTextureInfo:withSCNMaterial:atPath:

Updates a scenekit material property with the texture file path or the color if no texture is specifed.

- (void)makeMaterialPropertyForMaterial:(const struct aiMaterial *)aiMaterial withTextureInfo:(SCNTextureInfo *)textureInfo withSCNMaterial:(SCNMaterial *)material atPath:(NSString *)path

Parameters

aiMaterial

The assimp material.

textureInfo

The metadata of the texture.

material

The scenekit material.

path

The path to the scene file to load.

Discussion

Updates a scenekit material property with the texture file path or the color if no texture is specifed.

Declared In

AssimpImporter.m

– applyMultiplyPropertyForMaterial:withSCNMaterial:

Updates a scenekit material’s multiply property

- (void)applyMultiplyPropertyForMaterial:(const struct aiMaterial *)aiMaterial withSCNMaterial:(SCNMaterial *)material

Parameters

aiMaterial

The assimp material

material

The scenekit material.

Discussion

Updates a scenekit material’s multiply property

Declared In

AssimpImporter.m

– makeMaterialsForNode:inScene:atPath:

Creates an array of scenekit materials one for each mesh of the specified node.

- (NSMutableArray *)makeMaterialsForNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene atPath:(NSString *)path

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

path

The path to the scene file to load.

Return Value

An array of scenekit materials.

Discussion

Creates an array of scenekit materials one for each mesh of the specified node.

Declared In

AssimpImporter.m

– makeSCNGeometryFromAssimpNode:inScene:withVertices:atPath:

Creates a scenekit geometry to attach at the specified node.

- (SCNGeometry *)makeSCNGeometryFromAssimpNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withVertices:(int)nVertices atPath:(NSString *)path

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

nVertices

The total number of vertices in the meshes of the node.

path

The path to the scene file to load.

Return Value

A new geometry.

Discussion

Creates a scenekit geometry to attach at the specified node.

Declared In

AssimpImporter.m

Make scenekit lights

– makeSCNLightTypeDirectionalForAssimpLight:

Creates a scenekit directional light from an assimp directional light.

- (SCNLight *)makeSCNLightTypeDirectionalForAssimpLight:(const struct aiLight *)aiLight

Parameters

aiLight

The assimp directional light.

Return Value

A new scenekit directional light.

Discussion

Creates a scenekit directional light from an assimp directional light.

Declared In

AssimpImporter.m

– makeSCNLightTypePointForAssimpLight:

Creates a scenekit omni light from an assimp omni light.

- (SCNLight *)makeSCNLightTypePointForAssimpLight:(const struct aiLight *)aiLight

Parameters

aiLight

The assimp omni light.

Return Value

A new scenekit omni light.

Discussion

Creates a scenekit omni light from an assimp omni light.

Declared In

AssimpImporter.m

– makeSCNLightTypeSpotForAssimpLight:

Creates a scenekit spot light from an assimp spot light.

- (SCNLight *)makeSCNLightTypeSpotForAssimpLight:(const struct aiLight *)aiLight

Parameters

aiLight

The assimp spot light.

Return Value

A new scenekit spot light.

Discussion

Creates a scenekit spot light from an assimp spot light.

Declared In

AssimpImporter.m

– makeSCNLightFromAssimpNode:inScene:

Creates a scenekit light to attach at the specified node.

- (SCNLight *)makeSCNLightFromAssimpNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

Return Value

A new scenekit light.

Discussion

Creates a scenekit light to attach at the specified node.

Declared In

AssimpImporter.m

Make scenekit cameras

– makeSCNCameraFromAssimpNode:inScene:

Creates a scenekit camera to attach at the specified node.

- (SCNCamera *)makeSCNCameraFromAssimpNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

Return Value

A new scenekit camera.

Discussion

Creates a scenekit camera to attach at the specified node.

Declared In

AssimpImporter.m

Make scenekit skinner

– findNumBonesInNode:inScene:

Finds the number of bones in the meshes of the specified node.

- (int)findNumBonesInNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

Return Value

The number of bones.

Discussion

Finds the number of bones in the meshes of the specified node.

Declared In

AssimpImporter.m

– getBoneNamesForAssimpNode:inScene:

Creates an array of bone names in the meshes of the specified node.

- (NSArray *)getBoneNamesForAssimpNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

Return Value

An array of bone names.

Discussion

Creates an array of bone names in the meshes of the specified node.

Declared In

AssimpImporter.m

– getBoneTransformsForAssimpNode:inScene:

Creates a dictionary of bone transforms where bone name is the key, for the meshes of the specified node.

- (NSDictionary *)getBoneTransformsForAssimpNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

Return Value

A dictionary of bone transforms where bone name is the key.

Discussion

Creates a dictionary of bone transforms where bone name is the key, for the meshes of the specified node.

Declared In

AssimpImporter.m

– getTransformsForBones:fromTransforms:

Creates an array of bone transforms from a dictionary of bone transforms where bone name is the key.

- (NSArray *)getTransformsForBones:(NSArray *)boneNames fromTransforms:(NSDictionary *)boneTransforms

Parameters

boneNames

The array of bone names.

boneTransforms

The dictionary of bone transforms.

Return Value

An array of bone transforms

Discussion

Creates an array of bone transforms from a dictionary of bone transforms where bone name is the key.

Declared In

AssimpImporter.m

– findBoneNodesInScene:forBones:

Creates an array of scenekit bone nodes for the specified bone names.

- (NSArray *)findBoneNodesInScene:(SCNScene *)scene forBones:(NSArray *)boneNames

Parameters

scene

The scenekit scene.

boneNames

The array of bone names.

Return Value

An array of scenekit bone nodes.

Discussion

Creates an array of scenekit bone nodes for the specified bone names.

Declared In

AssimpImporter.m

– findSkeletonNodeFromBoneNodes:

Find the root node of the skeleton from the specified bone nodes.

- (SCNNode *)findSkeletonNodeFromBoneNodes:(NSArray *)boneNodes

Parameters

boneNodes

The array of bone nodes.

Return Value

The root node of the skeleton.

Discussion

Find the root node of the skeleton from the specified bone nodes.

Declared In

AssimpImporter.m

– findDepthOfNodeFromRoot:

Finds the depth of the specified node from the scene’s root node.

- (int)findDepthOfNodeFromRoot:(SCNNode *)node

Parameters

node

The scene node.

Return Value

The depth from the scene’s root node.

Discussion

Finds the depth of the specified node from the scene’s root node.

Declared In

AssimpImporter.m

– findMaxWeightsForNode:inScene:

Finds the maximum number of weights that influence the vertices in the meshes of the specified node.

- (int)findMaxWeightsForNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

Return Value

The maximum influences or weights.

Discussion

Finds the maximum number of weights that influence the vertices in the meshes of the specified node.

Declared In

AssimpImporter.m

– makeBoneWeightsGeometrySourceAtNode:inScene:withVertices:maxWeights:

Creates a scenekit geometry source defining the influence of each bone on the positions of vertices in the geometry

- (SCNGeometrySource *)makeBoneWeightsGeometrySourceAtNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withVertices:(int)nVertices maxWeights:(int)maxWeights

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

nVertices

The number of vertices in the meshes of the node.

maxWeights

The maximum number of weights influencing each vertex.

Return Value

A new geometry source whose semantic property is boneWeights.

Discussion

Creates a scenekit geometry source defining the influence of each bone on the positions of vertices in the geometry

Declared In

AssimpImporter.m

– makeBoneIndicesGeometrySourceAtNode:inScene:withVertices:maxWeights:boneNames:

Creates a scenekit geometry source defining the mapping from bone indices in skeleton data to the skinner’s bones array

- (SCNGeometrySource *)makeBoneIndicesGeometrySourceAtNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene withVertices:(int)nVertices maxWeights:(int)maxWeights boneNames:(NSArray *)boneNames

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

nVertices

The number of vertices in the meshes of the node.

maxWeights

The maximum number of weights influencing each vertex.

boneNames

The array of unique bone names.

Return Value

A new geometry source whose semantic property is boneIndices.

Discussion

Creates a scenekit geometry source defining the mapping from bone indices in skeleton data to the skinner’s bones array

Declared In

AssimpImporter.m

– buildSkeletonDatabaseForScene:

Builds a skeleton database of unique bone names and inverse bind bone transforms.

- (void)buildSkeletonDatabaseForScene:(SCNAssimpScene *)scene

Parameters

scene

The scenekit scene.

Discussion

Builds a skeleton database of unique bone names and inverse bind bone transforms.

When the scenekit scene is created from the assimp scene, a list of all bone names and a dictionary of bone transforms where each key is the bone name, is generated when parsing each node of the assimp scene.

Declared In

AssimpImporter.m

– makeSkinnerForAssimpNode:inScene:scnScene:

Creates a scenekit skinner for the specified node with visible geometry and skeleton information.

- (void)makeSkinnerForAssimpNode:(const struct aiNode *)aiNode inScene:(const struct aiScene *)aiScene scnScene:(SCNScene *)scene

Parameters

aiNode

The assimp node.

aiScene

The assimp scene.

scene

The scenekit scene.

Discussion

Creates a scenekit skinner for the specified node with visible geometry and skeleton information.

Declared In

AssimpImporter.m

Make scenekit animations

– createAnimationsFromScene:withScene:atPath:

Creates a dictionary of animations where each animation is a SCNAssimpAnimation, from each animation in the assimp scene.

- (void)createAnimationsFromScene:(const struct aiScene *)aiScene withScene:(SCNAssimpScene *)scene atPath:(NSString *)path

Parameters

aiScene

The assimp scene.

scene

The scenekit scene.

path

The path to the scene file to load.

Discussion

Creates a dictionary of animations where each animation is a SCNAssimpAnimation, from each animation in the assimp scene.

For each animation’s channel which is a bone node, a CAKeyframeAnimation is created for each of position, orientation and scale. These animations are then stored in an SCNAssimpAnimation object, which holds the animation name and the keyframe animations.

The animation name is generated by appending the file name with an animation index. The example of an animation name is walk-1 for the first animation in a file named walk.

Declared In

AssimpImporter.m

Extension Methods

  boneNames

The array of bone names across all meshes in all nodes.

@property (readwrite, nonatomic) NSMutableArray *boneNames

Discussion

The array of bone names across all meshes in all nodes.

Declared In

AssimpImporter.m

  uniqueBoneNames

The array of unique bone names across all meshes in all nodes.

@property (readwrite, nonatomic) NSArray *uniqueBoneNames

Discussion

The array of unique bone names across all meshes in all nodes.

Declared In

AssimpImporter.m

  uniqueBoneNodes

The array of unique bone nodes across all meshes in all nodes.

@property (readwrite, nonatomic) NSArray *uniqueBoneNodes

Discussion

The array of unique bone nodes across all meshes in all nodes.

Declared In

AssimpImporter.m

  boneTransforms

The dictionary of bone inverse bind transforms, where key is the bone name.

@property (readwrite, nonatomic) NSMutableDictionary *boneTransforms

Discussion

The dictionary of bone inverse bind transforms, where key is the bone name.

Declared In

AssimpImporter.m

  uniqueBoneTransforms

The array of unique bone transforms for all unique bone nodes.

@property (readwrite, nonatomic) NSArray *uniqueBoneTransforms

Discussion

The array of unique bone transforms for all unique bone nodes.

Declared In

AssimpImporter.m

  skeleton

The root node of the skeleton in the scene.

@property (readwrite, nonatomic) SCNNode *skeleton

Discussion

The root node of the skeleton in the scene.

Declared In

AssimpImporter.m