Mercurial > hg > Game > Cerium
comparison SceneGraph/BlenderScript/export_xml.py @ 1072:262d9367848d draft
merge
author | yutaka@localhost.localdomain |
---|---|
date | Fri, 17 Dec 2010 00:18:36 +0900 |
parents | 2403d545abd8 |
children |
comparison
equal
deleted
inserted
replaced
1069:19a1769343d6 | 1072:262d9367848d |
---|---|
1 #!BPY | 1 #!BPY |
2 """Registration info for Blender menus: | 2 """Registration info for Blender menus: |
3 Name: 'Libps3 (.xml)' | 3 Name: 'Libps+x (.xml)' |
4 Blender: 240 | 4 Blender: 240 |
5 Group: 'Export' | 5 Group: 'Export' |
6 Tooltip: 'Export to (.xml) for libps3' | 6 Tooltip: 'Export to (.xml) for libps3' |
7 """ | 7 """ |
8 | 8 |
142 def getFaces(): | 142 def getFaces(): |
143 ##change | 143 ##change |
144 #str = "" | 144 #str = "" |
145 file.write("") | 145 file.write("") |
146 matrix = obj.getMatrix() | 146 matrix = obj.getMatrix() |
147 | 147 big = 6 |
148 for mindex in range(len(flist)): | 148 for mindex in range(len(flist)): |
149 fl = flist[mindex] | 149 fl = flist[mindex] |
150 if fl != []: | 150 if fl != []: |
151 parent_name = obj.getParent() | 151 parent_name = obj.getParent() |
152 if parent_name: | 152 if parent_name: |
164 for f in fl: | 164 for f in fl: |
165 tri_first = vlist[f[0]] | 165 tri_first = vlist[f[0]] |
166 tri_second = vlist[f[1]] | 166 tri_second = vlist[f[1]] |
167 tri_third = vlist[f[2]] | 167 tri_third = vlist[f[2]] |
168 | 168 |
169 file.write("\t\t\t%f %f %f\n" %(tri_first[0][0] + matrix[3][0], tri_first[0][1] + matrix[3][1], tri_first[0][2] + matrix[3][2]) ) | 169 file.write("\t\t\t%f %f %f\n" %(big*(tri_first[0][0] + matrix[3][0]), big*(tri_first[0][1] + matrix[3][1]), big*(tri_first[0][2] + matrix[3][2])) ) |
170 file.write("\t\t\t%f %f %f\n" %(tri_second[0][0] + matrix[3][0], tri_second[0][1] + matrix[3][1], tri_second[0][2] + matrix[3][2]) ) | 170 file.write("\t\t\t%f %f %f\n" %(big*(tri_second[0][0] + matrix[3][0]), big*(tri_second[0][1] + matrix[3][1]), big*(tri_second[0][2] + matrix[3][2])) ) |
171 file.write("\t\t\t%f %f %f\n" %(tri_third[0][0] + matrix[3][0], tri_third[0][1] + matrix[3][1], tri_third[0][2] + matrix[3][2]) ) | 171 file.write("\t\t\t%f %f %f\n" %(big*(tri_third[0][0] + matrix[3][0]), big*(tri_third[0][1] + matrix[3][1]), big*(tri_third[0][2] + matrix[3][2])) ) |
172 file.write("\t\t</coordinate>\n") | 172 file.write("\t\t</coordinate>\n") |
173 | 173 |
174 file.write("\t\t<normal>\n") | 174 file.write("\t\t<normal>\n") |
175 for f in fl: | 175 for f in fl: |
176 tri_first = vlist[f[0]] | 176 tri_first = vlist[f[0]] |
177 tri_second = vlist[f[1]] | 177 tri_second = vlist[f[1]] |
178 tri_third = vlist[f[2]] | 178 tri_third = vlist[f[2]] |
179 | 179 |
180 file.write("\t\t\t%f %f %f\n" %(tri_first[1][0], tri_first[1][1], tri_first[1][2]) ) | 180 file.write("\t\t\t%f %f %f\n" %(big*(tri_first[1][0]), big*(tri_first[1][1]), big*(tri_first[1][2])) ) |
181 file.write("\t\t\t%f %f %f\n" %(tri_second[1][0], tri_second[1][1], tri_second[1][2]) ) | 181 file.write("\t\t\t%f %f %f\n" %(big*(tri_second[1][0]), big*(tri_second[1][1]), big*(tri_second[1][2])) ) |
182 file.write("\t\t\t%f %f %f\n" %(tri_third[1][0], tri_third[1][1], tri_third[1][2]) ) | 182 file.write("\t\t\t%f %f %f\n" %(big*(tri_third[1][0]), big*(tri_third[1][1]), big*(tri_third[1][2])) ) |
183 file.write("\t\t</normal>\n" ) | 183 file.write("\t\t</normal>\n" ) |
184 | 184 |
185 file.write("\t\t<model>\n" ) | 185 file.write("\t\t<model>\n" ) |
186 ###parameter of translate | 186 ###parameter of translate |
187 file.write("\t\t\t%f %f %f\n" % (matrix[3][0], matrix[3][1], matrix[3][2]) ) | 187 file.write("\t\t\t%f %f %f\n" % (matrix[3][0], matrix[3][1], matrix[3][2]) ) |
191 file.write("\t\t<texture>\n") | 191 file.write("\t\t<texture>\n") |
192 for f in fl: | 192 for f in fl: |
193 tri_first = vlist[f[0]] | 193 tri_first = vlist[f[0]] |
194 tri_second = vlist[f[1]] | 194 tri_second = vlist[f[1]] |
195 tri_third = vlist[f[2]] | 195 tri_third = vlist[f[2]] |
196 | 196 file.write("\t\t\t%f %f\n" %(tri_first[2][0], (-1*(tri_first[2][1])+1 ))) |
197 file.write("\t\t\t%f %f\n" %(tri_first[2][0], tri_first[2][1]) ) | 197 file.write("\t\t\t%f %f\n" %(tri_second[2][0], (-1*(tri_second[2][1])+1 ))) |
198 file.write("\t\t\t%f %f\n" %(tri_second[2][0], tri_second[2][1]) ) | 198 file.write("\t\t\t%f %f\n" %(tri_third[2][0], (-1*(tri_third[2][1])+1 ))) |
199 file.write("\t\t\t%f %f\n" %(tri_third[2][0], tri_third[2][1]) ) | |
200 file.write("\t\t</texture>\n") | 199 file.write("\t\t</texture>\n") |
201 else: | 200 else: |
202 file.write("\t\t<texture/>\n") | 201 file.write("\t\t<texture>\n") |
203 | 202 for f in fl: |
204 | 203 file.write("\t\t\t0.000000 0.000000\n") |
204 file.write("\t\t\t0.000000 0.000000\n") | |
205 file.write("\t\t\t0.000000 0.000000\n") | |
206 file.write("\t\t</texture>\n") | |
205 ### get texture_image and change base64 data | 207 ### get texture_image and change base64 data |
206 texture = mesh.faces[0].image | 208 texture = mesh.faces[0].image |
207 if texture: | 209 if texture: |
208 file.write(loadTexture(texture)) | 210 file.write(loadTexture(texture)) |
209 | |
210 else: | 211 else: |
211 file.write("\t\t<image name=\"%s\">\n" %("sample_white.png") ) | 212 file.write("\t\t<image name=\"%s\">\n" %("dummy.png") ) |
212 | 213 file.write("\t\t\tiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGUlEQVQokWP8/fs3AymAiSTVoxpG\n"); |
213 file.write("\t\t\tiVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAEElEQVQImWP8zwABTAwUMQBJQQEP\n"); | 214 file.write("\t\t\tNQwpDQAwxQMRlevqcQAAAABJRU5ErkJggg==\n"); |
214 file.write("\t\t\tlYH+agAAAABJRU5ErkJggg==\n"); | |
215 | |
216 file.write("\t\t</image>\n") | 215 file.write("\t\t</image>\n") |
217 | |
218 #return str | 216 #return str |
219 | 217 |
220 vdata = [] | 218 vdata = [] |
221 vlist = [] | 219 vlist = [] |
222 flist = [] | 220 flist = [] |
445 | 443 |
446 | 444 |
447 def loadTexture(texture): | 445 def loadTexture(texture): |
448 global images, imageCount | 446 global images, imageCount |
449 name = texture.getName() | 447 name = texture.getName() |
450 if name in images: | 448 #if name in images: |
451 return "\t\t<image name=\"" + name + "\"/>\n" | 449 # return "\t\t<image name=\"" + name + "\"/>\n" |
452 out = "\t\t<image name=\"" + name + "\">\n" | 450 out = "\t\t<image name=\"" + name + "\">\n" |
453 imageCount += 1 | 451 imageCount += 1 |
454 images[name] = imageCount | 452 images[name] = imageCount |
455 image_path = texture.getFilename() | 453 image_path = texture.getFilename() |
456 input = open(expandpath(image_path), 'r') | 454 input = open(expandpath(image_path), 'r') |