Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
#!BPY
|
|
|
|
""" Registration info for Blender menus:
|
|
|
|
Name: 'VRML97 (.wrl)...'
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
Blender: 241
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
Group: 'Export'
|
2008-05-10 14:05:35 +00:00
|
|
|
Submenu: 'All Objects...' all
|
|
|
|
Submenu: 'All Objects compressed...' comp
|
|
|
|
Submenu: 'Selected Objects...' selected
|
2005-05-22 18:50:46 +00:00
|
|
|
Tooltip: 'Export to VRML97 file (.wrl)'
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = ("Rick Kimball", "Ken Miller", "Steve Matthews", "Bart")
|
2008-04-23 14:04:05 +00:00
|
|
|
__url__ = ["blender", "blenderartists.org",
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
"Author's (Rick) homepage, http://kimballsoftware.com/blender",
|
2005-06-06 19:00:02 +00:00
|
|
|
"Author's (Bart) homepage, http://www.neeneenee.de/vrml"]
|
2006-01-29 19:17:53 +00:00
|
|
|
__email__ = ["Bart, bart:neeneenee*de"]
|
|
|
|
__version__ = "2006/01/17"
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
__bpydoc__ = """\
|
2005-05-22 18:50:46 +00:00
|
|
|
This script exports to VRML97 format.
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
Run this script from "File->Export" menu. A pop-up will ask whether you
|
|
|
|
want to export only selected or all relevant objects.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-05-22 18:50:46 +00:00
|
|
|
# VRML97 exporter for blender 2.36 or above
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
#
|
|
|
|
# ***** 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 *****
|
|
|
|
#
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Library dependancies
|
|
|
|
####################################
|
|
|
|
|
|
|
|
import Blender
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
from Blender import Object, Mesh, Lamp, Draw, BGL, \
|
2008-05-10 14:05:35 +00:00
|
|
|
Image, Text, sys, Mathutils
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
from Blender.Scene import Render
|
2006-05-16 22:57:24 +00:00
|
|
|
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
import math
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Global Variables
|
|
|
|
####################################
|
|
|
|
|
|
|
|
scene = Blender.Scene.getCurrent()
|
2006-05-16 22:57:24 +00:00
|
|
|
world = Blender.World.GetCurrent()
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
worldmat = Blender.Texture.Get()
|
2005-05-22 18:50:46 +00:00
|
|
|
filename = Blender.Get('filename')
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
_safeOverwrite = True
|
2006-01-29 19:17:53 +00:00
|
|
|
extension = ''
|
2008-05-10 14:05:35 +00:00
|
|
|
ARG=''
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# Blender is Z up, VRML is Y up, both are right hand coordinate
|
|
|
|
# systems, so to go from Blender coords to VRML coords we rotate
|
|
|
|
# by 90 degrees around the X axis. In matrix notation, we have a
|
|
|
|
# matrix, and it's inverse, as:
|
|
|
|
M_blen2vrml = Mathutils.Matrix([1,0,0,0], \
|
|
|
|
[0,0,1,0], \
|
|
|
|
[0,-1,0,0], \
|
|
|
|
[0,0,0,1])
|
|
|
|
M_vrml2blen = Mathutils.Matrix([1,0,0,0], \
|
|
|
|
[0,0,-1,0], \
|
|
|
|
[0,1,0,0], \
|
|
|
|
[0,0,0,1])
|
|
|
|
|
|
|
|
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
class DrawTypes:
|
2006-05-10 21:37:03 +00:00
|
|
|
"""Object DrawTypes enum values
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
BOUNDS - draw only the bounding box of the object
|
|
|
|
WIRE - draw object as a wire frame
|
|
|
|
SOLID - draw object with flat shading
|
|
|
|
SHADED - draw object with OpenGL shading
|
|
|
|
"""
|
2006-05-10 21:37:03 +00:00
|
|
|
BOUNDBOX = 1
|
|
|
|
WIRE = 2
|
|
|
|
SOLID = 3
|
|
|
|
SHADED = 4
|
|
|
|
TEXTURE = 5
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
|
|
|
if not hasattr(Blender.Object,'DrawTypes'):
|
2006-05-10 21:37:03 +00:00
|
|
|
Blender.Object.DrawTypes = DrawTypes()
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
|
|
|
##########################################################
|
|
|
|
# Functions for writing output file
|
|
|
|
##########################################################
|
|
|
|
|
|
|
|
class VRML2Export:
|
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
def __init__(self, filename):
|
|
|
|
#--- public you can change these ---
|
|
|
|
self.wire = 0
|
|
|
|
self.proto = 1
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.facecolors = 0
|
|
|
|
self.vcolors = 0
|
2006-05-10 21:37:03 +00:00
|
|
|
self.billnode = 0
|
|
|
|
self.halonode = 0
|
|
|
|
self.collnode = 0
|
|
|
|
self.tilenode = 0
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.wire = 0
|
|
|
|
self.twosided = 0
|
|
|
|
|
|
|
|
# level of verbosity in console 0-none, 1-some, 2-most
|
|
|
|
try:
|
|
|
|
rt = Blender.Get('rt')
|
|
|
|
if (rt == 42):
|
|
|
|
self.verbose = 1
|
|
|
|
elif (rt == 43):
|
|
|
|
self.verbose = 2
|
|
|
|
else:
|
|
|
|
self.verbose = 0
|
|
|
|
except:
|
|
|
|
self.verbose = 0
|
|
|
|
|
|
|
|
# decimals for material color values 0.000 - 1.000
|
2006-11-11 19:12:43 +00:00
|
|
|
self.cp=7
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# decimals for vertex coordinate values 0.000 - n.000
|
2006-11-11 19:12:43 +00:00
|
|
|
self.vp=7
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# decimals for texture coordinate values 0.000 - 1.000
|
2006-11-11 19:12:43 +00:00
|
|
|
self.tp=7
|
2006-05-10 21:37:03 +00:00
|
|
|
|
|
|
|
#--- class private don't touch ---
|
|
|
|
self.texNames={} # dictionary of textureNames
|
|
|
|
self.matNames={} # dictionary of materialNames
|
|
|
|
self.meshNames={} # dictionary of meshNames
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.coordNames={} # dictionary of coordNames
|
2006-05-10 21:37:03 +00:00
|
|
|
self.indentLevel=0 # keeps track of current indenting
|
|
|
|
self.filename=filename
|
|
|
|
self.file = open(filename, "w")
|
|
|
|
self.bNav=0
|
|
|
|
self.nodeID=0
|
|
|
|
self.namesReserved=[ "Anchor", "Appearance", "AudioClip",
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
"Background","Billboard", "Box",
|
|
|
|
"Collision", "Color", "ColorInterpolator",
|
|
|
|
"Cone", "Coordinate",
|
|
|
|
"CoordinateInterpolator", "Cylinder",
|
|
|
|
"CylinderSensor",
|
|
|
|
"DirectionalLight",
|
|
|
|
"ElevationGrid", "Extrustion",
|
|
|
|
"Fog", "FontStyle", "Group",
|
|
|
|
"ImageTexture", "IndexedFaceSet",
|
|
|
|
"IndexedLineSet", "Inline",
|
|
|
|
"LOD", "Material", "MovieTexture",
|
|
|
|
"NavigationInfo", "Normal",
|
|
|
|
"NormalInterpolator",
|
|
|
|
"OrientationInterpolator", "PixelTexture",
|
|
|
|
"PlaneSensor", "PointLight", "PointSet",
|
|
|
|
"PositionInterpolator", "ProxmimitySensor",
|
|
|
|
"ScalarInterpolator", "Script", "Shape",
|
|
|
|
"Sound", "Sphere", "SphereSensor",
|
|
|
|
"SpotLight", "Switch", "Text",
|
|
|
|
"TextureCoordinate", "TextureTransform",
|
|
|
|
"TimeSensor", "TouchSensor", "Transform",
|
2006-05-10 21:37:03 +00:00
|
|
|
"Viewpoint", "VisibilitySensor", "WorldInfo" ]
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.namesStandard=[ "Empty", "Empty.000", "Empty.001",
|
|
|
|
"Empty.002", "Empty.003", "Empty.004",
|
|
|
|
"Empty.005", "Empty.006", "Empty.007",
|
|
|
|
"Empty.008", "Empty.009", "Empty.010",
|
|
|
|
"Empty.011", "Empty.012",
|
|
|
|
"Scene.001", "Scene.002", "Scene.003",
|
|
|
|
"Scene.004", "Scene.005", "Scene.06",
|
|
|
|
"Scene.013", "Scene.006", "Scene.007",
|
|
|
|
"Scene.008", "Scene.009", "Scene.010",
|
|
|
|
"Scene.011","Scene.012",
|
|
|
|
"World", "World.000", "World.001",
|
|
|
|
"World.002", "World.003", "World.004",
|
|
|
|
"World.005" ]
|
|
|
|
self.namesFog=[ "", "LINEAR"," EXPONENTIAL", "" ]
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
|
|
|
##########################################################
|
|
|
|
# Writing nodes routines
|
|
|
|
##########################################################
|
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
def writeHeader(self):
|
|
|
|
bfile = sys.expandpath(Blender.Get('filename'))
|
|
|
|
self.file.write("#VRML V2.0 utf8\n\n")
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.file.write("# This file was authored with Blender " \
|
|
|
|
"(http://www.blender.org/)\n")
|
2006-05-10 21:37:03 +00:00
|
|
|
self.file.write("# Blender version %s\n" % Blender.Get('version'))
|
|
|
|
self.file.write("# Blender file %s\n" % sys.basename(bfile))
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.file.write("# Exported using VRML97 exporter " \
|
|
|
|
"v1.55 (2006/01/17)\n\n")
|
2006-05-10 21:37:03 +00:00
|
|
|
|
|
|
|
def writeInline(self):
|
|
|
|
inlines = Blender.Scene.Get()
|
|
|
|
allinlines = len(inlines)
|
|
|
|
if scene != inlines[0]:
|
|
|
|
return
|
|
|
|
else:
|
2008-05-10 14:05:35 +00:00
|
|
|
for i in range(allinlines):
|
2006-05-10 21:37:03 +00:00
|
|
|
nameinline=inlines[i].getName()
|
|
|
|
if (nameinline not in self.namesStandard) and (i > 0):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("DEF %s Inline {\n" % \
|
|
|
|
(self.cleanStr(nameinline)), 1)
|
2006-05-10 21:37:03 +00:00
|
|
|
nameinline = nameinline+".wrl"
|
|
|
|
self.writeIndented("url \"%s\" \n" % nameinline)
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
self.writeIndented("\n")
|
|
|
|
|
|
|
|
def writeScript(self):
|
|
|
|
textEditor = Blender.Text.Get()
|
|
|
|
alltext = len(textEditor)
|
2008-05-10 14:05:35 +00:00
|
|
|
for i in range(alltext):
|
2006-05-10 21:37:03 +00:00
|
|
|
nametext = textEditor[i].getName()
|
|
|
|
nlines = textEditor[i].getNLines()
|
|
|
|
if (self.proto == 1):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
if (nametext == "proto" or nametext == "proto.js" or \
|
|
|
|
nametext == "proto.txt") and (nlines != None):
|
2006-05-10 21:37:03 +00:00
|
|
|
nalllines = len(textEditor[i].asLines())
|
|
|
|
alllines = textEditor[i].asLines()
|
2008-05-10 14:05:35 +00:00
|
|
|
for j in range(nalllines):
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented(alllines[j] + "\n")
|
|
|
|
elif (self.proto == 0):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
if (nametext == "route" or nametext == "route.js" or \
|
|
|
|
nametext == "route.txt") and (nlines != None):
|
2006-05-10 21:37:03 +00:00
|
|
|
nalllines = len(textEditor[i].asLines())
|
|
|
|
alllines = textEditor[i].asLines()
|
2008-05-10 14:05:35 +00:00
|
|
|
for j in range(nalllines):
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented(alllines[j] + "\n")
|
|
|
|
self.writeIndented("\n")
|
|
|
|
|
|
|
|
def writeViewpoint(self, thisObj):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# NOTE: The transform node above this will take care of
|
|
|
|
# the position and orientation of the camera
|
2006-05-10 21:37:03 +00:00
|
|
|
context = scene.getRenderingContext()
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
ratio = float(context.imageSizeY()) / float(context.imageSizeX())
|
|
|
|
temp = ratio * 16 / thisObj.data.getLens()
|
|
|
|
lens = 2 * math.atan(temp)
|
2006-05-10 21:37:03 +00:00
|
|
|
lens = min(lens, math.pi)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
|
|
|
self.writeIndented("DEF %s Viewpoint {\n" % \
|
|
|
|
(self.cleanStr(thisObj.name)), 1)
|
2006-05-16 22:57:24 +00:00
|
|
|
self.writeIndented('description "%s" \n' % thisObj.name)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("position 0.0 0.0 0.0\n")
|
|
|
|
# Need camera to point to -y in local space to accomodate
|
|
|
|
# the transforma node above
|
|
|
|
self.writeIndented("orientation 1.0 0.0 0.0 %f\n" % (-math.pi/2.0))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("fieldOfView %.3f\n" % (lens))
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
self.writeIndented("\n")
|
|
|
|
|
|
|
|
def writeFog(self):
|
2006-05-16 22:57:24 +00:00
|
|
|
if world:
|
|
|
|
mtype = world.getMistype()
|
|
|
|
mparam = world.getMist()
|
|
|
|
grd = world.getHor()
|
2006-05-10 21:37:03 +00:00
|
|
|
grd0, grd1, grd2 = grd[0], grd[1], grd[2]
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
if (mtype == 1 or mtype == 2):
|
|
|
|
self.writeIndented("Fog {\n",1)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented('fogType "%s"\n' % self.namesFog[mtype])
|
|
|
|
self.writeIndented("color %s %s %s\n" % \
|
|
|
|
(round(grd0,self.cp), \
|
|
|
|
round(grd1,self.cp), \
|
|
|
|
round(grd2,self.cp)))
|
|
|
|
self.writeIndented("visibilityRange %s\n" % \
|
|
|
|
round(mparam[2],self.cp))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
self.writeIndented("\n")
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
|
|
|
|
def writeNavigationInfo(self, scene):
|
|
|
|
allObj = []
|
2006-12-25 09:17:23 +00:00
|
|
|
allObj = list(scene.objects)
|
2006-05-10 21:37:03 +00:00
|
|
|
headlight = "TRUE"
|
|
|
|
vislimit = 0.0
|
|
|
|
for thisObj in allObj:
|
2006-12-25 09:17:23 +00:00
|
|
|
objType=thisObj.type
|
2006-05-10 21:37:03 +00:00
|
|
|
if objType == "Camera":
|
|
|
|
vislimit = thisObj.data.getClipEnd()
|
|
|
|
elif objType == "Lamp":
|
|
|
|
headlight = "FALSE"
|
|
|
|
self.writeIndented("NavigationInfo {\n",1)
|
2006-05-16 22:57:24 +00:00
|
|
|
self.writeIndented("headlight %s\n" % headlight)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("visibilityLimit %s\n" % \
|
|
|
|
(round(vislimit,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("type [\"EXAMINE\", \"ANY\"]\n")
|
|
|
|
self.writeIndented("avatarSize [0.25, 1.75, 0.75]\n")
|
|
|
|
self.writeIndented("} \n",-1)
|
|
|
|
self.writeIndented(" \n")
|
|
|
|
|
|
|
|
def writeSpotLight(self, object, lamp):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# Note: location and orientation are handled by the
|
|
|
|
# transform node above this object
|
2006-05-16 22:57:24 +00:00
|
|
|
if world:
|
|
|
|
ambi = world.getAmb()
|
2006-05-10 21:37:03 +00:00
|
|
|
ambientIntensity = ((float(ambi[0] + ambi[1] + ambi[2]))/3)/2.5
|
|
|
|
else:
|
|
|
|
ambi = 0
|
|
|
|
ambientIntensity = 0
|
|
|
|
|
|
|
|
# compute cutoff and beamwidth
|
|
|
|
intensity=min(lamp.energy/1.75,1.0)
|
|
|
|
beamWidth=((lamp.spotSize*math.pi)/180.0)*.37;
|
|
|
|
cutOffAngle=beamWidth*1.3
|
|
|
|
|
|
|
|
radius = lamp.dist*math.cos(beamWidth)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("DEF %s SpotLight {\n" % \
|
|
|
|
self.cleanStr(object.name),1)
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("radius %s\n" % (round(radius,self.cp)))
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("ambientIntensity %s\n" % \
|
|
|
|
(round(ambientIntensity,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("intensity %s\n" % (round(intensity,self.cp)))
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("color %s %s %s\n" % \
|
|
|
|
(round(lamp.col[0],self.cp), \
|
|
|
|
round(lamp.col[1],self.cp), \
|
|
|
|
round(lamp.col[2],self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("beamWidth %s\n" % (round(beamWidth,self.cp)))
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("cutOffAngle %s\n" % \
|
|
|
|
(round(cutOffAngle,self.cp)))
|
|
|
|
# Note: point down -Y axis, transform node above will rotate
|
|
|
|
self.writeIndented("direction 0.0 -1.0 0.0\n")
|
|
|
|
self.writeIndented("location 0.0 0.0 0.0\n")
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
self.writeIndented("\n")
|
|
|
|
|
|
|
|
def writeDirectionalLight(self, object, lamp):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# Note: location and orientation are handled by the
|
|
|
|
# transform node above this object
|
2006-05-16 22:57:24 +00:00
|
|
|
if world:
|
|
|
|
ambi = world.getAmb()
|
2006-05-10 21:37:03 +00:00
|
|
|
ambientIntensity = ((float(ambi[0] + ambi[1] + ambi[2]))/3)/2.5
|
|
|
|
else:
|
|
|
|
ambi = 0
|
|
|
|
ambientIntensity = 0
|
|
|
|
|
|
|
|
intensity=min(lamp.energy/1.75,1.0)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("DEF %s DirectionalLight {\n" % \
|
|
|
|
self.cleanStr(object.name),1)
|
|
|
|
self.writeIndented("ambientIntensity %s\n" % \
|
|
|
|
(round(ambientIntensity,self.cp)))
|
|
|
|
self.writeIndented("color %s %s %s\n" % \
|
|
|
|
(round(lamp.col[0],self.cp), \
|
|
|
|
round(lamp.col[1],self.cp), \
|
|
|
|
round(lamp.col[2],self.cp)))
|
|
|
|
self.writeIndented("intensity %s\n" % \
|
|
|
|
(round(intensity,self.cp)))
|
|
|
|
# Note: point down -Y axis, transform node above will rotate
|
|
|
|
self.writeIndented("direction 0.0 -1.0 0.0\n")
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
self.writeIndented("\n")
|
|
|
|
|
|
|
|
def writePointLight(self, object, lamp):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# Note: location is at origin because parent transform node
|
|
|
|
# takes care of this
|
2006-05-16 22:57:24 +00:00
|
|
|
if world:
|
|
|
|
ambi = world.getAmb()
|
2006-05-10 21:37:03 +00:00
|
|
|
ambientIntensity = ((float(ambi[0] + ambi[1] + ambi[2]))/3)/2.5
|
|
|
|
else:
|
|
|
|
ambi = 0
|
|
|
|
ambientIntensity = 0
|
|
|
|
om = object.getMatrix()
|
|
|
|
intensity=min(lamp.energy/1.75,1.0)
|
|
|
|
radius = lamp.dist
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("DEF %s PointLight {\n" % \
|
|
|
|
self.cleanStr(object.name),1)
|
|
|
|
self.writeIndented("ambientIntensity %s\n" % \
|
|
|
|
(round(ambientIntensity,self.cp)))
|
|
|
|
self.writeIndented("color %s %s %s\n" % \
|
|
|
|
(round(lamp.col[0],self.cp), \
|
|
|
|
round(lamp.col[1],self.cp), \
|
|
|
|
round(lamp.col[2],self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("intensity %s\n" % (round(intensity,self.cp)))
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("location 0.0 0.0 0.0\n")
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("radius %s\n" % radius )
|
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
self.writeIndented("\n")
|
|
|
|
|
|
|
|
def writeNode(self, thisObj):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# Note: location and orientation are handled by the
|
|
|
|
# transform node above this object
|
2006-05-10 21:37:03 +00:00
|
|
|
objectname=str(thisObj.getName())
|
|
|
|
if objectname in self.namesStandard:
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.writeIndented("%s {\n" % objectname,1)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# May need to check that the direction is done right
|
|
|
|
self.writeIndented("direction 0.0 -1.0 0.0\n")
|
|
|
|
self.writeIndented("location 0.0 0.0 0.0\n")
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
self.writeIndented("\n")
|
|
|
|
|
|
|
|
def secureName(self, name):
|
|
|
|
name = name + str(self.nodeID)
|
|
|
|
self.nodeID += 1
|
|
|
|
if len(name) <= 3:
|
|
|
|
newname = "_" + str(self.nodeID)
|
|
|
|
return "%s" % (newname)
|
|
|
|
else:
|
|
|
|
for bad in ['"','#',"'",',','.','[','\\',']','{','}']:
|
|
|
|
name=name.replace(bad,'_')
|
|
|
|
if name in self.namesReserved:
|
|
|
|
newname = name[0:3] + "_" + str(self.nodeID)
|
|
|
|
return "%s" % (newname)
|
|
|
|
elif name[0].isdigit():
|
|
|
|
newname = "_" + name + str(self.nodeID)
|
|
|
|
return "%s" % (newname)
|
|
|
|
else:
|
|
|
|
newname = name
|
|
|
|
return "%s" % (newname)
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def classifyMesh(self, me, ob):
|
|
|
|
self.halonode = 0
|
|
|
|
self.billnode = 0
|
|
|
|
self.facecolors = 0
|
|
|
|
self.vcolors = 0
|
|
|
|
self.tilenode = 0
|
|
|
|
self.colnode = 0
|
|
|
|
self.wire = 0
|
|
|
|
if me.faceUV:
|
|
|
|
for face in me.faces:
|
|
|
|
if (face.mode & Mesh.FaceModes['HALO']):
|
|
|
|
self.halonode = 1
|
|
|
|
if (face.mode & Mesh.FaceModes['BILLBOARD']):
|
|
|
|
self.billnode = 1
|
|
|
|
if (face.mode & Mesh.FaceModes['OBCOL']):
|
|
|
|
self.facecolors = 1
|
|
|
|
if (face.mode & Mesh.FaceModes['SHAREDCOL']):
|
|
|
|
self.vcolors = 1
|
|
|
|
if (face.mode & Mesh.FaceModes['TILES']):
|
|
|
|
self.tilenode = 1
|
|
|
|
if not (face.mode & Mesh.FaceModes['DYNAMIC']):
|
|
|
|
self.collnode = 1
|
|
|
|
if (face.mode & Mesh.FaceModes['TWOSIDE']):
|
|
|
|
self.twosided = 1
|
|
|
|
|
|
|
|
# Bit of a crufty trick, but if mesh has vertex colors
|
|
|
|
# (as a non-face property) and if first material has
|
|
|
|
# vcol paint set, we export the vertex colors
|
|
|
|
if (me.vertexColors):
|
2008-05-10 14:05:35 +00:00
|
|
|
if len(me.materials) > 0:
|
|
|
|
mat = me.materials[0]
|
2006-08-16 01:06:38 +00:00
|
|
|
if mat:
|
|
|
|
if (mat.mode & Blender.Material.Modes['VCOL_PAINT']):
|
|
|
|
self.vcolors = 1
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
|
|
|
# check if object is wireframe only
|
|
|
|
if ob.drawType == Blender.Object.DrawTypes.WIRE:
|
|
|
|
# user selected WIRE=2 on the Drawtype=Wire on (F9) Edit page
|
|
|
|
self.wire = 1
|
|
|
|
|
|
|
|
###
|
|
|
|
### The next few functions nest Collision/Billboard/Halo nodes.
|
|
|
|
### For real mesh data export, jump down to writeMeshData()
|
|
|
|
###
|
|
|
|
def writeMesh(self, ob, normals = 0):
|
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
imageMap={} # set of used images
|
|
|
|
sided={} # 'one':cnt , 'two':cnt
|
|
|
|
vColors={} # 'multi':1
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
2006-05-19 17:28:17 +00:00
|
|
|
if (len(ob.modifiers) > 0):
|
|
|
|
me = Mesh.New()
|
|
|
|
me.getFromObject(ob.name)
|
2006-07-19 13:05:11 +00:00
|
|
|
# Careful with the name, the temporary mesh may
|
|
|
|
# reuse the default name for other meshes. So we
|
|
|
|
# pick our own name.
|
|
|
|
me.name = "MOD_%s" % (ob.name)
|
2006-05-19 17:28:17 +00:00
|
|
|
else:
|
|
|
|
me = ob.getData(mesh = 1)
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.classifyMesh(me, ob)
|
|
|
|
|
|
|
|
if (self.collnode):
|
|
|
|
self.writeCollisionMesh(me, ob, normals)
|
|
|
|
return
|
2006-05-10 21:37:03 +00:00
|
|
|
else:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeRegularMesh(me, ob, normals)
|
|
|
|
return
|
|
|
|
|
|
|
|
def writeCollisionMesh(self, me, ob, normals = 0):
|
|
|
|
self.writeIndented("Collision {\n",1)
|
|
|
|
self.writeIndented("collide FALSE\n")
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("children [\n")
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeRegularMesh(me, ob, normals)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("]\n", -1)
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
|
|
|
|
def writeRegularMesh(self, me, ob, normals = 0):
|
|
|
|
if (self.billnode):
|
|
|
|
self.writeBillboardMesh(me, ob, normals)
|
|
|
|
elif (self.halonode):
|
|
|
|
self.writeHaloMesh(me, ob, normals)
|
2006-05-10 21:37:03 +00:00
|
|
|
else:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeMeshData(me, ob, normals)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def writeBillboardMesh(self, me, ob, normals = 0):
|
|
|
|
self.writeIndented("Billboard {\n",1)
|
|
|
|
self.writeIndented("axisOfRotation 0 1 0\n")
|
|
|
|
self.writeIndented("children [\n")
|
|
|
|
|
|
|
|
self.writeMeshData(me, ob, normals)
|
|
|
|
|
|
|
|
self.writeIndented("]\n", -1)
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("}\n", -1)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
|
|
|
def writeHaloMesh(self, me, ob, normals = 0):
|
|
|
|
self.writeIndented("Billboard {\n",1)
|
|
|
|
self.writeIndented("axisOfRotation 0 0 0\n")
|
|
|
|
self.writeIndented("children [\n")
|
|
|
|
|
|
|
|
self.writeMeshData(me, ob, normals)
|
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("]\n", -1)
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
###
|
|
|
|
### Here is where real mesh data is written
|
|
|
|
###
|
|
|
|
def writeMeshData(self, me, ob, normals = 0):
|
|
|
|
meshName = self.cleanStr(me.name)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
if self.meshNames.has_key(meshName):
|
|
|
|
self.writeIndented("USE ME_%s\n" % meshName, 0)
|
|
|
|
self.meshNames[meshName]+=1
|
2006-07-19 13:05:11 +00:00
|
|
|
if (self.verbose == 1):
|
|
|
|
print " Using Mesh %s (Blender mesh: %s)\n" % \
|
|
|
|
(meshName, me.name)
|
2006-11-17 16:11:03 +00:00
|
|
|
return
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.meshNames[meshName]=1
|
2006-05-10 21:37:03 +00:00
|
|
|
|
2006-07-19 13:05:11 +00:00
|
|
|
if (self.verbose == 1):
|
|
|
|
print " Writing Mesh %s (Blender mesh: %s)\n" % \
|
|
|
|
(meshName, me.name)
|
|
|
|
return
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("DEF ME_%s Group {\n" % meshName,1)
|
|
|
|
self.writeIndented("children [\n", 1)
|
|
|
|
|
|
|
|
hasImageTexture = 0
|
|
|
|
issmooth = 0
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
maters = me.materials
|
2008-05-10 14:05:35 +00:00
|
|
|
nummats = self.getNumMaterials(me)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# Vertex and Face colors trump materials and image textures
|
|
|
|
if (self.facecolors or self.vcolors):
|
2006-08-16 01:06:38 +00:00
|
|
|
if nummats > 0:
|
|
|
|
if maters[0]:
|
|
|
|
self.writeShape(ob, me, 0, None)
|
|
|
|
else:
|
|
|
|
self.writeShape(ob, me, -1, None)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
else:
|
|
|
|
self.writeShape(ob, me, -1, None)
|
|
|
|
# Do meshes with materials, possible with image textures
|
2006-08-16 01:06:38 +00:00
|
|
|
elif nummats > 0:
|
2008-05-10 14:05:35 +00:00
|
|
|
for matnum in range(len(maters)):
|
|
|
|
if maters[matnum]:
|
|
|
|
images = []
|
|
|
|
if me.faceUV:
|
|
|
|
images = self.getImages(me, matnum)
|
|
|
|
if len(images) > 0:
|
|
|
|
for image in images:
|
|
|
|
self.writeShape(ob, me, matnum, image)
|
|
|
|
else:
|
|
|
|
self.writeShape(ob, me, matnum, None)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
else:
|
|
|
|
self.writeShape(ob, me, matnum, None)
|
|
|
|
else:
|
|
|
|
if me.faceUV:
|
|
|
|
images = self.getImages(me, -1)
|
|
|
|
if len(images) > 0:
|
|
|
|
for image in images:
|
|
|
|
self.writeShape(ob, me, -1, image)
|
|
|
|
else:
|
|
|
|
self.writeShape(ob, me, -1, None)
|
|
|
|
else:
|
|
|
|
self.writeShape(ob, me, -1, None)
|
|
|
|
|
|
|
|
|
|
|
|
self.writeIndented("]\n", -1)
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
|
|
|
|
def getImages(self, me, matnum):
|
|
|
|
imageNames = {}
|
2008-05-10 14:05:35 +00:00
|
|
|
images = []
|
|
|
|
for face in me.faces:
|
|
|
|
if (matnum == -1) or (face.mat == matnum):
|
|
|
|
if (face.image):
|
|
|
|
imName = self.cleanStr(face.image.name)
|
|
|
|
if not imageNames.has_key(imName):
|
|
|
|
images.append(face.image)
|
|
|
|
imageNames[imName]=1
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
return images
|
|
|
|
|
2008-05-10 14:05:35 +00:00
|
|
|
def getNumMaterials(self, me):
|
|
|
|
# Oh silly Blender, why do you sometimes have 'None' as
|
|
|
|
# a member of the me.materials array?
|
|
|
|
num = 0
|
|
|
|
for mat in me.materials:
|
|
|
|
if mat:
|
|
|
|
num = num + 1
|
|
|
|
return num
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def writeCoordinates(self, me, meshName):
|
|
|
|
coordName = "coord_%s" % (meshName)
|
|
|
|
# look up coord name, use it if available
|
|
|
|
if self.coordNames.has_key(coordName):
|
|
|
|
self.writeIndented("coord USE %s\n" % coordName, 0)
|
|
|
|
self.coordNames[coordName]+=1
|
|
|
|
return;
|
|
|
|
|
|
|
|
self.coordNames[coordName]=1
|
2006-05-10 21:37:03 +00:00
|
|
|
|
|
|
|
#-- vertices
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("coord DEF %s Coordinate {\n" % (coordName), 1)
|
|
|
|
self.writeIndented("point [\n", 1)
|
|
|
|
meshVertexList = me.verts
|
2006-05-10 21:37:03 +00:00
|
|
|
|
|
|
|
for vertex in meshVertexList:
|
2008-05-10 14:05:35 +00:00
|
|
|
blenvert = Mathutils.Vector(vertex.co)
|
|
|
|
vrmlvert = M_blen2vrml * blenvert
|
|
|
|
self.writeUnindented("%s %s %s\n " % \
|
|
|
|
(vrmlvert[0], \
|
|
|
|
vrmlvert[1], \
|
|
|
|
vrmlvert[2]))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("]\n", -1)
|
|
|
|
self.writeIndented("}\n", -1)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("\n")
|
|
|
|
|
|
|
|
def writeShape(self, ob, me, matnum, image):
|
2006-08-16 01:06:38 +00:00
|
|
|
# Note: at this point it is assumed for matnum!=-1 that the
|
|
|
|
# material in me.materials[matnum] is not equal to 'None'.
|
|
|
|
# Such validation should be performed by the function that
|
|
|
|
# calls this one.
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("Shape {\n",1)
|
|
|
|
|
|
|
|
self.writeIndented("appearance Appearance {\n", 1)
|
|
|
|
if (matnum != -1):
|
|
|
|
mater = me.materials[matnum]
|
2008-05-10 14:05:35 +00:00
|
|
|
self.writeMaterial(mater, self.cleanStr(mater.name,''))
|
|
|
|
if (mater.mode & Blender.Material.Modes['TEXFACE']):
|
|
|
|
if image != None:
|
|
|
|
self.writeImageTexture(image.name, image.filename)
|
2006-11-17 16:11:03 +00:00
|
|
|
else:
|
|
|
|
if image != None:
|
2007-06-18 20:03:23 +00:00
|
|
|
self.writeImageTexture(image.name, image.filename)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
|
|
|
|
self.writeGeometry(ob, me, matnum, image)
|
|
|
|
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
|
|
|
|
def writeGeometry(self, ob, me, matnum, image):
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
#-- IndexedFaceSet or IndexedLineSet
|
|
|
|
meshName = self.cleanStr(me.name)
|
|
|
|
|
|
|
|
# check if object is wireframe only
|
|
|
|
if (self.wire):
|
|
|
|
ifStyle="IndexedLineSet"
|
|
|
|
else:
|
|
|
|
# user selected BOUNDS=1, SOLID=3, SHARED=4, or TEXTURE=5
|
|
|
|
ifStyle="IndexedFaceSet"
|
|
|
|
|
|
|
|
self.writeIndented("geometry %s {\n" % ifStyle, 1)
|
|
|
|
if not self.wire:
|
|
|
|
if self.twosided == 1:
|
|
|
|
self.writeIndented("solid FALSE\n")
|
|
|
|
else:
|
|
|
|
self.writeIndented("solid TRUE\n")
|
|
|
|
|
|
|
|
self.writeCoordinates(me, meshName)
|
|
|
|
self.writeCoordIndex(me, meshName, matnum, image)
|
|
|
|
self.writeTextureCoordinates(me, meshName, matnum, image)
|
|
|
|
if self.facecolors:
|
|
|
|
self.writeFaceColors(me)
|
|
|
|
elif self.vcolors:
|
|
|
|
self.writeVertexColors(me)
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
|
|
|
|
def writeCoordIndex(self, me, meshName, matnum, image):
|
|
|
|
meshVertexList = me.verts
|
|
|
|
self.writeIndented("coordIndex [\n", 1)
|
2006-05-10 21:37:03 +00:00
|
|
|
coordIndexList=[]
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
for face in me.faces:
|
|
|
|
if (matnum == -1) or (face.mat == matnum):
|
|
|
|
if (image == None) or (face.image == image):
|
2008-05-10 14:05:35 +00:00
|
|
|
cordStr=""
|
|
|
|
for v in face.verts:
|
|
|
|
indx=v.index
|
|
|
|
cordStr = cordStr + "%s " % indx
|
|
|
|
self.writeUnindented(cordStr + "-1, \n")
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("]\n", -1)
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def writeTextureCoordinates(self, me, meshName, matnum, image):
|
|
|
|
if (image == None):
|
|
|
|
return
|
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
texCoordList=[]
|
|
|
|
texIndexList=[]
|
|
|
|
j=0
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
for face in me.faces:
|
|
|
|
coordStr = ""
|
|
|
|
indexStr = ""
|
|
|
|
if (matnum == -1) or (face.mat == matnum):
|
|
|
|
if (face.image == image):
|
2008-05-10 14:05:35 +00:00
|
|
|
for i in range(len(face.verts)):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
uv = face.uv[i]
|
|
|
|
indexStr += "%s " % (j)
|
|
|
|
coordStr += "%s %s, " % \
|
|
|
|
(round(uv[0], self.tp), \
|
|
|
|
round(uv[1], self.tp))
|
|
|
|
j=j+1
|
|
|
|
indexStr += "-1"
|
|
|
|
texIndexList.append(indexStr)
|
|
|
|
texCoordList.append(coordStr)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
|
|
|
self.writeIndented("texCoord TextureCoordinate {\n", 1)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("point [\n", 1)
|
|
|
|
for coord in texCoordList:
|
|
|
|
self.writeUnindented("%s\n" % (coord))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("]\n", -1)
|
|
|
|
self.writeIndented("}\n", -1)
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("texCoordIndex [\n", 1)
|
|
|
|
for ind in texIndexList:
|
|
|
|
self.writeUnindented("%s\n" % (ind))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("]\n", -1)
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def writeFaceColors(self, me):
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("colorPerVertex FALSE\n")
|
|
|
|
self.writeIndented("color Color {\n",1)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("color [\n", 1)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
for face in me.faces:
|
2006-05-10 21:37:03 +00:00
|
|
|
if face.col:
|
|
|
|
c=face.col[0]
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
if self.verbose >= 2:
|
2006-05-10 21:37:03 +00:00
|
|
|
print "Debug: face.col r=%d g=%d b=%d" % (c.r, c.g, c.b)
|
|
|
|
|
|
|
|
aColor = self.rgbToFS(c)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeUnindented("%s,\n" % aColor)
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("]\n",-1)
|
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def writeVertexColors(self, me):
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("colorPerVertex TRUE\n")
|
|
|
|
self.writeIndented("color Color {\n",1)
|
|
|
|
self.writeIndented("color [\n\t\t\t\t\t\t", 1)
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
cols = [None] * len(me.verts)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
for face in me.faces:
|
2006-05-11 17:42:58 +00:00
|
|
|
for vind in range(len(face.v)):
|
|
|
|
vertex = face.v[vind]
|
|
|
|
i = vertex.index
|
|
|
|
if cols[i] == None:
|
|
|
|
cols[i] = face.col[vind]
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
for i in range(len(me.verts)):
|
2006-05-11 17:42:58 +00:00
|
|
|
aColor = self.rgbToFS(cols[i])
|
2006-05-18 20:47:39 +00:00
|
|
|
self.writeUnindented("%s\n" % aColor)
|
2006-05-11 17:42:58 +00:00
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("\n", 0)
|
|
|
|
self.writeIndented("]\n",-1)
|
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
|
|
|
|
def writeMaterial(self, mat, matName):
|
|
|
|
# look up material name, use it if available
|
|
|
|
if self.matNames.has_key(matName):
|
|
|
|
self.writeIndented("material USE MA_%s\n" % matName)
|
|
|
|
self.matNames[matName]+=1
|
|
|
|
return;
|
2005-05-22 18:50:46 +00:00
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
self.matNames[matName]=1
|
|
|
|
|
|
|
|
ambient = mat.amb/3
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
diffuseR, diffuseG, diffuseB = \
|
|
|
|
mat.rgbCol[0], mat.rgbCol[1],mat.rgbCol[2]
|
2006-05-16 22:57:24 +00:00
|
|
|
if world:
|
|
|
|
ambi = world.getAmb()
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
ambi0, ambi1, ambi2 = (ambi[0]*mat.amb) * 2, \
|
|
|
|
(ambi[1]*mat.amb) * 2, \
|
|
|
|
(ambi[2]*mat.amb) * 2
|
2006-05-10 21:37:03 +00:00
|
|
|
else:
|
|
|
|
ambi0, ambi1, ambi2 = 0, 0, 0
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
emisR, emisG, emisB = (diffuseR*mat.emit+ambi0) / 2, \
|
|
|
|
(diffuseG*mat.emit+ambi1) / 2, \
|
|
|
|
(diffuseB*mat.emit+ambi2) / 2
|
2006-05-10 21:37:03 +00:00
|
|
|
|
|
|
|
shininess = mat.hard/512.0
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
specR = (mat.specCol[0]+0.001) / (1.25/(mat.getSpec()+0.001))
|
|
|
|
specG = (mat.specCol[1]+0.001) / (1.25/(mat.getSpec()+0.001))
|
|
|
|
specB = (mat.specCol[2]+0.001) / (1.25/(mat.getSpec()+0.001))
|
|
|
|
transp = 1 - mat.alpha
|
2006-05-10 21:37:03 +00:00
|
|
|
matFlags = mat.getMode()
|
|
|
|
if matFlags & Blender.Material.Modes['SHADELESS']:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
ambient = 1
|
|
|
|
shine = 1
|
|
|
|
specR = emitR = diffuseR
|
|
|
|
specG = emitG = diffuseG
|
|
|
|
specB = emitB = diffuseB
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("material DEF MA_%s Material {\n" % matName, 1)
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("diffuseColor %s %s %s\n" % \
|
|
|
|
(round(diffuseR,self.cp), \
|
|
|
|
round(diffuseG,self.cp), \
|
|
|
|
round(diffuseB,self.cp)))
|
|
|
|
self.writeIndented("ambientIntensity %s\n" % \
|
|
|
|
(round(ambient,self.cp)))
|
|
|
|
self.writeIndented("specularColor %s %s %s\n" % \
|
|
|
|
(round(specR,self.cp), \
|
|
|
|
round(specG,self.cp), \
|
|
|
|
round(specB,self.cp)))
|
|
|
|
self.writeIndented("emissiveColor %s %s %s\n" % \
|
|
|
|
(round(emisR,self.cp), \
|
|
|
|
round(emisG,self.cp), \
|
|
|
|
round(emisB,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("shininess %s\n" % (round(shininess,self.cp)))
|
|
|
|
self.writeIndented("transparency %s\n" % (round(transp,self.cp)))
|
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
|
2007-06-18 20:03:23 +00:00
|
|
|
def writeImageTexture(self, name, filename):
|
2006-05-10 21:37:03 +00:00
|
|
|
if self.texNames.has_key(name):
|
|
|
|
self.writeIndented("texture USE %s\n" % self.cleanStr(name))
|
|
|
|
self.texNames[name] += 1
|
|
|
|
return
|
|
|
|
else:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("texture DEF %s ImageTexture {\n" % \
|
|
|
|
self.cleanStr(name), 1)
|
|
|
|
self.writeIndented('url "%s"\n' % \
|
2007-06-18 20:03:23 +00:00
|
|
|
filename.split("\\")[-1].split("/")[-1])
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("}\n",-1)
|
|
|
|
self.texNames[name] = 1
|
|
|
|
|
|
|
|
def writeBackground(self):
|
2006-05-16 22:57:24 +00:00
|
|
|
if world:
|
|
|
|
worldname = world.getName()
|
2006-05-10 21:37:03 +00:00
|
|
|
else:
|
|
|
|
return
|
2006-05-16 22:57:24 +00:00
|
|
|
blending = world.getSkytype()
|
|
|
|
grd = world.getHor()
|
2006-05-10 21:37:03 +00:00
|
|
|
grd0, grd1, grd2 = grd[0], grd[1], grd[2]
|
2006-05-16 22:57:24 +00:00
|
|
|
sky = world.getZen()
|
2006-05-10 21:37:03 +00:00
|
|
|
sky0, sky1, sky2 = sky[0], sky[1], sky[2]
|
|
|
|
mix0, mix1, mix2 = grd[0]+sky[0], grd[1]+sky[1], grd[2]+sky[2]
|
|
|
|
mix0, mix1, mix2 = mix0/2, mix1/2, mix2/2
|
|
|
|
if worldname in self.namesStandard:
|
|
|
|
self.writeIndented("Background {\n",1)
|
|
|
|
else:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("DEF %s Background {\n" % \
|
|
|
|
self.secureName(worldname),1)
|
2006-05-10 21:37:03 +00:00
|
|
|
# No Skytype - just Hor color
|
|
|
|
if blending == 0:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("groundColor %s %s %s\n" % \
|
|
|
|
(round(grd0,self.cp), \
|
|
|
|
round(grd1,self.cp), \
|
|
|
|
round(grd2,self.cp)))
|
|
|
|
self.writeIndented("skyColor %s %s %s\n" % \
|
|
|
|
(round(grd0,self.cp), \
|
|
|
|
round(grd1,self.cp), \
|
|
|
|
round(grd2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
# Blend Gradient
|
|
|
|
elif blending == 1:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("groundColor [ %s %s %s, " % \
|
|
|
|
(round(grd0,self.cp), \
|
|
|
|
round(grd1,self.cp), \
|
|
|
|
round(grd2,self.cp)))
|
|
|
|
self.writeIndented("%s %s %s ]\n" % \
|
|
|
|
(round(mix0,self.cp), \
|
|
|
|
round(mix1,self.cp), \
|
|
|
|
round(mix2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("groundAngle [ 1.57, 1.57 ]\n")
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("skyColor [ %s %s %s, " % \
|
|
|
|
(round(sky0,self.cp), \
|
|
|
|
round(sky1,self.cp), \
|
|
|
|
round(sky2,self.cp)))
|
|
|
|
self.writeIndented("%s %s %s ]\n" % \
|
|
|
|
(round(mix0,self.cp), \
|
|
|
|
round(mix1,self.cp), \
|
|
|
|
round(mix2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("skyAngle [ 1.57, 1.57 ]\n")
|
|
|
|
# Blend+Real Gradient Inverse
|
|
|
|
elif blending == 3:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("groundColor [ %s %s %s, " % \
|
|
|
|
(round(sky0,self.cp), \
|
|
|
|
round(sky1,self.cp), \
|
|
|
|
round(sky2,self.cp)))
|
|
|
|
self.writeIndented("%s %s %s ]\n" % \
|
|
|
|
(round(mix0,self.cp), \
|
|
|
|
round(mix1,self.cp), \
|
|
|
|
round(mix2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("groundAngle [ 1.57, 1.57 ]\n")
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("skyColor [ %s %s %s, " % \
|
|
|
|
(round(grd0,self.cp), \
|
|
|
|
round(grd1,self.cp), \
|
|
|
|
round(grd2,self.cp)))
|
|
|
|
self.writeIndented("%s %s %s ]\n" % \
|
|
|
|
(round(mix0,self.cp), \
|
|
|
|
round(mix1,self.cp), \
|
|
|
|
round(mix2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("skyAngle [ 1.57, 1.57 ]\n")
|
|
|
|
# Paper - just Zen Color
|
|
|
|
elif blending == 4:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("groundColor %s %s %s\n" % \
|
|
|
|
(round(sky0,self.cp), \
|
|
|
|
round(sky1,self.cp), \
|
|
|
|
round(sky2,self.cp)))
|
|
|
|
self.writeIndented("skyColor %s %s %s\n" % \
|
|
|
|
(round(sky0,self.cp), \
|
|
|
|
round(sky1,self.cp), \
|
|
|
|
round(sky2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
# Blend+Real+Paper - komplex gradient
|
|
|
|
elif blending == 7:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("groundColor [ %s %s %s, " % \
|
|
|
|
(round(sky0,self.cp), \
|
|
|
|
round(sky1,self.cp), \
|
|
|
|
round(sky2,self.cp)))
|
|
|
|
self.writeIndented("%s %s %s ]\n" % \
|
|
|
|
(round(grd0,self.cp), \
|
|
|
|
round(grd1,self.cp), \
|
|
|
|
round(grd2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("groundAngle [ 1.57, 1.57 ]\n")
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("skyColor [ %s %s %s, " % \
|
|
|
|
(round(sky0,self.cp), \
|
|
|
|
round(sky1,self.cp), \
|
|
|
|
round(sky2,self.cp)))
|
|
|
|
self.writeIndented("%s %s %s ]\n" % \
|
|
|
|
(round(grd0,self.cp),
|
|
|
|
round(grd1,self.cp),
|
|
|
|
round(grd2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("skyAngle [ 1.57, 1.57 ]\n")
|
|
|
|
# Any Other two colors
|
|
|
|
else:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeIndented("groundColor %s %s %s\n" % \
|
|
|
|
(round(grd0,self.cp), \
|
|
|
|
round(grd1,self.cp), \
|
|
|
|
round(grd2,self.cp)))
|
|
|
|
self.writeIndented("skyColor %s %s %s\n" % \
|
|
|
|
(round(sky0,self.cp), \
|
|
|
|
round(sky1,self.cp), \
|
|
|
|
round(sky2,self.cp)))
|
2006-05-10 21:37:03 +00:00
|
|
|
alltexture = len(worldmat)
|
2006-12-25 09:17:23 +00:00
|
|
|
for i in xrange(alltexture):
|
2006-05-10 21:37:03 +00:00
|
|
|
namemat = worldmat[i].getName()
|
2006-05-16 22:57:24 +00:00
|
|
|
pic = worldmat[i].getImage()
|
|
|
|
if pic:
|
|
|
|
# Stripped path.
|
|
|
|
pic_path= pic.filename.split('\\')[-1].split('/')[-1]
|
|
|
|
if namemat == "back":
|
|
|
|
self.writeIndented('backUrl "%s"\n' % pic_path)
|
|
|
|
elif namemat == "bottom":
|
|
|
|
self.writeIndented('bottomUrl "%s"\n' % pic_path)
|
|
|
|
elif namemat == "front":
|
|
|
|
self.writeIndented('frontUrl "%s"\n' % pic_path)
|
|
|
|
elif namemat == "left":
|
|
|
|
self.writeIndented('leftUrl "%s"\n' % pic_path)
|
|
|
|
elif namemat == "right":
|
|
|
|
self.writeIndented('rightUrl "%s"\n' % pic_path)
|
|
|
|
elif namemat == "top":
|
|
|
|
self.writeIndented('topUrl "%s"\n' % pic_path)
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeIndented("}",-1)
|
|
|
|
self.writeIndented("\n\n")
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def writeLamp(self, ob):
|
2006-12-25 09:17:23 +00:00
|
|
|
la = ob.data
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
laType = la.getType()
|
|
|
|
|
|
|
|
if laType == Lamp.Types.Lamp:
|
|
|
|
self.writePointLight(ob, la)
|
|
|
|
elif laType == Lamp.Types.Spot:
|
|
|
|
self.writeSpotLight(ob, la)
|
|
|
|
elif laType == Lamp.Types.Sun:
|
|
|
|
self.writeDirectionalLight(ob, la)
|
|
|
|
else:
|
|
|
|
self.writeDirectionalLight(ob, la)
|
|
|
|
|
|
|
|
def writeObject(self, ob):
|
|
|
|
|
|
|
|
obname = self.cleanStr(ob.name)
|
|
|
|
|
|
|
|
try:
|
|
|
|
obtype=ob.getType()
|
|
|
|
except AttributeError:
|
|
|
|
print "Error: Unable to get type info for %s" % obname
|
|
|
|
return
|
|
|
|
|
|
|
|
if self.verbose >= 1:
|
|
|
|
print "++ Writing %s object %s (Blender name: %s)\n" % \
|
|
|
|
(obtype, obname, ob.name)
|
|
|
|
|
|
|
|
# Note: I am leaving empties out for now -- the original
|
|
|
|
# script does some really weird stuff with empties
|
|
|
|
if ( (obtype != "Camera") and \
|
|
|
|
(obtype != "Mesh") and \
|
|
|
|
(obtype != "Lamp") ):
|
|
|
|
print "Info: Ignoring [%s], object type [%s] " \
|
|
|
|
"not handle yet" % (obname, obtype)
|
|
|
|
return
|
|
|
|
|
|
|
|
ob_matrix = Mathutils.Matrix(ob.getMatrix('worldspace'))
|
2008-05-10 14:05:35 +00:00
|
|
|
matrix = M_blen2vrml * ob_matrix * M_vrml2blen
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
e = matrix.rotationPart().toEuler()
|
|
|
|
|
|
|
|
v = matrix.translationPart()
|
|
|
|
(axis, angle) = self.eulToVecRot(self.deg2rad(e.x), \
|
|
|
|
self.deg2rad(e.y), \
|
|
|
|
self.deg2rad(e.z))
|
|
|
|
|
|
|
|
mrot = e.toMatrix().resize4x4()
|
|
|
|
try:
|
|
|
|
mrot.invert()
|
|
|
|
except:
|
|
|
|
print "Warning: %s has degenerate transformation!" % (obname)
|
|
|
|
return
|
|
|
|
|
|
|
|
diag = matrix * mrot
|
|
|
|
sizeX = diag[0][0]
|
|
|
|
sizeY = diag[1][1]
|
|
|
|
sizeZ = diag[2][2]
|
|
|
|
|
|
|
|
if self.verbose >= 1:
|
|
|
|
print " Transformation:\n" \
|
|
|
|
" loc: %f %f %f\n" \
|
|
|
|
" size: %f %f %f\n" \
|
|
|
|
" Rot: (%f %f %f), %f\n" % \
|
|
|
|
(v.x, v.y, v.z, \
|
|
|
|
sizeX, sizeY, sizeZ, \
|
|
|
|
axis[0], axis[1], axis[2], angle)
|
|
|
|
|
|
|
|
self.writeIndented("DEF OB_%s Transform {\n" % (obname), 1)
|
2006-11-11 19:12:43 +00:00
|
|
|
self.writeIndented("translation %f %f %f\n" % \
|
|
|
|
(v.x, v.y, v.z) )
|
|
|
|
|
|
|
|
self.writeIndented("rotation %f %f %f %f\n" % \
|
|
|
|
(axis[0],axis[1],axis[2],angle) )
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
2006-11-11 19:12:43 +00:00
|
|
|
self.writeIndented("scale %f %f %f\n" % \
|
|
|
|
(sizeX, sizeY, sizeZ) )
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
|
|
|
self.writeIndented("children [\n", 1)
|
|
|
|
|
|
|
|
self.writeObData(ob)
|
|
|
|
|
|
|
|
self.writeIndented("]\n", -1) # end object
|
|
|
|
self.writeIndented("}\n", -1) # end object
|
|
|
|
|
|
|
|
def writeObData(self, ob):
|
|
|
|
|
|
|
|
obtype = ob.getType()
|
|
|
|
|
|
|
|
if obtype == "Camera":
|
|
|
|
self.writeViewpoint(ob)
|
|
|
|
elif obtype == "Mesh":
|
|
|
|
self.writeMesh(ob)
|
|
|
|
elif obtype == "Lamp":
|
|
|
|
self.writeLamp(ob)
|
|
|
|
elif obtype == "Empty":
|
|
|
|
self.writeNode(ob)
|
|
|
|
|
|
|
|
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
##########################################################
|
|
|
|
# export routine
|
|
|
|
##########################################################
|
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
def export(self, scene, world, worldmat):
|
|
|
|
print "Info: starting VRML97 export to " + self.filename + "..."
|
|
|
|
self.writeHeader()
|
|
|
|
self.writeScript()
|
|
|
|
self.writeNavigationInfo(scene)
|
|
|
|
self.writeBackground()
|
|
|
|
self.writeFog()
|
|
|
|
self.proto = 0
|
|
|
|
allObj = []
|
2008-05-10 14:05:35 +00:00
|
|
|
if ARG == 'selected':
|
2006-12-25 09:17:23 +00:00
|
|
|
allObj = list(scene.objects.context)
|
2006-05-10 21:37:03 +00:00
|
|
|
else:
|
2006-12-25 09:17:23 +00:00
|
|
|
allObj = list(scene.objects)
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeInline()
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
for thisObj in allObj:
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
self.writeObject(thisObj)
|
|
|
|
|
2008-05-10 14:05:35 +00:00
|
|
|
if ARG != 'selected':
|
2006-05-10 21:37:03 +00:00
|
|
|
self.writeScript()
|
|
|
|
self.cleanup()
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
##########################################################
|
|
|
|
# Utility methods
|
|
|
|
##########################################################
|
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
def cleanup(self):
|
|
|
|
self.file.close()
|
|
|
|
self.texNames={}
|
|
|
|
self.matNames={}
|
|
|
|
self.indentLevel=0
|
|
|
|
print "Info: finished VRML97 export to %s\n" % self.filename
|
|
|
|
|
|
|
|
def cleanStr(self, name, prefix='rsvd_'):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
"""cleanStr(name,prefix) - try to create a valid VRML DEF \
|
|
|
|
name from object name"""
|
2006-05-10 21:37:03 +00:00
|
|
|
|
|
|
|
newName=name[:]
|
|
|
|
if len(newName) == 0:
|
|
|
|
self.nNodeID+=1
|
|
|
|
return "%s%d" % (prefix, self.nNodeID)
|
|
|
|
|
|
|
|
if newName in self.namesReserved:
|
|
|
|
newName='%s%s' % (prefix,newName)
|
|
|
|
|
|
|
|
if newName[0].isdigit():
|
|
|
|
newName='%s%s' % ('_',newName)
|
|
|
|
|
2006-05-16 22:57:24 +00:00
|
|
|
for bad in (' ','"','#',"'",',','.','[','\\',']','{','}'):
|
2006-05-10 21:37:03 +00:00
|
|
|
newName=newName.replace(bad,'_')
|
|
|
|
return newName
|
|
|
|
|
|
|
|
def rgbToFS(self, c):
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
s = "%s %s %s" % \
|
|
|
|
(round(c.r/255.0,self.cp), \
|
|
|
|
round(c.g/255.0,self.cp), \
|
|
|
|
round(c.b/255.0,self.cp))
|
2006-05-10 21:37:03 +00:00
|
|
|
return s
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def rad2deg(self, v):
|
|
|
|
return round(v*180.0/math.pi,4)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def deg2rad(self, v):
|
|
|
|
return (v*math.pi)/180.0;
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
def eulToVecRot(self, RotX, RotY, RotZ):
|
2006-05-10 21:37:03 +00:00
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
ti = RotX*0.5
|
|
|
|
tj = RotY*0.5
|
|
|
|
th = RotZ*0.5
|
|
|
|
|
|
|
|
ci = math.cos(ti)
|
|
|
|
cj = math.cos(tj)
|
|
|
|
ch = math.cos(th)
|
|
|
|
si = math.sin(ti)
|
|
|
|
sj = math.sin(tj)
|
|
|
|
sh = math.sin(th)
|
|
|
|
cc = ci*ch
|
|
|
|
cs = ci*sh
|
|
|
|
sc = si*ch
|
|
|
|
ss = si*sh
|
|
|
|
|
|
|
|
q0 = cj*cc + sj*ss
|
|
|
|
q1 = cj*sc - sj*cs
|
|
|
|
q2 = cj*ss + sj*cc
|
|
|
|
q3 = cj*cs - sj*sc
|
|
|
|
|
|
|
|
angle = 2 * math.acos(q0)
|
|
|
|
if (math.fabs(angle) < 0.000001):
|
|
|
|
axis = [1.0, 0.0, 0.0]
|
|
|
|
else:
|
|
|
|
sphi = 1.0/math.sqrt(1.0 - (q0*q0))
|
|
|
|
axis = [q1 * sphi, q2 * sphi, q3 * sphi]
|
|
|
|
|
|
|
|
a = Mathutils.Vector(axis)
|
|
|
|
a.normalize()
|
|
|
|
return ([a.x, a.y, a.z], angle)
|
2006-05-10 21:37:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
# For writing well formed VRML code
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
#----------------------------------
|
2006-05-10 21:37:03 +00:00
|
|
|
def writeIndented(self, s, inc=0):
|
|
|
|
if inc < 1:
|
|
|
|
self.indentLevel = self.indentLevel + inc
|
|
|
|
|
|
|
|
self.file.write( self.indentLevel*"\t" + s)
|
|
|
|
|
|
|
|
if inc > 0:
|
|
|
|
self.indentLevel = self.indentLevel + inc
|
|
|
|
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
# Sometimes better to not have too many
|
|
|
|
# tab characters in a long list, for file size
|
|
|
|
#----------------------------------
|
|
|
|
def writeUnindented(self, s):
|
|
|
|
self.file.write(s)
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
|
|
|
##########################################################
|
|
|
|
# Callbacks, needed before Main
|
|
|
|
##########################################################
|
|
|
|
|
|
|
|
def select_file(filename):
|
2006-05-16 22:57:24 +00:00
|
|
|
if sys.exists(filename) and _safeOverwrite:
|
|
|
|
result = \
|
|
|
|
Draw.PupMenu("File Already Exists, Overwrite?%t|Yes%x1|No%x0")
|
|
|
|
if(result != 1):
|
|
|
|
return
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
if not filename.endswith(extension):
|
|
|
|
filename += extension
|
2006-01-29 19:17:53 +00:00
|
|
|
|
2006-05-10 21:37:03 +00:00
|
|
|
wrlexport=VRML2Export(filename)
|
|
|
|
wrlexport.export(scene, world, worldmat)
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
#########################################################
|
|
|
|
# main routine
|
|
|
|
#########################################################
|
|
|
|
|
2008-05-10 14:05:35 +00:00
|
|
|
try:
|
|
|
|
ARG = __script__['arg'] # user selected argument
|
|
|
|
except:
|
|
|
|
print "older version"
|
|
|
|
|
|
|
|
if Blender.Get('version') < 235:
|
|
|
|
print "Warning: VRML97 export failed, wrong blender version!"
|
|
|
|
print " You aren't running blender version 2.35 or greater"
|
|
|
|
print " download a newer version from http://blender3d.org/"
|
|
|
|
else:
|
|
|
|
if ARG == 'comp':
|
|
|
|
extension=".wrz"
|
|
|
|
from gzip import *
|
2006-05-10 21:37:03 +00:00
|
|
|
else:
|
|
|
|
extension=".wrl"
|
A fairly major revision of the VRML97 export script.
Changes include, but may not be limited to:
* Support for meshes with multiple materials/face images
* Mode modular design that more closely reflects Blender's
internal workings
* Position, scale, and orientations are now exclusively dealt
with in Transform nodes, making the math more unified and
way easier to understand.
* vertex colors either written when mesh has SHARED_COL
face property, or when mesh has vertex colors and
first material with VCOL_PAINT (a little crufty, but
maybe will try a better way later)
* Support for debugging output to the console by setting
the 'rt' button to 42 (for mild verbosity) or 43 (for more
verbosity)
* Potentially long lists like vertex coordinates, face indices,
etc. are now unindented (why potentially waste thousands of
tab characters?)
* All lines in the script are under 79 characters (as per the
python style guide).
A major revision will usually beget major bugs, so
please test, test, test to make sure I haven't broken your favorite
feature in this script! (I've done a number of tests loading
output into the Bitmanagement viewer and into 3DSMax.)
2006-05-18 17:34:41 +00:00
|
|
|
Blender.Window.FileSelector(select_file, "Export VRML97", \
|
|
|
|
sys.makename(ext=extension))
|
2008-05-10 14:05:35 +00:00
|
|
|
|