-
Notifications
You must be signed in to change notification settings - Fork 36
Home
directX import addon for blender
goal is simple : import everything from an .x file into Blender 2.6
meshes + mesh stuffs and armatures are imported, next main step is about importing animation (features details below). I would need more .x files for further tests !
the readme provides current, accurate info this article is a summary of the readme
to use it :
- open this : https://github.com/littleneo/directX_blender/zipball/master
- from the archive copy the 'bel' folder in /scripts/modules
- copy the 'io_directx_bel' folder in /scripts/addons
- start blender
- enable the addon in user prefs > addons (directx Importer)
- run the script with file > import > directX
features / goals :
- [ok] store any declared tokens, even if unknown, plus their relationships to others
- [ok] read and use x templates to parse datas. so the importer can adapt to any kind of x data organization and is easier to improve.
- [ok] handle big files (files are red as chunks)
- [ok] handle any text format (\n, \r, \r\n)
- [ok] allow random access to content of each different directx section
- [ok] be fast : 150 000 lines in 4 secs on 'old' i3. no ply. no file.tell()
- [ko] read binary and compressed x format
- [ok] import verts and faces
- [ok] import uv
- [ko] import normals
- [ok] import verts weights
- [ok] import materials
- [ok] import textures
- [ok] objects parent-childs relationships
- [ok] import armatures
- [ko] import animations
- [ko] import anything that can be imported :)
- [ko] select items to import through methods or Blender gui (tranverse project : BEL)
usage (directions)
the first time the .x file is red, it stores the templates and all the token names with their relationships this step has to be quick. then info of the internal representation of the file are displayed, browsable (the templates and tokens dictionnary) then a request is made and datas are retrieved from the token (from the file) and injected into blender datas.
the only request for now is in io_import_dx, at the end :
pseudo code :
for each token of Mesh type :
retrieve its data
read it using the directx vertices and faces format
build it
which corresponds to this at the end of io_import_directx :
for tokenname, token in tokens.items() :
if token ['type'] == 'Mesh' :
nVerts, verts, nFaces, faces = readToken(tokenname)
writeMesh(tokenname, False, verts, [], faces)
below is a part of the output the script generates from a x file before the requests this tree is generated by wandering through the generated dictionnary. from the root tokens to every child token it supports the directX {references} and non strict syntaxes. unknow tokens are stored and listed here too if any.
TREE TEST
69. Material__23_02_-_DefaultSub1 (Material)
69. |__ user: MeshMaterialList
75. |__ TextureFilename00001 (TextureFilename)
75.
58. Material__23_01_-_DefaultSub0 (Material)
58. |__ user: MeshMaterialList
64. |__ TextureFilename (TextureFilename)
64.
80. obj5 (Frame)
83. |__ FrameTransformMatrix (FrameTransformMatrix)
87. |__ Frame (Frame)
90. |__ FrameTransformMatrix00001 (FrameTransformMatrix)
94. |__ Mesh (Mesh)
330. |__ MeshNormals (MeshNormals)
567. |__ MeshMaterialList (MeshMaterialList)
58. | |__ ref: Material__23_01_-_DefaultSub0 (Material)
69. | |__ ref: Material__23_02_-_DefaultSub1 (Material)
632. |__ MeshTextureCoords (MeshTextureCoords)
810. |__ XSkinMeshHeader (XSkinMeshHeader)
816. |__ SkinWeights (SkinWeights)
746. |__ SkinWeights00001 (SkinWeights)
508. |__ SkinWeights00002 (SkinWeights)
000. |__ SkinWeights00003 (SkinWeights)
858. |__ SkinWeights00004 (SkinWeights)
992. |__ SkinWeights00005 (SkinWeights)
534. |__ SkinWeights00006 (SkinWeights)
746. |__ SkinWeights00007 (SkinWeights)
022. |__ SkinWeights00008 (SkinWeights)
302. |__ SkinWeights00009 (SkinWeights)
376. |__ SkinWeights00010 (SkinWeights)
778. |__ SkinWeights00011 (SkinWeights)
792. |__ SkinWeights00012 (SkinWeights)
474. |__ SkinWeights00013 (SkinWeights)
984. |__ SkinWeights00014 (SkinWeights)
680. |__ SkinWeights00015 (SkinWeights)
866. |__ SkinWeights00016 (SkinWeights)
746. |__ SkinWeights00017 (SkinWeights)
892. |__ SkinWeights00018 (SkinWeights)
422. |__ SkinWeights00019 (SkinWeights)
702. |__ SkinWeights00020 (SkinWeights)
776. |__ SkinWeights00021 (SkinWeights)
472. |__ SkinWeights00022 (SkinWeights)
646. |__ SkinWeights00023 (SkinWeights)
so each token like obj5, mesh or SkinWeights00023 can be call and read apart. its datas are not stored at step 1, they are retrieved from the file if wanted. only info about relationships are stored at step 1. on the contrary, template datas are already stored since we need them to parse each kind of data structures of each kind of token (for each uuid).
each token knows internally what are its relationship with other so you can wander from any location.
also note that token names can be modified : a name is created if none exists (token names are optional is x), shortened if too long for blender names, and indexed if there's duplicates