diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-06-23 04:21:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-06-23 04:21:49 +0400 |
commit | fcc377e204bd1cb3d474c1e3bbb5e0ae7f267cff (patch) | |
tree | 087646661e29bdffd382afbf7d895667567f17f6 /release | |
parent | 7a55f52b1bddc389dca1d456dafb79751abcc9c1 (diff) |
[#13635] DirectX8Exporter with vertex colors
patch from Masaru Nemoto (mnemoto)
Made some modifications to the patch, use reduce() to get total face verts and some speedup for face vcol looping, also don't write vcol alpha since its used by brushes internally and has no useful meaning.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/DirectX8Exporter.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/release/scripts/DirectX8Exporter.py b/release/scripts/DirectX8Exporter.py index 2ec42057039..01212545f77 100644 --- a/release/scripts/DirectX8Exporter.py +++ b/release/scripts/DirectX8Exporter.py @@ -6,9 +6,9 @@ # Group: 'Export' # Tooltip: 'Export to DirectX text file format format for XNA Animation Component Library.' """ -__author__ = "minahito (original:Arben (Ben) Omari)" -__url__ = ("blender", "blenderartists.org", "Adjuster's site http://sunday-lab.blogspot.com/, Author's site http://www.omariben.too.it") -__version__ = "3.0" +__author__ = "vertex color exporting feature is added by mnemoto (original:minahito (original:Arben (Ben) Omari))" +__url__ = ("blender", "elysiun", "Adjuster's site http://sunday-lab.blogspot.com/, Author's site http://www.omariben.too.it","Adjuster's site http://ex.homeunix.net/") +__version__ = "3.1" __bpydoc__ = """\ This script exports a Blender mesh with armature to DirectX 8's text file @@ -444,6 +444,7 @@ class xExport: self.writeMeshMaterialList(obj, mesh, tex) self.writeMeshNormals(obj, mesh) self.writeMeshTextureCoords(obj, mesh) + self.writeMeshVertexColors(obj, mesh) self.file.write(" } // End of the Mesh %s \n" % (obj.name)) @@ -464,6 +465,7 @@ class xExport: self.writeMeshMaterialList(obj, mesh, tex) self.writeMeshNormals(obj, mesh) self.writeMeshTextureCoords(obj, mesh) + self.writeMeshVertexColors(obj, mesh) self.file.write(" }\n") self.file.write("}\n") ind = objs.index(obj) @@ -1047,6 +1049,32 @@ template SkinWeights {\n\ self.file.write(",\n") self.file.write("} //End of MeshTextureCoords\n") + + #*********************************************** + #MESH VORTEX COLORS + #*********************************************** + def writeMeshVertexColors(self, name, mesh): + if mesh.hasVertexColours(): + self.file.write("MeshVertexColors {\n") + #VERTICES NUMBER + numvert = reduce( lambda i,f: len(f)+i, mesh.faces, 0) + self.file.write("%d;\n" % (numvert)) + #VERTEX COLORS + + vcounter =0 + for f in mesh.faces: + col = f.col + for i,c in enumerate(col): + # Note vcol alpha has no meaning + self.file.write("%d;%f;%f;%f;%f;" % (vcounter,c.r/255.0, c.g/255.0, c.b/255.0, 1.0)) # c.a/255.0)) + vcounter+=1 + if vcounter == numvert : + self.file.write(";\n") + else : + self.file.write(",\n") + + self.file.write("} //End of MeshVertexColors\n") + #***********************************************#***********************************************#*********************************************** #*********************************************** #FRAMES |