[Bf-committers] Yafray export problems with images for textures

bf-committers@blender.org bf-committers@blender.org
Tue, 06 Jan 2004 08:34:48 -0600


Arne Schmitz wrote:
> Am Dienstag, 6. Januar 2004 14:57 schrieb zaz@visi.com:
> 
>>The yafray export doesn't handle relative pathnames properly.
>>For example, using an image of //textures/bumpmap.tga leads to
>>yafray complaining about not being able to find
>>//textures/bumpmap.tga.  It would be better if the exporter
>>converted the // syntax in these filenames to the directory
>>referenced by the //s.
> 
> 
> Shouldn't this better be converted to "./"? This way you keep the relative 
> directory names.
> 
Not necessarily as the yafray export directory is not
required to be relative to the directory from which the last
blender file was loaded or saved.

Supporting // for yafray export dir would be good also,
I've added that and include a full patch again.

cvs -z3 diff -u source/blender/yafray/intern/yafray_Render.cpp
Index: source/blender/yafray/intern/yafray_Render.cpp
===================================================================
RCS file: 
/cvsroot/bf-blender/blender/source/blender/yafray/intern/yafray_Render.cpp,v
retrieving revision 1.2
diff -u -r1.2 yafray_Render.cpp
--- source/blender/yafray/intern/yafray_Render.cpp      5 Jan 2004 15:58:48 
-0000       1.2
+++ source/blender/yafray/intern/yafray_Render.cpp      6 Jan 2004 14:34:27 -0000
@@ -35,14 +35,22 @@
                 clearAll();
                 return false;
         }
+
+       // Convert yafray export dir from relative path if necessary.
+       char str[FILE_MAXDIR+FILE_MAXFILE];
+       strcpy(str, U.yfexportdir);
+       BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
+
+       string xmlpath = str;
+
         // check if it exists
-       if (!BLI_exists(U.yfexportdir)) {
-               cout << "YafRay temporary xml export directory:\n" << 
U.yfexportdir << "\ndoes not exist!\n";
+       if (!BLI_exists(str)) {
+               cout << "YafRay temporary xml export directory:\n" << U.yfexportdir
+                    << "(" << str << ")" << "\ndoes not exist!\n";
                 clearAll();
                 return false;
         }

-       string xmlpath = U.yfexportdir;
  #ifdef WIN32
         imgout = xmlpath + "\\YBtest.tga";
         xmlpath += "\\YBtest.xml";
@@ -333,11 +341,14 @@
                         case TEX_IMAGE: {
                                 Image* ima = tex->ima;
                                 if (ima) {
+                                  char str[FILE_MAXDIR+FILE_MAXFILE];
                                         ostr.str("");
                                         ostr << "<shader type=\"image\" 
name=\"" << blendtex->first << "\" >\n";
                                         ostr << "\t<attributes>\n";
-                                       // image->name is full path
-                                       ostr << "\t\t<filename value=\"" << 
ima->name << "\" />\n";
+                                       // image->name is full path, but might 
be relative.
+                                       strcpy(str, ima->name);
+                                       BLI_convertstringcode(str, G.sce, 
G.scene->r.cfra);
+                                       ostr << "\t\t<filename value=\"" << str
<< "\" />\n";
                                         ostr << "\t</attributes>\n";
                                         ostr << "</shader>\n\n";
                                         xmlfile << ostr.str();


--
Todd Koeckeritz, zaz@visi.com

Surfin' the Web with an ActiveX enabled browser is kindof like having
to worry about getting shot everytime you knock on a door.