Scripts: Campbell (ideasman) updated his obj wavefront scripts.

This commit is contained in:
Willian Padovani Germano 2004-06-08 04:43:40 +00:00
parent 61bb158291
commit a15b430d71
2 changed files with 71 additions and 89 deletions

@ -1,7 +1,7 @@
#!BPY
"""
Name: 'OBJ Wavefront'
Name: 'Wavefront (*.obj)'
Blender: 232
Group: 'Export'
Tooltip: 'Save a Wavefront OBJ File'
@ -46,26 +46,8 @@ def getWorldMat(ob):
# Apply Transform #
#==================#
def apply_transform(verts, matrix):
x, y, z = verts
xloc, yloc, zloc = matrix[3][0], matrix[3][1], matrix[3][2]
xcomponent = x*matrix[0][0] + y*matrix[1][0] + z*matrix[2][0] + xloc
ycomponent = x*matrix[0][1] + y*matrix[1][1] + z*matrix[2][1] + yloc
zcomponent = x*matrix[0][2] + y*matrix[1][2] + z*matrix[2][2] + zloc
return [xcomponent, ycomponent, zcomponent]
#=====================================#
# Apply Transform for vertex normals #
# ignore the translation #
#=====================================#
def apply_normal_transform(verts, matrix):
x, y, z = verts
xcomponent = x*matrix[0][0] + y*matrix[1][0] + z*matrix[2][0]
ycomponent = x*matrix[0][1] + y*matrix[1][1] + z*matrix[2][1]
zcomponent = x*matrix[0][2] + y*matrix[1][2] + z*matrix[2][2]
return Mathutils.Vector([xcomponent, ycomponent, zcomponent])
verts.resize4D()
return Mathutils.VecMultMat(verts, matrix)
#====================================================#
# Return a 6 deciaml point floating point value #
@ -129,7 +111,7 @@ def save_obj(filename):
for f in m.faces:
for v in f.v:
# Transform the normal
noTx = apply_normal_transform(v.no, matrix)
noTx = apply_transform(v.no, matrix)
noTx.normalize()
file.write('vn ')
file.write(saneFloat(noTx[0]))

@ -1,7 +1,7 @@
#!BPY
"""
Name: 'OBJ Wavefront'
Name: 'Wavefront (*.obj)'
Blender: 232
Group: 'Import'
Tooltip: 'Load a Wavefront OBJ File'
@ -231,7 +231,7 @@ def load_obj(file):
elif l[0] == 'usemtl':
if l[1] == '(null)':
currentMat = NULL_MAT
currentMat = getMat(NULL_MAT)
else:
currentMat = getMat(join(l[1:])) # Use join in case of spaces