http://code.google.com/p/tubras/source/detail?r=1894
Modified:
/trunk/tools/irrb/doc/export_panel.rst
/trunk/tools/irrb/doc/outgen.rst
/trunk/tools/irrb/io_export_irrlicht.py
=======================================
--- /trunk/tools/irrb/doc/export_panel.rst Mon Dec 26 10:59:32 2011
+++ /trunk/tools/irrb/doc/export_panel.rst Sat Dec 31 11:37:27 2011
@@ -21,7 +21,7 @@
"{out}/mdl/".
All file references in the generated scene and mesh files are relative
as well.
- This allows scenes to be loaded from arbitray locations as long as the
base
+ This allows scenes to be loaded from arbitrary locations as long as the
base
and relative sub-directories remain intact.
It is also worth noting that the default "mdl/" and "tex/"
sub-directories used
=======================================
--- /trunk/tools/irrb/doc/outgen.rst Mon Sep 26 10:03:18 2011
+++ /trunk/tools/irrb/doc/outgen.rst Sat Dec 31 11:37:27 2011
@@ -1,66 +1,81 @@
======================
Output File Generation
======================
+.. highlight:: cpp
+ :linenothreshold: 5
.. toctree::
:maxdepth: 2
-
-Key Points
-==========
-
-References to mesh and image locations are ALL relative.
-The relative location is based on the location of the "Output Directory"
field.
-
-Details
-=======
-
-irrb allows you to choose a single Output Directory. Depending on whether
-or not you choose to export a scene file, irrb behaves as follows:
-
-* **Create Scene File** - Not Selected. All mesh files (.irrmesh) and
- packed images are saved to the Output Directory location.
-
-* **Create Scene File** - Selected. All mesh files (.irrmesh) are saved
- to a sub-directory named **mdl** (model) underneath the Output Directory
- location. All packed textures are saved to a sub-directory named **tex**
- underneath the Output Directory location.
+References to mesh and image locations are ALL relative to the location
specified
+in the "Out Directory" option located in the **irrB** export panel. This
allows scenes to
+be loaded from arbitrary locations as long as the base and relative
sub-directories
+remain intact.
+
+**irrB** allows you to choose a single Output Directory. Depending on
whether
+or not you choose to export a scene file, **irrB** behaves as follows:
+
+ **Create Scene File** - Not Selected. All mesh files (.irrmesh) and
packed
+ images are saved to the Output Directory location.
+
+ **Create Scene File** - Selected. All mesh files (.irrmesh) are saved to
+ a sub-directory named **mdl** (model) underneath the Output Directory
location.
+ All packed textures are saved to a sub-directory named **tex** underneath
the
+ Output Directory location.
Given:
-1. You are exporting a singe scene named "test".
-2. The scene contains a single cube named "Cube", and a packed texture
named "checkers.png".
-3. The "Out Directory" is set to "c:\scenes\".
+ 1. You are exporting a singe scene named "test".
+
+ 2. The scene contains a single cube named "Cube", and a packed texture
named "checkers.png".
+
+ 3. The "Out Directory" is set to "c:\\scenes\\".
The following will be generated:
-* c:/scenes/test.irr // scene file
-* c:/scenes/mdl/Cube.irrmesh // Cube mesh
-* c:/scenes/tex/checkers.png // checkers texture
+
+ * c:/scenes/test.irr // scene file
+ * c:/scenes/mdl/Cube.irrmesh // Cube mesh
+ * c:/scenes/tex/checkers.png // checkers texture
All mesh and texture references will be relative to the "Out Directory".
In the example above, the test.irr scene file will reference the Cube mesh
as "mdl/Cube.irrmesh"::
- <node type="mesh">
+ <node type="mesh">
<attributes>
<string name="Mesh" value="mdl/Cube.irrmesh"/>
- The Cube.irrmesh file will reference the checkers texture
as "tex/checkers.png"::
-
- <buffer>
- <material bmat="uvmat:checkers.png:00100">
- <texture name="Texture1" value="tex/checkers.png"/>
-
-Note that non-packed texture references are also written relative to
the "Out Directory".
-For example, if you open and assign an existing image
("c:\myimages\patterns\brick.png")
-to the Cube UV map, the Cube.irrmesh texture reference would then look
-like::
-
- <buffer>
- <material bmat="uvmat:checkers.png:00100">
- <texture name="Texture1" value="../myimages/patterns/brick.png"/>
-
-iwalktest can be very useful for determining why a mesh isn't appearing in
a scene and/or
-why a texture isn't appearing properly. The first question to ask yourself:
-"Is the mesh/texture being loaded?". iwalktest will log mesh/texture
loading errors to
-its log file "iwalktest.log" which is located in the same directory as the
iwalktest
-executable. Windows users can also check for load errors in the iwalktest
console
-window if it is configured to be displayed (default).
+The Cube.irrmesh file will reference the checkers texture
as "tex/checkers.png"::
+
+ <buffer>
+ <material bmat="uvmat:grid.png:00100">
+ <texture name="Texture1" value="tex/grid.png"/>
+
+----
+
+Image Copying
+=============
+All non-packed texture/image files are copied to the texture directory in
order
+to maintain the integrity of the relative image references in scene nodes
+and mesh files.
+
+For example, if you open and assign an existing image
("c:\\myimages\\patterns\\bricks.png")
+to the Cube UV map, the Cube.irrmesh texture reference would then look
like::
+
+ <buffer>
+ <material bmat="uvmat:grid.png:00100">
+ <texture name="Texture1" value="tex/bricks.png"/>
+
+The original image ("c:\\myimages\\patterns\\bricks.png") is copied to the
+texture directory underneath the output directory: "{out
directory}/tex/bricks.png".
+
+Images that have the same name but are stored in different directories, are
+written to the texture directory using Blender's internally assigned file
name.
+
+----
+
+Packed Output
+=============
+**irrB** contains an option named "Pack Files" located in the export
panel. When
+selected, **irrB** exports/writes all of the scene, model, and texture
files
+following the rules outlined above. After all of the files have been
written
+and image files copied, **irrB** then packs (zip) all of the files into a
+single file and names the file "{scene name}.zip".
=======================================
--- /trunk/tools/irrb/io_export_irrlicht.py Fri Dec 30 12:56:27 2011
+++ /trunk/tools/irrb/io_export_irrlicht.py Sat Dec 31 11:37:27 2011
@@ -5217,7 +5217,7 @@
result = os.path.relpath(self.gTexDir + fileName + ext,
self.gBaseDir)
else:
- result = ls.path.relpath(fullFileName, self.gBaseDir)
+ result = os.path.relpath(fullFileName, self.gBaseDir)
result0 = result
@@ -5226,11 +5226,22 @@
result = self.gTexDir + fileName + ext
else:
result = self.gTexDir + fileName + fileExt
+
+ # replace file name with Blender's image.name to avoid dups
+ # from different directories overwriting each other.
+ dirname, fname = os.path.split(result)
+ result = '{}{}{}'.format(dirname, os.sep, imageName)
+
+ dirname, fname = os.path.split(result0)
+ result0 = '{}{}{}'.format(dirname, os.sep, imageName)
+
debug('result0: {}'.format(result0))
debug('result1: {}'.format(result))
self.gImageInfo[imageName] = (result0, result)
+
if which == 0:
return result0
+
return result
#=========================================================================