diff options
author | Jiri Hnidek <jiri.hnidek@tul.cz> | 2004-06-22 00:32:07 +0400 |
---|---|---|
committer | Jiri Hnidek <jiri.hnidek@tul.cz> | 2004-06-22 00:32:07 +0400 |
commit | ee07502a043fe1ebf07245f1b97181fe56b5096c (patch) | |
tree | 5affbb9d4aba7247fe151879b352d9c299e08f85 /release/scripts | |
parent | 59433aa42e302d0ddf95ae1944b90bb8bd85576f (diff) |
- Scripts:
small update of ideasman's obj import/export scripts (added support for smooth faces)
Diffstat (limited to 'release/scripts')
-rw-r--r-- | release/scripts/obj_export.py | 12 | ||||
-rw-r--r-- | release/scripts/obj_import.py | 17 |
2 files changed, 27 insertions, 2 deletions
diff --git a/release/scripts/obj_export.py b/release/scripts/obj_export.py index 8d52a06d6d9..814f9b481a2 100644 --- a/release/scripts/obj_export.py +++ b/release/scripts/obj_export.py @@ -150,6 +150,8 @@ def save_obj(filename): # Dosent work properly, matrix = getWorldMat(ob) + + smooth = 0 # Vert for v in m.verts: @@ -210,6 +212,16 @@ def save_obj(filename): elif currentImgName != NULL_IMG: # Not using an image so set to NULL_IMG currentImgName = NULL_IMG file.write( 'usemat ' + stripPath(currentImgName) +'\n') # Set a new image for all following faces + + if f.smooth == 1: + if smooth == 0: + smooth = 1 + file.write('s 1\n') + + if f.smooth == 0: + if smooth == 1: + smooth = 0 + file.write('s off\n') file.write('f ') for v in f.v: diff --git a/release/scripts/obj_import.py b/release/scripts/obj_import.py index 90f287559b1..e19c52b7be1 100644 --- a/release/scripts/obj_import.py +++ b/release/scripts/obj_import.py @@ -217,6 +217,8 @@ def load_obj(file): currentMat = nullMat # Use this mat. currentImg = NULL_IMG # Null image is a string, otherwise this should be set to an image object. + smooth = 0 + # Main loop lIdx = 0 while lIdx < len(fileLines): @@ -271,6 +273,8 @@ def load_obj(file): f.v.append(mesh.verts[vIdxLs[1]]) f.v.append(mesh.verts[vIdxLs[2]]) f.v.append(mesh.verts[vIdxLs[3]]) + # SMOTH FACE + f.smooth = smooth # UV MAPPING if uvMapList: if vtIdxLs[0] < len(uvMapList): @@ -294,6 +298,8 @@ def load_obj(file): f.v.append(mesh.verts[vIdxLs[0]]) f.v.append(mesh.verts[vIdxLs[i+1]]) f.v.append(mesh.verts[vIdxLs[i+2]]) + # SMOTH FACE + f.smooth = smooth # UV MAPPING if uvMapList: if vtIdxLs[0] < len(uvMapList): @@ -327,7 +333,14 @@ def load_obj(file): # New texture list uvMapList = [] - + + # setting smooth surface on or off + elif l[0] == 's': + if l[1] == 'off': + smooth = 0 + else: + smooth = 1 + elif l[0] == 'usemtl': if l[1] == '(null)': currentMat = getMat(NULL_MAT) @@ -355,4 +368,4 @@ def load_obj(file): if len(mesh.verts) > 0: NMesh.PutRaw(mesh, fileName + '_' + objectName) -Window.FileSelector(load_obj, 'Import OBJ')
\ No newline at end of file +Window.FileSelector(load_obj, 'Import OBJ') |