Assimp
v3.1.1 (June 2014)
|
Class to load MDL files. More...
Inherits Assimp::BaseImporter.
Inherited by Assimp::HMPImporter.
Public Member Functions | |
bool | CanRead (const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const |
Returns whether the class can handle the format of the given file. More... | |
MDLImporter () | |
void | SetupProperties (const Importer *pImp) |
Called prior to ReadFile(). More... | |
~MDLImporter () | |
![]() | |
BaseImporter () | |
Constructor to be privately used by Importer. More... | |
const std::string & | GetErrorText () const |
Returns the error description of the last error that occurred. More... | |
void | GetExtensionList (std::set< std::string > &extensions) |
Called by #Importer::GetExtensionList for each loaded importer. More... | |
aiScene * | ReadFile (const Importer *pImp, const std::string &pFile, IOSystem *pIOHandler) |
Imports the given file and returns the imported data. More... | |
virtual | ~BaseImporter () |
Destructor, private as well. More... | |
Protected Member Functions | |
void | AddAnimationBoneTrafoKey_3DGS_MDL7 (unsigned int iTrafo, const MDL::BoneTransform_MDL7 *pcBoneTransforms, MDL::IntBone_MDL7 **apcBonesOut) |
Add a bone transformation key to an animation. More... | |
void | AddBonesToNodeGraph_3DGS_MDL7 (const MDL::IntBone_MDL7 **apcBonesOut, aiNode *pcParent, uint16_t iParentIndex) |
Add all bones to the nodegraph (as children of the root node) More... | |
void | BuildOutputAnims_3DGS_MDL7 (const MDL::IntBone_MDL7 **apcBonesOut) |
Build output animations. More... | |
void | CalcAbsBoneMatrices_3DGS_MDL7 (MDL::IntBone_MDL7 **apcOutBones) |
Calculate absolute bone animation matrices for each bone. More... | |
void | CalculateUVCoordinates_MDL5 () |
Converts the absolute texture coordinates in MDL5 files to relative in a range between 0 and 1. More... | |
void | CopyMaterials_3DGS_MDL7 (MDL::IntSharedData_MDL7 &shared) |
Copies only the material that are referenced by at least one mesh to the final output material list. More... | |
void | CreateTexture_3DGS_MDL4 (const unsigned char *szData, unsigned int iType, unsigned int *piSkip) |
Used to load textures from MDL3/4. More... | |
void | CreateTexture_3DGS_MDL5 (const unsigned char *szData, unsigned int iType, unsigned int *piSkip) |
Used to load textures from MDL5. More... | |
void | CreateTextureARGB8_3DGS_MDL3 (const unsigned char *szData) |
Load a paletized texture from the file and convert it to 32bpp. More... | |
void | FreePalette (const unsigned char *pszColorMap) |
Free a palette created with a previous call to SearchPalette() More... | |
void | GenerateOutputMeshes_3DGS_MDL7 (MDL::IntGroupData_MDL7 &groupData, MDL::IntSplitGroupData_MDL7 &splitGroupData) |
Generate the final output meshes for a7 models. More... | |
const aiImporterDesc * | GetInfo () const |
Return importer meta information. More... | |
void | HandleMaterialReferences_3DGS_MDL7 () |
Handles materials that are just referencing another material There is no test file for this feature, but Conitec's doc say it is used. More... | |
void | ImportUVCoordinate_3DGS_MDL345 (aiVector3D &vOut, const MDL::TexCoord_MDL3 *pcSrc, unsigned int iIndex) |
Read an UV coordinate from the file. More... | |
void | InternReadFile (const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) |
Imports the given file into the given scene structure. More... | |
void | InternReadFile_3DGS_MDL345 () |
Import a GameStudio A4/A5 file (MDL 3,4,5) More... | |
void | InternReadFile_3DGS_MDL7 () |
Import a GameStudio A7 file (MDL 7) More... | |
void | InternReadFile_HL2 () |
Import a CS:S/HL2 MDL file (not fully implemented) More... | |
void | InternReadFile_Quake1 () |
Import a quake 1 MDL file (IDPO) More... | |
void | JoinSkins_3DGS_MDL7 (aiMaterial *pcMat1, aiMaterial *pcMat2, aiMaterial *pcMatOut) |
Join two materials / skins. More... | |
MDL::IntBone_MDL7 ** | LoadBones_3DGS_MDL7 () |
Load the bone list of a MDL7 file. More... | |
void | ParseBoneTrafoKeys_3DGS_MDL7 (const MDL::IntGroupInfo_MDL7 &groupInfo, IntFrameInfo_MDL7 &frame, MDL::IntSharedData_MDL7 &shared) |
Load bone transformation keyframes from a file chunk. More... | |
void | ParseSkinLump_3DGS_MDL7 (const unsigned char *szCurrent, const unsigned char **szCurrentOut, std::vector< aiMaterial *> &pcMats) |
Parse a skin lump in a MDL7/HMP7 file with all of its features variant 1: Current cursor position is the beginning of the skin header. More... | |
void | ParseSkinLump_3DGS_MDL7 (const unsigned char *szCurrent, const unsigned char **szCurrentOut, aiMaterial *pcMatOut, unsigned int iType, unsigned int iWidth, unsigned int iHeight) |
Parse a skin lump in a MDL7/HMP7 file with all of its features variant 2: Current cursor position is the beginning of the skin data. More... | |
void | ParseTextureColorData (const unsigned char *szData, unsigned int iType, unsigned int *piSkip, aiTexture *pcNew) |
Parse texture color data for MDL5, MDL6 and MDL7 formats. More... | |
bool | ProcessFrames_3DGS_MDL7 (const MDL::IntGroupInfo_MDL7 &groupInfo, MDL::IntGroupData_MDL7 &groupData, MDL::IntSharedData_MDL7 &shared, const unsigned char *szCurrent, const unsigned char **szCurrentOut) |
Process the frame section at the end of a group. More... | |
void | ReadFaces_3DGS_MDL7 (const MDL::IntGroupInfo_MDL7 &groupInfo, MDL::IntGroupData_MDL7 &groupData) |
Read all faces and vertices from a MDL7 group. More... | |
aiColor4D | ReplaceTextureWithColor (const aiTexture *pcTexture) |
Checks whether a texture can be replaced with a single color This is useful for all file formats before MDL7 (all those that are not containing material colors separate from textures). More... | |
void | SearchPalette (const unsigned char **pszColorMap) |
Try to load a palette from the current directory (colormap.lmp) If it is not found the default palette of Quake1 is returned. More... | |
void | SetupMaterialProperties_3DGS_MDL5_Quake1 () |
Setup the material properties for Quake and MDL<7 models. More... | |
void | SizeCheck (const void *szPos) |
Check whether a given position is inside the valid range Throw a DeadlyImportError if it is not. More... | |
void | SizeCheck (const void *szPos, const char *szFile, unsigned int iLine) |
void | SkipSkinLump_3DGS_MDL7 (const unsigned char *szCurrent, const unsigned char **szCurrentOut, unsigned int iType, unsigned int iWidth, unsigned int iHeight) |
Skip a skin lump in a MDL7/HMP7 file. More... | |
void | SortByMaterials_3DGS_MDL7 (const MDL::IntGroupInfo_MDL7 &groupInfo, MDL::IntGroupData_MDL7 &groupData, MDL::IntSplitGroupData_MDL7 &splitGroupData) |
Sort all faces by their materials. More... | |
void | ValidateHeader_3DGS_MDL7 (const MDL::Header_MDL7 *pcHeader) |
Validate the header data structure of a game studio MDL7 file. More... | |
void | ValidateHeader_Quake1 (const MDL::Header *pcHeader) |
Validate the header data structure of a Quake 1 model. More... | |
Protected Attributes | |
unsigned int | configFrameID |
Configuration option: frame to be loaded. More... | |
std::string | configPalette |
Configuration option: palette to be used to decode palletized images. More... | |
unsigned int | iFileSize |
Size of the input file in bytes. More... | |
unsigned int | iGSFileVersion |
For GameStudio MDL files: The number in the magic word, either 3,4 or 5 (MDL7 doesn't need this, the format has a separate loader) More... | |
unsigned char * | mBuffer |
Buffer to hold the loaded file. More... | |
IOSystem * | pIOHandler |
Output I/O handler. More... | |
aiScene * | pScene |
Output scene to be filled. More... | |
![]() | |
std::string | m_ErrorText |
Error description in case there was one. More... | |
ProgressHandler * | m_progress |
Currently set progress handler. More... | |
Additional Inherited Members | |
![]() | |
enum | TextFileMode { ALLOW_EMPTY, FORBID_EMPTY } |
Enum to define, if empty files are ok or not. More... | |
![]() | |
static bool | CheckMagicToken (IOSystem *pIOHandler, const std::string &pFile, const void *magic, unsigned int num, unsigned int offset=0, unsigned int size=4) |
Check whether a file starts with one or more magic tokens. More... | |
static void | ConvertToUTF8 (std::vector< char > &data) |
An utility for all text file loaders. More... | |
static void | ConvertUTF8toISO8859_1 (std::string &data) |
An utility for all text file loaders. More... | |
template<typename T > | |
static AI_FORCE_INLINE void | CopyVector (std::vector< T > &vec, T *&out, unsigned int &outLength) |
Utility function to move a std::vector into a aiScene array. More... | |
static std::string | GetExtension (const std::string &pFile) |
Extract file extension from a string. More... | |
static bool | SearchFileHeaderForToken (IOSystem *pIOSystem, const std::string &file, const char **tokens, unsigned int numTokens, unsigned int searchBytes=200, bool tokensSol=false) |
A utility for CanRead(). More... | |
static bool | SimpleExtensionCheck (const std::string &pFile, const char *ext0, const char *ext1=NULL, const char *ext2=NULL) |
Check whether a file has a specific file extension. More... | |
static void | TextFileToBuffer (IOStream *stream, std::vector< char > &data, TextFileMode mode=FORBID_EMPTY) |
Utility for text file loaders which copies the contents of the file into a memory buffer and converts it to our UTF8 representation. More... | |
Class to load MDL files.
Several subformats exist:
These formats are partially identical and it would be possible to load them all with a single 1000-line function-beast. However, it has been split into several code paths to make the code easier to read and maintain.
MDLImporter::MDLImporter | ( | ) |
MDLImporter::~MDLImporter | ( | ) |
|
protected |
Add a bone transformation key to an animation.
iTrafo | Index of the transformation (always==frame index?) No need to validate this index, it is always valid. |
pcBoneTransforms | Bone transformation for this index |
apcOutBones | Output bones array |
|
protected |
Add all bones to the nodegraph (as children of the root node)
apcBonesOut | List of bones |
pcParent | Parent node. New nodes will be added to this node |
iParentIndex | Index of the parent bone |
|
protected |
Build output animations.
apcBonesOut | List of bones |
|
protected |
Calculate absolute bone animation matrices for each bone.
apcOutBones | Output bones array |
|
protected |
Converts the absolute texture coordinates in MDL5 files to relative in a range between 0 and 1.
|
virtual |
Returns whether the class can handle the format of the given file.
See BaseImporter::CanRead() for details.
Implements Assimp::BaseImporter.
|
protected |
Copies only the material that are referenced by at least one mesh to the final output material list.
All other materials will be discarded.
shared | -> doc of data structure |
|
protected |
Used to load textures from MDL3/4.
szData | Input data |
iType | Color data type |
piSkip | Receive: Size to skip, in bytes |
|
protected |
Used to load textures from MDL5.
szData | Input data |
iType | Color data type |
piSkip | Receive: Size to skip, in bytes |
|
protected |
Load a paletized texture from the file and convert it to 32bpp.
|
protected |
Free a palette created with a previous call to SearchPalette()
|
protected |
Generate the final output meshes for a7 models.
groupData | -> doc of data structure |
splitGroupData | -> doc of data structure |
|
protectedvirtual |
Return importer meta information.
See #BaseImporter::GetInfo for the details
Implements Assimp::BaseImporter.
|
protected |
Handles materials that are just referencing another material There is no test file for this feature, but Conitec's doc say it is used.
|
protected |
Read an UV coordinate from the file.
If the file format is not MDL5, the function calculates relative texture coordinates
vOut | Receives the output UV coord |
pcSrc | UV coordinate buffer |
UV | coordinate index |
|
protectedvirtual |
Imports the given file into the given scene structure.
See BaseImporter::InternReadFile() for details
Implements Assimp::BaseImporter.
|
protected |
Import a GameStudio A4/A5 file (MDL 3,4,5)
|
protected |
Import a GameStudio A7 file (MDL 7)
|
protected |
Import a CS:S/HL2 MDL file (not fully implemented)
|
protected |
Import a quake 1 MDL file (IDPO)
|
protected |
Join two materials / skins.
Setup UV source ... etc
pcMat1 | First input material |
pcMat2 | Second input material |
pcMatOut | Output material instance to be filled. Must be empty |
|
protected |
Load the bone list of a MDL7 file.
|
protected |
Load bone transformation keyframes from a file chunk.
groupInfo | -> doc of data structure |
frame | -> doc of data structure |
shared | -> doc of data structure |
|
protected |
Parse a skin lump in a MDL7/HMP7 file with all of its features variant 1: Current cursor position is the beginning of the skin header.
szCurrent | Current data pointer |
szCurrentOut | Output data pointer |
pcMats | Material list for this group. To be filled ... |
|
protected |
Parse a skin lump in a MDL7/HMP7 file with all of its features variant 2: Current cursor position is the beginning of the skin data.
szCurrent | Current data pointer |
szCurrentOut | Output data pointer |
pcMatOut | Output material |
iType | header.typ |
iWidth | header.width |
iHeight | header.height |
|
protected |
Parse texture color data for MDL5, MDL6 and MDL7 formats.
szData | Current data pointer |
iType | type of the texture data. No DDS or external |
piSkip | Receive the number of bytes to skip |
pcNew | Must point to fully initialized data. Width and height must be set. If pcNew->pcData is set to UINT_MAX, piSkip will receive the size of the texture, in bytes, but no color data will be read. |
|
protected |
Process the frame section at the end of a group.
groupInfo | -> doc of data structure |
shared | -> doc of data structure |
szCurrent | Pointer to the start of the frame section |
szCurrentOut | Receives a pointer to the first byte of the next data section. |
|
protected |
Read all faces and vertices from a MDL7 group.
The function fills preallocated memory buffers.
groupInfo | -> doc of data structure |
groupData | -> doc of data structure |
Checks whether a texture can be replaced with a single color This is useful for all file formats before MDL7 (all those that are not containing material colors separate from textures).
MED seems to write dummy 8x8 monochrome images instead.
pcTexture | Input texture |
|
protected |
Try to load a palette from the current directory (colormap.lmp) If it is not found the default palette of Quake1 is returned.
|
protected |
Setup the material properties for Quake and MDL<7 models.
These formats don't support more than one material per mesh, therefore the method processes only ONE skin and removes all others.
|
virtual |
Called prior to ReadFile().
The function is a request to the importer to update its configuration basing on the Importer's configuration property list.
Reimplemented from Assimp::BaseImporter.
|
protected |
Check whether a given position is inside the valid range Throw a DeadlyImportError if it is not.
szPos | Cursor position |
szFile | Name of the source file from which the function was called |
iLine | Source code line from which the function was called |
|
protected |
|
protected |
Skip a skin lump in a MDL7/HMP7 file.
szCurrent | Current data pointer |
szCurrentOut | Output data pointer. Points to the byte just behind the last byte of the skin. |
iType | header.typ |
iWidth | header.width |
iHeight | header.height |
|
protected |
Sort all faces by their materials.
If the mesh is using multiple materials per face (that are blended together) the function might create new materials.
groupInfo | -> doc of data structure |
groupData | -> doc of data structure |
splitGroupData | -> doc of data structure |
|
protected |
Validate the header data structure of a game studio MDL7 file.
pcHeader | Input header to be validated |
|
protected |
Validate the header data structure of a Quake 1 model.
pcHeader | Input header to be validated |
|
protected |
Configuration option: frame to be loaded.
|
protected |
Configuration option: palette to be used to decode palletized images.
|
protected |
Size of the input file in bytes.
|
protected |
For GameStudio MDL files: The number in the magic word, either 3,4 or 5 (MDL7 doesn't need this, the format has a separate loader)
|
protected |
Buffer to hold the loaded file.
|
protected |
Output I/O handler.
used to load external lmp files
|
protected |
Output scene to be filled.