I made my first ‘not so big’ maxscript.
It would be great if you could give me some feedback on what could be better or things I have to keep in mind.
The function of this maxscript is loading the necessary tga’s into the right maps. It depends on the filename of a 1pxtga whether it updates or not and whitch maps.
Just a note. This maxscript is just a part of the application. There is also a javascript that saves the right tga’s out of one psd. Normalle the psd would be loaded in the maxscript, but that did not worked. Still have to found out.
It was supposed to be a realtime application so you could edit your textures in photoshop and directly see them in max. But it looks like it is not possible to run a script while working in photoshop. So now it is a action tha calls a script.
Thanks for your time.
rollout PMI "PMI" width:232 height:248
(
mapButton btn_File "Load PsdFile" pos:[16,24] width:200 height:24 toolTip:"Loads the Info FileTga"
groupBox grp_File "File" pos:[8,4] width:216 height:52
groupBox grp_LoadedMaps "Loaded Maps" pos:[8,64] width:216 height:152
editText info_diffuse "" pos:[16,88] width:200 height:24
editText info_normal "" pos:[16,120] width:200 height:24
editText info_specular "" pos:[16,152] width:200 height:24
editText info_opacity "" pos:[16,184] width:200 height:24
------------------------------------------------------------------------------
--Vars-----------------------------------------------------------------------
------------------------------------------------------------------------------
local Rollout_RealtimeTimerE
timer clock "testClock" interval:333 active:false
local PSDName = ""
local FileName = ""
local FileNamePath = ""
local InfoCodePart = ""
local Ref_Texmap = ""
------------------------------------------------------------------------------
--Events--------------------------------------------------------------------
------------------------------------------------------------------------------
on PMI open do
(
info_diffuse.readOnly = true
info_normal.readOnly = true
info_specular.readOnly = true
info_opacity.readOnly = true
info_diffuse.text = "[-] - Diffuse"
info_normal.text = "[-] - Normal"
info_specular.text = "[-] - Specular"
info_opacity.text = "[-] - Opacity"
)
-- Closing the timer when shutting down
on PMI close do
(
print "closed"
)
on btn_File picked texmap do
(
Ref_Texmap = texmap
PSDName = getFileNameFile (texmap.filename)
local FilePath = texmap.filename
FileNamePath = getFilenamePath FilePath
local TgaFiles = getFiles (FileNamePath + "*.tga")
for f in TgaFiles do
(
FileName = getFilenameFile f
local Arr_PartsFileName = filterstring FileName "_"
local CountParts = Arr_PartsFileName.count
if CountParts == 1 then
(
--Do Nothing otherwise there will ba an error
-- there is no O index
)
else
(
local CodePart = Arr_PartsFileName[CountParts-1]
local UpdatePart = Arr_PartsFileName[CountParts]
if CodePart.count == 8 and UpdatePart == "1" do
(
clock.active = true
InfoCodePart = CodePart
)
if CodePart.count == 8 and UpdatePart == "0" do
(
clock.active = false
)
)
)
)
on clock tick do
(
if(InfoCodePart[2] == "1") do
(
meditMaterials[1].diffuseMapEnable = on
meditMaterials[1].diffuseMap = Bitmaptexture fileName:(FileNamePath + PSDName + "_D.tga")
info_diffuse.text = "[+] - Diffuse"
)
if(InfoCodePart[4] == "1") do
(
meditMaterials[1].bumpMapEnable = on
meditMaterials[1].bumpMap = Normal_Bump ()
meditMaterials[1].bumpMap.normal_map = Bitmaptexture fileName:(FileNamePath + PSDName + "_N.tga")
meditMaterials[1].bumpMapAmount = 100
info_normal.text = "[+] - Normal"
)
if(InfoCodePart[6] == "1") do
(
meditMaterials[1].specularMapEnable = on
meditMaterials[1].specularMap = Bitmaptexture fileName:(FileNamePath + PSDName + "_S.tga")
info_specular.text = "[+] - Specular"
)
if(InfoCodePart[8] == "1") do
(
meditMaterials[1].opacityMapEnable = on
meditMaterials[1].opacityMap = Bitmaptexture fileName:(FileNamePath + PSDName + "_O.tga")
info_opacity.text = "[+] - Opacity"
)
stringedoe = FileNamePath + PSDName + "_" + InfoCodePart + "_0.tga"
renameFile Ref_Texmap.filename stringedoe
)
)
createDialog PMI