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 {
"./../../../oposifight/level/m1a1/pedrap1.jpg"
<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 {
"pedrap1.jpg"
<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"
WScript.Quit
else
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
Loop
FileInput.Close
FileOutPut.Close
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"