Cleaning the paths of textures in egg (VBSCRIPT)

Hi People,

So…I use Blender to convert my objects to EGG format.
But when I export some models for tests, I got some erros about the path of textures (the egg file store the full path of textures, and not the relative path).

Is very boring change/replace all times the relative path in a text editor, so I wrote this vbscript to change the relative paths of JPG,TGA or PNG textures.

I hope help someone, how help me…

Example of egg file before script:

<Texture> pedrap1_00_Kd.011 {
  <Scalar> envtype { MODULATE }
  <Scalar> minfilter { LINEAR_MIPMAP_LINEAR }
  <Scalar> magfilter { LINEAR_MIPMAP_LINEAR }
  <Scalar> wrap { REPEAT }

Example of egg file after script:

<Texture> pedrap1_00_Kd.011 {
  <Scalar> envtype { MODULATE }
  <Scalar> minfilter { LINEAR_MIPMAP_LINEAR }
  <Scalar> magfilter { LINEAR_MIPMAP_LINEAR }
  <Scalar> wrap { REPEAT }

Copy and save as .vbs file.
Change the EggInput parameters to complete path of your file.

'By Mauricio Cunha (aka mcunha98)
option explicit
	Dim FSO
	Dim FileInput
	Dim FileOutput
	Dim Line
	Dim Spaces
	Dim EggInput
	Dim EggOutput
	Dim TimeIni
	EggInput = "d:\oposifight\level\m1a1\@map.egg"
	EggOutput = replace(EggInput, ".egg" , ".tmp")
	Set FSO = CreateObject("Scripting.FileSystemObject")
	Set FileInput = FSO.OpenTextFile(EggInput, 1)
	if FSO.FileExists(EggInput) = false then
		msgbox "File " & EggInput & " not found !",16,"Error"
		if FSO.FileExists(EggOutPut) = true then
			FSO.DeleteFile EggOutPut,true
		end if
	end if

	Set FileOutput = FSO.OpenTextFile(EggOutput,2,true)

	TimeIni = Now		
	Do Until FileInput.AtEndOfStream
		Line = FileInput.ReadLine
		if instr(1,Line,"/") > 0 and (instr(1,Line,".jpg") > 0 or instr(1,Line,".tga") > 0 or instr(1,Line,".png") > 0) then
			Spaces = mid(Line,1,instr(Line,chr(34)))
			Line = Spaces & mid(Line, instrrev(Line, "/") + 1, len(Line))
		end if   
		FileOutput.WriteLine Line

	FSO.DeleteFile EggInput
	FSO.CopyFile EggOutPut , EggInput, True
	FSO.DeleteFile EggOutput
	Msgbox "Cleanup of " + EggInput + " completed after " & DateDiff("n",TimeIni,Now) & " minutes",48,"End of process"

if you look into your egg file… you’ll notice that the path actually are relative. it’ just that upon creating your egg files, the textures are simply not in the same folder therefore you’ll end up with those strange pathes.
a simple way to avoid this and have everything clean and lean together is to create a new directory(or folder if you’r using windows), put your texture files in there, and export your egg file into the same destination.

Believe me…

I did !
But when I open the panda application with the egg loaded, the textures (in the same folder) dont are loaded.

So, if I replace the references of paths in .egg file for simply the name of file, works fine :laughing:

well maybe i wrote it in a strange way.
if you create a new folder. put your textures in there, then create your model and load the textures you asign to it from that very folder. if you then export your egg into that folder. the pathes will be correct. at least they are for me and i see no reason why it should behave different on a different machine.

Ah…ok, I see…
Well, in the future I try it ! :wink: