C# Class Protogame.AssimpReader

Reads a model file using AssImp and converts it to an IModel, which can be used at runtime for rendering, or serialized for storage as an asset.
Mostra file Open project: RedpointGames/Protogame Class Usage Examples

Public Methods

Method Description
AssimpReader ( IModelRenderConfiguration modelRenderConfigurations, IRenderBatcher renderBatcher ) : System
Load ( byte data, string name, string extension, byte[]>.Dictionary rawAdditionalAnimations, string options ) : IModel

Load an FBX file from an array of bytes.

Load ( string filename, string name, string>.Dictionary additionalAnimationFiles, string options ) : IModel

Load an FBX file from a file on disk.

Private Methods

Method Description
BuildBoneWeightingMap ( Assimp.Scene scene ) : Dictionary>

Builds a bone weighting map. A bone weighting map is a map of each vertex to the bone indexes and weightings that apply to it.

This is used to build up the map which is assigned against the vertexes in the model. These bone indices and weightings are then pushed through to the hardware in the BLENDWEIGHTS and BLENDINDICES semantic fields.

BuildStaticTransformMap ( Assimp.Scene scene ) : Matrix>.Dictionary

Builds the static transform map. This is used by vertexes which do not have bones to weight them. When there are no bone weights available, we transform the vertexes based on the scene hierarchy directly on import.

ConvertMaterial ( Assimp m ) : Material
ConvertMaterialColor ( Color4D c ) : Color
ConvertMaterialTexture ( Assimp.TextureSlot t ) : IMaterialTexture
GetStaticTransformMatrixForFirstMesh ( Assimp.Node node ) : Matrix?

Returns the cumulative transformation matrix if the specified node or one of it's descendants specifies the transformation matrix for the first mesh in the scene (the only one that this importer processes).

ImportAnimation ( string name, Assimp assimpAnimation ) : IAnimation

Imports an FBX animation, storing the transformations that apply to each bone at each time.

ImportBoneHierarchy ( Assimp.Node node, Mesh mesh ) : IModelBone

Imports the FBX bone hierarchy of the specified mesh, converting each node in the hierarchy to a model bone.

This function recursively traverses the hierarchy, calling itself each time with a different node argument.

ImportIndices ( Assimp.Scene scene ) : int[]

Imports the mesh indices from the scene.

ImportVertexes ( Assimp.Scene scene, Vector4>.Dictionary boneWeightingMap, Matrix>.Dictionary staticTransformMap ) : Protogame.ModelVertex[]

Imports the mesh vertexes from the scene and adds the appropriate bone weighting data to each vertex.

LoadAssimpLibrary ( ) : void

Loads the AssImp library.

MatrixFromAssImpMatrix ( Matrix4x4 matrix ) : Matrix

Creates a Matrix from an AssImp Matrix4x4.

Method Details

AssimpReader() public method

public AssimpReader ( IModelRenderConfiguration modelRenderConfigurations, IRenderBatcher renderBatcher ) : System
modelRenderConfigurations IModelRenderConfiguration
renderBatcher IRenderBatcher
return System

Load() public method

Load an FBX file from an array of bytes.
public Load ( byte data, string name, string extension, byte[]>.Dictionary rawAdditionalAnimations, string options ) : IModel
data byte /// The byte array containing the FBX data. ///
name string
extension string /// The file extension for raw model data. ///
rawAdditionalAnimations byte[]>.Dictionary /// A dictionary mapping of animation names to byte arrays for additional FBX files to load. ///
options string Additional options for the import.
return IModel

Load() public method

Load an FBX file from a file on disk.
public Load ( string filename, string name, string>.Dictionary additionalAnimationFiles, string options ) : IModel
filename string /// The filename of the FBX file to load. ///
name string
additionalAnimationFiles string>.Dictionary /// A dictionary mapping of animation names to filenames for additional FBX files to load. ///
options string Additional options for the import.
return IModel