-
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
I'm testing things for the moment, so it does not produce anything yet. the structure looks like to be in place
the readme provides current, accurate info this article is a more readable summary of th readme
to use it :
actually it's not an addon yet, code baby steps. but it can already imports some stuff (verts and faces) so here's how to do :
- create a 'bel' folder in your blender addons folder
- copy anything from the repo inside it (except crcf folder, not used)
- start Blender
- open io_import_directx.py in a text block
- alt-p : some objects created from the current .x file
- line 73 and next to change the .x file to parse
features / goals :
- [ok] store any declared tokens, even if unknown, plus their relationships to others
- [ok] read and use template section (only red for the moment). this allows special format and evolution
- [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
- [ko] import verts weights
- [ko] import shapes
- [ko] import materials
- [ko] import textures
- [ko] import armatures
- [ko] import animations
- [ko] import ...
- [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.