2004-06-14 20:51:09 +00:00
|
|
|
#!BPY
|
2004-06-21 12:01:23 +00:00
|
|
|
|
2004-06-14 20:51:09 +00:00
|
|
|
"""
|
|
|
|
|
Name: 'Wavefront (.obj)...'
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
Blender: 232
|
2004-06-14 20:51:09 +00:00
|
|
|
Group: 'Import'
|
|
|
|
|
Tooltip: 'Load a Wavefront OBJ File'
|
|
|
|
|
"""
|
2004-06-07 01:34:15 +00:00
|
|
|
|
2004-11-07 16:31:13 +00:00
|
|
|
__author__ = "Campbell Barton"
|
|
|
|
|
__url__ = ["blender", "elysiun"]
|
|
|
|
|
__version__ = "0.9"
|
|
|
|
|
|
|
|
|
|
__bpydoc__ = """\
|
|
|
|
|
This script imports OBJ files to Blender.
|
|
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
|
|
Run this script from "File->Import" menu and then load the desired OBJ file.
|
|
|
|
|
"""
|
|
|
|
|
|
2004-06-10 03:27:46 +00:00
|
|
|
# $Id$
|
|
|
|
|
#
|
2004-06-14 20:51:09 +00:00
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
|
# OBJ Import v0.9 by Campbell Barton (AKA Ideasman)
|
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
|
# ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
#
|
|
|
|
|
# ***** END GPL LICENCE BLOCK *****
|
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
NULL_MAT = '(null)' # Name for mesh's that have no mat set.
|
2004-06-21 12:01:23 +00:00
|
|
|
NULL_IMG = '(null)' # Name for mesh's that have no mat set.
|
2004-06-14 20:51:09 +00:00
|
|
|
|
2004-06-15 09:45:29 +00:00
|
|
|
MATLIMIT = 16 # This isnt about to change but probably should not be hard coded.
|
2004-06-14 20:51:09 +00:00
|
|
|
|
|
|
|
|
DIR = ''
|
|
|
|
|
|
|
|
|
|
#==============================================#
|
|
|
|
|
# Return directory, where is file #
|
|
|
|
|
#==============================================#
|
|
|
|
|
def pathName(path,name):
|
2004-09-18 21:04:23 +00:00
|
|
|
length=len(path)
|
|
|
|
|
for CH in range(1, length):
|
|
|
|
|
if path[length-CH:] == name:
|
|
|
|
|
path = path[:length-CH]
|
|
|
|
|
break
|
|
|
|
|
return path
|
2004-06-14 20:51:09 +00:00
|
|
|
|
|
|
|
|
#==============================================#
|
|
|
|
|
# Strips the slashes from the back of a string #
|
|
|
|
|
#==============================================#
|
|
|
|
|
def stripPath(path):
|
2005-05-30 02:26:40 +00:00
|
|
|
return path.split('/')[-1].split('\\')[-1]
|
2004-09-18 21:04:23 +00:00
|
|
|
|
2004-06-14 20:51:09 +00:00
|
|
|
#====================================================#
|
|
|
|
|
# Strips the prefix off the name before writing #
|
|
|
|
|
#====================================================#
|
|
|
|
|
def stripName(name): # name is a string
|
2004-09-18 21:04:23 +00:00
|
|
|
prefixDelimiter = '.'
|
|
|
|
|
return name[ : name.find(prefixDelimiter) ]
|
2004-06-14 20:51:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
from Blender import *
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
import sys as py_sys
|
2004-06-21 12:01:23 +00:00
|
|
|
|
2004-06-14 20:51:09 +00:00
|
|
|
#==================================================================================#
|
|
|
|
|
# This function sets textures defined in .mtl file #
|
|
|
|
|
#==================================================================================#
|
2004-06-21 12:01:23 +00:00
|
|
|
def getImg(img_fileName):
|
2004-09-18 21:04:23 +00:00
|
|
|
for i in Image.Get():
|
|
|
|
|
if i.filename == img_fileName:
|
|
|
|
|
return i
|
|
|
|
|
|
|
|
|
|
# if we are this far it means the image hasnt been loaded.
|
|
|
|
|
try:
|
|
|
|
|
return Image.Load(img_fileName)
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
except IOError:
|
|
|
|
|
print '\tunable to open image file: "%s"' % img_fileName
|
2004-09-18 21:04:23 +00:00
|
|
|
return
|
2004-06-21 12:01:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#==================================================================================#
|
|
|
|
|
# This function sets textures defined in .mtl file #
|
|
|
|
|
#==================================================================================#
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
def load_mat_image(mat, img_fileName, type, meshDict):
|
|
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
|
|
|
|
|
texture = Texture.New(type)
|
|
|
|
|
texture.setType('Image')
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
|
|
|
|
image = getImg(img_fileName)
|
|
|
|
|
if image:
|
|
|
|
|
texture.image = image
|
2004-09-18 21:04:23 +00:00
|
|
|
|
|
|
|
|
# adds textures to faces (Textured/Alt-Z mode)
|
|
|
|
|
# Only apply the diffuse texture to the face if the image has not been set with the inline usemat func.
|
|
|
|
|
if type == 'Kd':
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
for meshPair in meshDict.values():
|
|
|
|
|
for f in meshPair[0].faces:
|
|
|
|
|
if meshPair[0].materials[f.mat].name == mat.name:
|
|
|
|
|
# the inline usemat command overides the material Image
|
|
|
|
|
if not f.image:
|
|
|
|
|
f.image = image
|
|
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# adds textures for materials (rendering)
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
elif type == 'Ka':
|
2004-09-18 21:04:23 +00:00
|
|
|
mat.setTexture(0, texture, Texture.TexCo.UV, Texture.MapTo.CMIR)
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
elif type == 'Kd':
|
2004-09-18 21:04:23 +00:00
|
|
|
mat.setTexture(1, texture, Texture.TexCo.UV, Texture.MapTo.COL)
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
elif type == 'Ks':
|
2004-09-18 21:04:23 +00:00
|
|
|
mat.setTexture(2, texture, Texture.TexCo.UV, Texture.MapTo.SPEC)
|
2004-06-14 20:51:09 +00:00
|
|
|
|
|
|
|
|
#==================================================================================#
|
|
|
|
|
# This function loads materials from .mtl file (have to be defined in obj file) #
|
|
|
|
|
#==================================================================================#
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
def load_mtl(dir, mtl_file, meshDict):
|
2004-09-18 21:04:23 +00:00
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
#===============================================================================#
|
|
|
|
|
# This gets a mat or creates one of the requested name if none exist. #
|
|
|
|
|
#===============================================================================#
|
|
|
|
|
def getMat(matName):
|
|
|
|
|
# Make a new mat
|
|
|
|
|
try:
|
|
|
|
|
return Material.Get(matName)
|
|
|
|
|
except NameError:
|
|
|
|
|
return Material.New(matName)
|
|
|
|
|
|
|
|
|
|
mtl_file = stripPath(mtl_file)
|
2004-09-18 21:04:23 +00:00
|
|
|
mtl_fileName = dir + mtl_file
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
try:
|
|
|
|
|
fileLines= open(mtl_fileName, 'r').readlines()
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
except IOError:
|
|
|
|
|
print '\tunable to open referenced material file: "%s"' % mtl_fileName
|
2004-09-18 21:04:23 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
lIdx=0
|
|
|
|
|
while lIdx < len(fileLines):
|
|
|
|
|
l = fileLines[lIdx].split()
|
|
|
|
|
|
|
|
|
|
# Detect a line that will be ignored
|
|
|
|
|
if len(l) == 0:
|
|
|
|
|
pass
|
|
|
|
|
elif l[0] == '#' or len(l) == 0:
|
|
|
|
|
pass
|
|
|
|
|
elif l[0] == 'newmtl':
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
currentMat = getMat('_'.join(l[1:])) # Material should alredy exist.
|
2004-09-18 21:04:23 +00:00
|
|
|
elif l[0] == 'Ka':
|
|
|
|
|
currentMat.setMirCol(float(l[1]), float(l[2]), float(l[3]))
|
|
|
|
|
elif l[0] == 'Kd':
|
|
|
|
|
currentMat.setRGBCol(float(l[1]), float(l[2]), float(l[3]))
|
|
|
|
|
elif l[0] == 'Ks':
|
|
|
|
|
currentMat.setSpecCol(float(l[1]), float(l[2]), float(l[3]))
|
|
|
|
|
elif l[0] == 'Ns':
|
|
|
|
|
currentMat.setHardness( int((float(l[1])*0.51)) )
|
|
|
|
|
elif l[0] == 'd':
|
|
|
|
|
currentMat.setAlpha(float(l[1]))
|
|
|
|
|
elif l[0] == 'Tr':
|
|
|
|
|
currentMat.setAlpha(float(l[1]))
|
|
|
|
|
elif l[0] == 'map_Ka':
|
|
|
|
|
img_fileName = dir + l[1]
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
load_mat_image(currentMat, img_fileName, 'Ka', meshDict)
|
2004-09-18 21:04:23 +00:00
|
|
|
elif l[0] == 'map_Ks':
|
|
|
|
|
img_fileName = dir + l[1]
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
load_mat_image(currentMat, img_fileName, 'Ks', meshDict)
|
2004-09-18 21:04:23 +00:00
|
|
|
elif l[0] == 'map_Kd':
|
|
|
|
|
img_fileName = dir + l[1]
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
load_mat_image(currentMat, img_fileName, 'Kd', meshDict)
|
2004-09-18 21:04:23 +00:00
|
|
|
lIdx+=1
|
|
|
|
|
|
2005-05-30 02:26:40 +00:00
|
|
|
#===========================================================================#
|
|
|
|
|
# Returns unique name of object/mesh (preserve overwriting existing meshes) #
|
|
|
|
|
#===========================================================================#
|
2004-09-18 21:04:23 +00:00
|
|
|
def getUniqueName(name):
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
newName = name
|
2004-09-18 21:04:23 +00:00
|
|
|
uniqueInt = 0
|
|
|
|
|
while 1:
|
|
|
|
|
try:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
ob = Object.Get(newName)
|
2004-09-18 21:04:23 +00:00
|
|
|
# Okay, this is working, so lets make a new name
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
newName = '%s.%d' % (name, uniqueInt)
|
2004-09-18 21:04:23 +00:00
|
|
|
uniqueInt +=1
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
except AttributeError:
|
|
|
|
|
if newName not in NMesh.GetNames():
|
|
|
|
|
return newName
|
2004-11-30 02:27:46 +00:00
|
|
|
else:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
newName = '%s.%d' % (name, uniqueInt)
|
2004-11-30 02:27:46 +00:00
|
|
|
uniqueInt +=1
|
2004-06-14 20:51:09 +00:00
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
|
|
|
|
# Gets the meshs index for this material, -1 if its not in the list
|
|
|
|
|
def getMeshMaterialIndex(mesh, material):
|
|
|
|
|
meshMatIndex = -1
|
|
|
|
|
matIdx = 0
|
|
|
|
|
meshMatList = mesh.materials
|
|
|
|
|
while matIdx < len(meshMatList):
|
|
|
|
|
if meshMatList[matIdx].name == material.name:
|
|
|
|
|
meshMatIndex = matIdx # The current mat index.
|
|
|
|
|
break
|
|
|
|
|
matIdx+=1
|
|
|
|
|
# -1 if not found
|
|
|
|
|
return meshMatIndex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-06-14 20:51:09 +00:00
|
|
|
#==================================================================================#
|
|
|
|
|
# This loads data from .obj file #
|
|
|
|
|
#==================================================================================#
|
|
|
|
|
def load_obj(file):
|
2004-09-18 21:04:23 +00:00
|
|
|
time1 = sys.time()
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
|
|
|
|
TEX_OFF_FLAG = ~NMesh.FaceModes['TEX']
|
|
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# Get the file name with no path or .obj
|
|
|
|
|
fileName = stripName( stripPath(file) )
|
2004-09-11 13:45:17 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
mtl_fileName = ''
|
2004-09-11 13:45:17 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
DIR = pathName(file, stripPath(file))
|
|
|
|
|
|
|
|
|
|
fileLines = open(file, 'r').readlines()
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
uvMapList = [(0,0)] # store tuple uv pairs here
|
|
|
|
|
|
|
|
|
|
# This dummy vert makes life a whole lot easier-
|
|
|
|
|
# pythons index system then aligns with objs, remove later
|
2005-05-30 02:26:40 +00:00
|
|
|
vertList = [NMesh.Vert(0, 0, 0)]
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
|
|
|
|
# Store all imported materials in a dict, names are key
|
|
|
|
|
materiaDict = {}
|
|
|
|
|
|
|
|
|
|
# Store all imported images in a dict, names are key
|
|
|
|
|
imageDict = {}
|
|
|
|
|
|
|
|
|
|
# This stores the index that the current mesh has for the current material.
|
|
|
|
|
# if the mesh does not have the material then set -1
|
|
|
|
|
contextMeshMatIdx = -1
|
|
|
|
|
|
|
|
|
|
# Keep this out of the dict for easy accsess.
|
|
|
|
|
nullMat = Material.New(NULL_MAT)
|
2004-09-21 09:09:58 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
currentMat = nullMat # Use this mat.
|
|
|
|
|
currentImg = NULL_IMG # Null image is a string, otherwise this should be set to an image object.\
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
currentSmooth = 1
|
2004-09-21 09:09:58 +00:00
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
# Store a list of unnamed names
|
|
|
|
|
currentUnnamedGroupIdx = 0
|
|
|
|
|
currentUnnamedObjectIdx = 0
|
|
|
|
|
|
|
|
|
|
quadList = (0, 1, 2, 3)
|
2004-09-21 09:09:58 +00:00
|
|
|
|
|
|
|
|
#==================================================================================#
|
|
|
|
|
# Load all verts first (texture verts too) #
|
|
|
|
|
#==================================================================================#
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
nonVertFileLines = []
|
2004-09-18 21:04:23 +00:00
|
|
|
lIdx = 0
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
print '\tfile length: %d' % len(fileLines)
|
2004-09-18 21:04:23 +00:00
|
|
|
while lIdx < len(fileLines):
|
|
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
# Dont Bother splitting empty or comment lines.
|
|
|
|
|
if len(fileLines[lIdx]) == 0:
|
|
|
|
|
pass
|
|
|
|
|
elif fileLines[lIdx][0] == '\n':
|
|
|
|
|
pass
|
|
|
|
|
elif fileLines[lIdx][0] == '#':
|
|
|
|
|
pass
|
2004-09-21 09:09:58 +00:00
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
else:
|
|
|
|
|
fileLines[lIdx] = fileLines[lIdx].split()
|
|
|
|
|
l = fileLines[lIdx]
|
|
|
|
|
|
|
|
|
|
# Splitting may
|
|
|
|
|
if len(l) == 0:
|
|
|
|
|
pass
|
|
|
|
|
# Verts
|
|
|
|
|
elif l[0] == 'v':
|
|
|
|
|
vertList.append( NMesh.Vert(float(l[1]), float(l[2]), float(l[3]) ) )
|
|
|
|
|
|
|
|
|
|
# UV COORDINATE
|
|
|
|
|
elif l[0] == 'vt':
|
|
|
|
|
uvMapList.append( (float(l[1]), float(l[2])) )
|
|
|
|
|
else:
|
|
|
|
|
nonVertFileLines.append(l)
|
2004-09-21 09:09:58 +00:00
|
|
|
lIdx+=1
|
|
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
del fileLines
|
|
|
|
|
fileLines = nonVertFileLines
|
|
|
|
|
del nonVertFileLines
|
|
|
|
|
|
|
|
|
|
# Make a list of all unused vert indicies that we can copy from
|
|
|
|
|
VERT_USED_LIST = [-1]*len(vertList)
|
2004-09-21 09:09:58 +00:00
|
|
|
|
|
|
|
|
# Here we store a boolean list of which verts are used or not
|
|
|
|
|
# no we know weather to add them to the current mesh
|
|
|
|
|
# This is an issue with global vertex indicies being translated to per mesh indicies
|
|
|
|
|
# like blenders, we start with a dummy just like the vert.
|
|
|
|
|
# -1 means unused, any other value refers to the local mesh index of the vert.
|
|
|
|
|
|
|
|
|
|
# objectName has a char in front of it that determins weather its a group or object.
|
|
|
|
|
# We ignore it when naming the object.
|
|
|
|
|
objectName = 'omesh' # If we cant get one, use this
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
|
|
|
|
meshDict = {}
|
|
|
|
|
currentMesh = NMesh.GetRaw()
|
|
|
|
|
meshDict[objectName] = (currentMesh, VERT_USED_LIST[:]) # Mesh/meshDict[objectName][1]
|
|
|
|
|
currentMesh.verts.append(vertList[0])
|
|
|
|
|
currentMesh.hasFaceUV(1)
|
|
|
|
|
|
2004-09-21 09:09:58 +00:00
|
|
|
|
|
|
|
|
#==================================================================================#
|
|
|
|
|
# Load all faces into objects, main loop #
|
|
|
|
|
#==================================================================================#
|
|
|
|
|
lIdx = 0
|
|
|
|
|
# Face and Object loading LOOP
|
|
|
|
|
while lIdx < len(fileLines):
|
|
|
|
|
l = fileLines[lIdx]
|
2004-11-30 02:27:46 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# FACE
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
if l[0] == 'f':
|
2004-09-18 21:04:23 +00:00
|
|
|
# Make a face with the correct material.
|
|
|
|
|
f = NMesh.Face()
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
|
|
|
|
# Add material to mesh
|
|
|
|
|
if contextMeshMatIdx == -1:
|
|
|
|
|
tmpMatLs = currentMesh.materials
|
|
|
|
|
|
|
|
|
|
if len(tmpMatLs) == MATLIMIT:
|
|
|
|
|
contextMeshMatIdx = 0 # Use first material
|
|
|
|
|
print 'material overflow, attempting to use > 16 materials. defaulting to first.'
|
|
|
|
|
else:
|
|
|
|
|
contextMeshMatIdx = len(tmpMatLs)
|
|
|
|
|
currentMesh.addMaterial(currentMat)
|
2004-09-11 13:45:17 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# Set up vIdxLs : Verts
|
|
|
|
|
# Set up vtIdxLs : UV
|
|
|
|
|
# Start with a dummy objects so python accepts OBJs 1 is the first index.
|
|
|
|
|
vIdxLs = []
|
|
|
|
|
vtIdxLs = []
|
|
|
|
|
fHasUV = len(uvMapList)-1 # Assume the face has a UV until it sho it dosent, if there are no UV coords then this will start as 0.
|
|
|
|
|
for v in l[1:]:
|
|
|
|
|
# OBJ files can have // or / to seperate vert/texVert/normal
|
|
|
|
|
# this is a bit of a pain but we must deal with it.
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
objVert = v.split('/')
|
2004-09-21 09:09:58 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# Vert Index - OBJ supports negative index assignment (like python)
|
2004-09-21 09:09:58 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
vIdxLs.append(int(objVert[0]))
|
|
|
|
|
if fHasUV:
|
|
|
|
|
# UV
|
|
|
|
|
if len(objVert) == 1:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
#vtIdxLs.append(int(objVert[0])) # replace with below.
|
|
|
|
|
vtIdxLs.append(vIdxLs[-1]) # Sticky UV coords
|
|
|
|
|
elif objVert[1]: # != '' # Its possible that theres no texture vert just he vert and normal eg 1//2
|
2004-09-18 21:04:23 +00:00
|
|
|
vtIdxLs.append(int(objVert[1])) # Seperate UV coords
|
|
|
|
|
else:
|
|
|
|
|
fHasUV = 0
|
|
|
|
|
|
|
|
|
|
# Dont add a UV to the face if its larger then the UV coord list
|
|
|
|
|
# The OBJ file would have to be corrupt or badly written for thi to happen
|
|
|
|
|
# but account for it anyway.
|
|
|
|
|
if len(vtIdxLs) > 0:
|
|
|
|
|
if vtIdxLs[-1] > len(uvMapList):
|
|
|
|
|
fHasUV = 0
|
|
|
|
|
print 'badly written OBJ file, invalid references to UV Texture coordinates.'
|
2004-09-21 09:09:58 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# Quads only, we could import quads using the method below but it polite to import a quad as a quad.
|
|
|
|
|
if len(vIdxLs) == 4:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
for i in quadList: # quadList == [0,1,2,3]
|
|
|
|
|
if meshDict[objectName][1][vIdxLs[i]] == -1:
|
|
|
|
|
currentMesh.verts.append(vertList[vIdxLs[i]])
|
|
|
|
|
f.v.append(currentMesh.verts[-1])
|
|
|
|
|
meshDict[objectName][1][vIdxLs[i]] = len(currentMesh.verts)-1
|
2004-09-18 21:04:23 +00:00
|
|
|
else:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
f.v.append(currentMesh.verts[meshDict[objectName][1][vIdxLs[i]]])
|
2004-09-21 09:09:58 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# UV MAPPING
|
|
|
|
|
if fHasUV:
|
2004-11-30 02:27:46 +00:00
|
|
|
f.uv.extend([uvMapList[ vtIdxLs[0] ],uvMapList[ vtIdxLs[1] ],uvMapList[ vtIdxLs[2] ],uvMapList[ vtIdxLs[3] ]])
|
|
|
|
|
#for i in [0,1,2,3]:
|
|
|
|
|
# f.uv.append( uvMapList[ vtIdxLs[i] ] )
|
2004-09-18 21:04:23 +00:00
|
|
|
|
|
|
|
|
if f.v > 0:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
f.mat = contextMeshMatIdx
|
2004-09-18 21:04:23 +00:00
|
|
|
if currentImg != NULL_IMG:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
f.image = currentImg
|
|
|
|
|
else:
|
|
|
|
|
f.mode &= TEX_OFF_FLAG
|
|
|
|
|
currentMesh.faces.append(f) # move the face onto the mesh
|
|
|
|
|
if len(f) > 0:
|
|
|
|
|
f.smooth = currentSmooth
|
|
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
elif len(vIdxLs) >= 3: # This handles tri's and fans
|
|
|
|
|
for i in range(len(vIdxLs)-2):
|
|
|
|
|
f = NMesh.Face()
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
for ii in [0, i+1, i+2]:
|
2004-09-21 09:09:58 +00:00
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
if meshDict[objectName][1][vIdxLs[ii]] == -1:
|
|
|
|
|
currentMesh.verts.append(vertList[vIdxLs[ii]])
|
|
|
|
|
f.v.append(currentMesh.verts[-1])
|
|
|
|
|
meshDict[objectName][1][vIdxLs[ii]] = len(currentMesh.verts)-1
|
2004-09-18 21:04:23 +00:00
|
|
|
else:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
f.v.append(currentMesh.verts[meshDict[objectName][1][vIdxLs[ii]]])
|
2004-09-18 21:04:23 +00:00
|
|
|
|
|
|
|
|
# UV MAPPING
|
|
|
|
|
if fHasUV:
|
2004-12-12 15:28:38 +00:00
|
|
|
f.uv.extend([uvMapList[ vtIdxLs[0] ], uvMapList[ vtIdxLs[i+1] ], uvMapList[ vtIdxLs[i+2] ]])
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
if f.v > 0:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
f.mat = contextMeshMatIdx
|
2004-09-18 21:04:23 +00:00
|
|
|
if currentImg != NULL_IMG:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
f.image = currentImg
|
|
|
|
|
else:
|
|
|
|
|
f.mode |= TEX_OFF_FLAG
|
|
|
|
|
currentMesh.faces.append(f) # move the face onto the mesh
|
|
|
|
|
if len(f) > 0:
|
|
|
|
|
f.smooth = currentSmooth
|
2004-09-21 09:09:58 +00:00
|
|
|
|
|
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# FACE SMOOTHING
|
|
|
|
|
elif l[0] == 's':
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
# No value? then turn on.
|
|
|
|
|
if len(l) == 1:
|
|
|
|
|
currentSmooth = 1
|
|
|
|
|
else:
|
|
|
|
|
if l[1] == 'off':
|
|
|
|
|
currentSmooth = 0
|
|
|
|
|
else:
|
|
|
|
|
currentSmooth = 1
|
2004-09-18 21:04:23 +00:00
|
|
|
|
|
|
|
|
# OBJECT / GROUP
|
|
|
|
|
elif l[0] == 'o' or l[0] == 'g':
|
|
|
|
|
# This makes sure that if an object and a group have the same name then
|
|
|
|
|
# they are not put into the same object.
|
2004-09-21 09:09:58 +00:00
|
|
|
|
|
|
|
|
# Only make a new group.object name if the verts in the existing object have been used, this is obscure
|
|
|
|
|
# but some files face groups seperating verts and faces which results in silly things. (no groups have names.)
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
if len(l) > 1:
|
|
|
|
|
objectName = '_'.join(l[1:])
|
|
|
|
|
else: # No name given
|
|
|
|
|
# Make a new empty name
|
|
|
|
|
if l[0] == 'g': # Make a blank group name
|
|
|
|
|
objectName = 'unnamed_grp_%d' % currentUnnamedGroupIdx
|
|
|
|
|
currentUnnamedGroupIdx +=1
|
|
|
|
|
else: # is an object.
|
|
|
|
|
objectName = 'unnamed_ob_%d' % currentUnnamedObjectIdx
|
|
|
|
|
currentUnnamedObjectIdx +=1
|
2004-09-21 09:09:58 +00:00
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
|
|
|
|
# If we havnt written to this mesh before then do so.
|
|
|
|
|
# if we have then we'll just keep appending to it, this is required for soem files.
|
|
|
|
|
|
|
|
|
|
# If we are new, or we are not yet in the list of added meshes
|
|
|
|
|
# then make us new mesh.
|
|
|
|
|
if len(l) == 1 or objectName not in meshDict.keys():
|
|
|
|
|
currentMesh = NMesh.GetRaw()
|
|
|
|
|
meshDict[objectName] = (currentMesh, VERT_USED_LIST[:])
|
|
|
|
|
currentMesh.hasFaceUV(1)
|
|
|
|
|
currentMesh.verts.append( vertList[0] )
|
|
|
|
|
contextMeshMatIdx = -1
|
2004-09-21 09:09:58 +00:00
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
else:
|
|
|
|
|
# Since we have this in Blender then we will check if the current Mesh has the material.
|
|
|
|
|
# set the contextMeshMatIdx to the meshs index but only if we have it.
|
|
|
|
|
currentMesh = meshDict[objectName]
|
|
|
|
|
contextMeshMatIdx = getMeshMaterialIndex(currentMesh, currentMat)
|
|
|
|
|
|
|
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
|
|
|
|
|
# MATERIAL
|
|
|
|
|
elif l[0] == 'usemtl':
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
if len(l) == 1 or l[1] == NULL_MAT:
|
|
|
|
|
#~ currentMat = getMat(NULL_MAT)
|
|
|
|
|
newMatName = NULL_MAT
|
|
|
|
|
currentMat = nullMat
|
2004-09-18 21:04:23 +00:00
|
|
|
else:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
#~ currentMat = getMat(' '.join(l[1:])) # Use join in case of spaces
|
|
|
|
|
newMatName = '_'.join(l[1:])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: # Add to material list if not there
|
|
|
|
|
currentMat = materiaDict[newMatName]
|
|
|
|
|
newMatName = currentMat.name # Make sure we are up to date, Blender might have incremented the name.
|
|
|
|
|
|
|
|
|
|
# Since we have this in Blender then we will check if the current Mesh has the material.
|
|
|
|
|
matIdx = 0
|
|
|
|
|
tmpMeshMaterials = currentMesh.materials
|
|
|
|
|
while matIdx < len(tmpMeshMaterials):
|
|
|
|
|
if tmpMeshMaterials[matIdx].name == newMatName:
|
|
|
|
|
contextMeshMatIdx = matIdx # The current mat index.
|
|
|
|
|
break
|
|
|
|
|
matIdx+=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except KeyError: # Not added yet, add now.
|
|
|
|
|
currentMat = Material.New(newMatName)
|
|
|
|
|
materiaDict[newMatName] = currentMat
|
|
|
|
|
contextMeshMatIdx = -1 # Mesh cant possibly have the material.
|
|
|
|
|
|
|
|
|
|
# IMAGE
|
2005-05-30 02:26:40 +00:00
|
|
|
elif l[0] == 'usemat' or l[0] == 'usemap':
|
|
|
|
|
if len(l) == 1 or l[1] == '(null)' or l[1] == 'off':
|
2004-09-18 21:04:23 +00:00
|
|
|
currentImg = NULL_IMG
|
|
|
|
|
else:
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
# Load an image.
|
|
|
|
|
newImgName = stripPath(' '.join(l[1:]))
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# Assume its alredy set in the dict (may or maynot be loaded)
|
|
|
|
|
currentImg = imageDict[newImgName]
|
|
|
|
|
|
|
|
|
|
except KeyError: # Not in dict, add for first time.
|
|
|
|
|
try: # Image has not been added, Try and load the image
|
|
|
|
|
currentImg = Image.Load( '%s%s' % (DIR, newImgName) ) # Use join in case of spaces
|
|
|
|
|
imageDict[newImgName] = currentImg
|
|
|
|
|
|
|
|
|
|
except IOError: # Cant load, just set blank.
|
|
|
|
|
imageDict[newImgName] = NULL_IMG
|
|
|
|
|
currentImg = NULL_IMG
|
2004-11-30 02:27:46 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
# MATERIAL FILE
|
|
|
|
|
elif l[0] == 'mtllib':
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
mtl_fileName = ' '.join(l[1:]) # SHOULD SUPPORT MULTIPLE MTL?
|
2004-09-21 09:09:58 +00:00
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
lIdx+=1
|
2004-09-21 09:09:58 +00:00
|
|
|
|
|
|
|
|
|
2004-09-18 21:04:23 +00:00
|
|
|
#==============================================#
|
|
|
|
|
# Write all meshs in the dictionary #
|
2005-05-30 02:26:40 +00:00
|
|
|
#==============================================#
|
|
|
|
|
for ob in Scene.GetCurrent().getChildren(): # Deselect all
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
ob.sel = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Applies material properties to materials alredy on the mesh as well as Textures.
|
|
|
|
|
if mtl_fileName != '':
|
|
|
|
|
load_mtl(DIR, mtl_fileName, meshDict)
|
|
|
|
|
|
2005-05-30 02:26:40 +00:00
|
|
|
|
|
|
|
|
importedObjects = []
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
for mk in meshDict.keys():
|
|
|
|
|
meshDict[mk][0].verts.pop(0)
|
2005-05-30 02:26:40 +00:00
|
|
|
|
|
|
|
|
# Ignore no vert meshes.
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
if not meshDict[mk][0].verts:
|
2005-05-30 02:26:40 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
name = getUniqueName(mk)
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
ob = NMesh.PutRaw(meshDict[mk][0], name)
|
2005-05-30 02:26:40 +00:00
|
|
|
ob.name = name
|
|
|
|
|
|
|
|
|
|
importedObjects.append(ob)
|
|
|
|
|
|
|
|
|
|
# Select all imported objects.
|
|
|
|
|
for ob in importedObjects:
|
|
|
|
|
ob.sel = 1
|
2004-09-18 21:04:23 +00:00
|
|
|
|
|
|
|
|
print "obj import time: ", sys.time() - time1
|
2004-08-17 04:26:00 +00:00
|
|
|
|
2004-09-11 13:45:17 +00:00
|
|
|
Window.FileSelector(load_obj, 'Import Wavefront OBJ')
|
2004-11-30 02:27:46 +00:00
|
|
|
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
|
2004-12-01 04:49:04 +00:00
|
|
|
# For testing compatibility
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
'''
|
|
|
|
|
TIME = sys.time()
|
2005-05-30 02:26:40 +00:00
|
|
|
import os
|
|
|
|
|
for obj in os.listdir('/obj/'):
|
|
|
|
|
if obj.lower().endswith('obj'):
|
|
|
|
|
print obj
|
|
|
|
|
newScn = Scene.New(obj)
|
|
|
|
|
newScn.makeCurrent()
|
|
|
|
|
load_obj('/obj/' + obj)
|
|
|
|
|
'''
|
BPython bug fixes:
- #2646 reported by Campbell: Python/Fileselector (moving from fileselector called by script to another space caused script to hang around open but not accessible)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2646&group_id=9
- #2676 reported by Wim Van Hoydonck: 2.37 python scripts gui: event 8 ignored (thanks Ton for discussing / pointing what to do, Ken Hughes for also working on a fix)
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2676&group_id=9
- gui-less scripts with calls to progress bar inside fileselector callbacks didn't return to the previous space on exit (staying on Scripts win), requiring an event to do so (mouse movement, for example). Quick fix for now, will rework a little after 2.37a for a better alternative, not needing to move to the Scripts win at all.
- added syntax colors access to Window.Theme module.
Scripts:
- updates by Jean-Michel Soler: svg2obj (svg paths import), tex2uvbaker, fixfromarmature;
- updates by Campbell Barton: obj import / export, console;
- tiny: converted vrml97 export to unix line endings;
- updates in ac3d exporter, help browser, save theme.
Thanks all mentioned above.
2005-06-11 05:30:14 +00:00
|
|
|
#print "TOTAL IMPORT TIME: ", sys.time() - TIME
|
|
|
|
|
#load_obj('/obj/her.obj')
|