[Closed] RTT Issuse
I have been working on an slimed downed version of the RTT tool and each time I try and run the code it will error out/ not work correctly unity I evaluate the following script using Crtl-E.
fn geometry_filt = isKindOf obj Geometry
(
theGeo = selectByName title:"Select High Poly" buttonText:"Select Mesh" filter:geometry_filt showHidden:true single:true
a = $
print(a)
)
Once I do that all of the code will work correctly for the entire 3Ds Max session. It’s only after I close and reopen do these problem occur. Here is the code that I am working with. Please forgive my poor coding skills, I am still getting the hang of it. If you have any advice on code structure and setup please give it as I know my code is a bit of a mess.
-- Store the selected path so that we can use it / change it later on.
-- This needs to be up here or it will not allow the saving of the path. This will conflict with the other sctipt as I do n
Global SourceDirectoryName_STR = SourcePath_Var
-- Makes sure that we have only one window open at a time.
if (( mainRoll != undefined) and ( mainRoll.isdisplayed)) do
(destroyDialog mainRoll ) -- test if dialog exist
rollout mainRoll "Unreal Multi Tool"
(
group "RTT"
(
button butRTT "RTT"align:#left width:70 height:20
button browse "Texture Location" align:#left width:85 height:20
button hp "High Poly" align:#left width:85 height:20
button lp "Low Poly" align:#left width:85 height:20
edittext SourcePath "Export File Location :" text: "<Select Valid source path>" fieldWidth:150 align:#left readOnly:true labelOnTop:true
)
On hp pressed do
(
fn geometryHP = isKindOf obj Geometry
(
theGeo1 = selectByName title:"Select High Poly" buttonText:"Select Mesh" showHidden:false single:true
global theProjObj = theGeo1
)
)
On lp pressed do
(
fn geometryLP = isKindOf obj Geometry
(
theGeo2 = selectByName title:"Select Low Poly" buttonText:"Select Mesh" showHidden:false single:true
global theObj = theGeo2
)
)
-- set up the objects
--theObj = $SM_TestBox_LP
--theProjObj = $SM_TestBox_HP
---theProjObj.material = standard diffuseMap:(Perlin_Marble ())
on butRTT pressed do
(
-- add project modifier and projection objects
fn addProjMod lowResObj highResObjs cageOffset =
(
modMode = getCommandPanelTaskMode()
setCommandPanelTaskMode #modify
projMod = projection()
addModifier lowResObj projMod
for obj in highResObjs do
(
projMod.addObjectNode obj
)
projMod.resetCage()
projMod.pushCage cageOffset
projMod.displayCage = true
projMod.name = "ProjMod"
setCommandPanelTaskMode modMode
projMod
)
-- define variables
renderSize = 512
fileName = theObj.name + "_Diffuse.tga"
filePath = SourceDirectoryName_STR +"\\" + diff.filename
--filePath = "c:\\" + diff.filename
--This will setup the file with the correct name and format to be exported
--destinationFile = SourceDirectoryName_STR + "\\" + b + ".FBX"
-- the bake object needs to be selected
select theObj
-- set up the bake interfaces
bakeProps = theObj.INodeBakeProperties
bakeProjProps = theObj.INodeBakeProjProperties
-- add diffuse element
diff = LightingMap()
bakeProps.addBakeElement diff
-- file name
diff.filename = fileName
diff.filetype = filePath
-- map size
diff.outputSzX = renderSize
diff.outputSzY = renderSize
diff.enabled = true
-- projection
bakeProjProps.enabled = true
bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
-- open and close RTT
macros.run "Render" "BakeDialog"
destroyDialog gTextureBakeDialog
-- do the render
curBM = bitmap renderSize renderSize
render rendertype:#bakeSelected frame:0 to:curBM vfb:true cancelled:&wasCanceled
close curBM
)
on browse pressed do
(
--Get the location of where we want to export the file to.
SourcePath_Var = getSavePath caption:"Please select a Folder to export";
--If there is no path selected promt the user to select a path.
if SourcePath_Var == undefined then messagebox "Please select an Export location";
-- This stores the soruce path as a string.
else SourcePath.text = SourceDirectoryName_STR
)
)
createDialog mainRoll 175 450
I am pretty sure that it is not working because I am failing to initialize something but I am not sure what that is. I am however pretty sure that my issues are with the following lines of code as they do the same thing as the code I first posted, they just do it on a button click.
On hp pressed do
(
fn geometryHP = isKindOf obj Geometry
(
theGeo1 = selectByName title:"Select High Poly" buttonText:"Select Mesh" showHidden:false single:true
global theProjObj = theGeo1
)
)
On lp pressed do
(
fn geometryLP = isKindOf obj Geometry
(
theGeo2 = selectByName title:"Select Low Poly" buttonText:"Select Mesh" showHidden:false single:true
global theObj = theGeo2
)
)
Any and all advice would be welcomed and greatly appreciated.
you need something like that
on browse pressed do
(
--Get the location of where we want to export the file to.
SourcePath_Var = getSavePath caption:"Please select a Folder to export";
--If there is no path selected promt the user to select a path.
if SourcePath_Var == undefined then messagebox "Please select an Export location"
-- This stores the soruce path as a string.
else
(
SourcePath.text = SourcePath_Var
SourceDirectoryName_STR = SourcePath_Var
)
)
and in your line
filePath = SourceDirectoryName_STR +"\\" + diff.filename
diff is not defined yet.
But in general is not user friendly. Rtt must be the last button, not the first, if you need to define the Low poly, High Poly and destiny. Or the user doesnt know if he define the Low or High Poly or not…
Use Try()catch() to protect your code or be care of using undefined variables
I will give that a try and post back if it works. I know the buttons are a bit of a mess right now, I was just more concerned with getting something up and working. I have been working on it in steps and this is where I just happen to be. Last night I did not even have the buttons but hard coded variables that looked for the objects by name.
But the advice is good never the less and I will move things around so that it reads better and is more user friendly.
Okay I tried the changes and the following ones seemed to work.
on browse pressed do
(
--Get the location of where we want to export the file to.
SourcePath_Var = getSavePath caption:"Please select a Folder to export";
--If there is no path selected promt the user to select a path.
if SourcePath_Var == undefined then messagebox "Please select an Export location";
-- This stores the soruce path as a string.
else
(
SourcePath.text = SourcePath_Var
SourceDirectoryName_STR = SourcePath_Var
)
)
But now when the bake is finished it always fails to save the bitmap. I think this has something to do with your suggestion
filePath = SourceDirectoryName_STR +"\\" + diff.filename
But I am also not sure what to with it. I have tried moving some things around, creating new variables, and basically trying anything I can think of to get this to work. I will post back if I get anything working.
as i said before, thea variable diff is undefined, son it cannot have properties.
the variable filepath looks like is only the path so it can be
SourceDirectoryName_STR +"\\"
Okay I have tried that and it looks like it is working but every time now it will not save out the image. No matter what I do. I am still messing around with the code but here is what I have so far.
-- Store the selected path so that we can use it / change it later on.
-- This needs to be up here or it will not allow the saving of the path. This will conflict with the other sctipt as I do n
Global SourceDirectoryName_STR = SourcePath_Var
-- Makes sure that we have only one window open at a time.
if (( mainRoll != undefined) and ( mainRoll.isdisplayed)) do
(destroyDialog mainRoll ) -- test if dialog exist
rollout mainRoll "Unreal Multi Tool"
(
group "RTT"
(
button hp "High Poly" align:#left width:85 height:20
button lp "Low Poly" align:#left width:85 height:20
button browse "Texture Location" align:#left width:85 height:20
edittext SourcePath "Export File Location :" text: "<Select Valid source path>" fieldWidth:150 align:#left readOnly:true labelOnTop:true
button butRTT "RTT"align:#left width:70 height:20
)
On hp pressed do
(
fn geometryHP = isKindOf obj Geometry
(
theGeo1 = selectByName title:"Select High Poly" buttonText:"Select Mesh" showHidden:false single:true
global theProjObj = theGeo1
)
)
On lp pressed do
(
fn geometryLP = isKindOf obj Geometry
(
theGeo2 = selectByName title:"Select Low Poly" buttonText:"Select Mesh" showHidden:false single:true
global theObj = theGeo2
)
)
-- set up the objects
--theObj = $SM_TestBox_LP
--theProjObj = $SM_TestBox_HP
---theProjObj.material = standard diffuseMap:(Perlin_Marble ())
on butRTT pressed do
(
-- add project modifier and projection objects
fn addProjMod lowResObj highResObjs cageOffset =
(
modMode = getCommandPanelTaskMode()
setCommandPanelTaskMode #modify
projMod = projection()
addModifier lowResObj projMod
for obj in highResObjs do
(
projMod.addObjectNode obj
)
projMod.resetCage()
projMod.pushCage cageOffset
projMod.displayCage = true
projMod.name = "ProjMod"
setCommandPanelTaskMode modMode
projMod
)
-- define variables
renderSize = 512
fileName = theObj.name + ".tga"
filePath = SourceDirectoryName_STR +"\\"
--filePath = SourceDirectoryName_STR +"\\" --+ diff.filename
--This will setup the file with the correct name and format to be exported
--destinationFile = SourceDirectoryName_STR + "\\" + b + ".FBX"
-- the bake object needs to be selected
select theObj
-- set up the bake interfaces
bakeProps = theObj.INodeBakeProperties
bakeProjProps = theObj.INodeBakeProjProperties
-- add diffuse element
diff = LightingMap()
bakeProps.addBakeElement diff
-- file name
diff.filename = fileName
diff.fileType = filePath
-- map size
diff.outputSzX = renderSize
diff.outputSzY = renderSize
diff.enabled = true
-- projection
bakeProjProps.enabled = true
bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
-- open and close RTT
macros.run "Render" "BakeDialog"
destroyDialog gTextureBakeDialog
-- do the render
curBM = bitmap renderSize renderSize
render rendertype:#bakeSelected frame:0 to:curBM vfb:true cancelled:&wasCanceled
close curBM
)
on browse pressed do
(
--Get the location of where we want to export the file to.
SourcePath_Var = getSavePath caption:"Please select a Folder to export";
--If there is no path selected promt the user to select a path.
if SourcePath_Var == undefined then messagebox "Please select an Export location";
-- This stores the soruce path as a string.
else
(
SourcePath.text = SourcePath_Var
SourceDirectoryName_STR = SourcePath_Var
)
)
)
createDialog mainRoll 175 450
Everything is working fine now except for it not saving the file correctly. Ahh man this is really getting to, because you fix one thing and another thing breaks.
try something like this
diff.fileType = (path + obj.name + suffix + ".png")
Tried that and it’s still not working at all and I have no idea as to why.I have been looking at this THREAD
I am doing pretty much the same thing but I just made my script work on my objects using buttons. But still not matter what I tweak, or what I change this still does not work. It renders out just fine and the values are even being written correctly(As far as I can see)but I just do not get why this does not save. From what I can see everything looks correct but I have ran out of ideas on what it could be. Again here is the code that I have currently working with.
-- Store the selected path so that we can use it / change it later on.
-- This needs to be up here or it will not allow the saving of the path. This will conflict with the other sctipt as I do n
Global SourceDirectoryName_STR = SourcePath_Var
-- Makes sure that we have only one window open at a time.
if (( mainRoll != undefined) and ( mainRoll.isdisplayed)) do
(destroyDialog mainRoll ) -- test if dialog exist
rollout mainRoll "Unreal Multi Tool"
(
group "RTT"
(
button hp "High Poly" align:#left width:85 height:20
button lp "Low Poly" align:#left width:85 height:20
button browse "Texture Location" align:#left width:85 height:20
edittext SourcePath "Export File Location :" text: "<Select Valid source path>" fieldWidth:150 align:#left readOnly:true labelOnTop:true
button butRTT "RTT"align:#left width:70 height:20
)
On hp pressed do
(
fn geometryHP = isKindOf obj Geometry
(
theGeo1 = selectByName title:"Select High Poly" buttonText:"Select Mesh" showHidden:false single:true
global theProjObj = theGeo1
print(theGeo1)
)
)
On lp pressed do
(
fn geometryLP = isKindOf obj Geometry
(
theGeo2 = selectByName title:"Select Low Poly" buttonText:"Select Mesh" showHidden:false single:true
global theObj = theGeo2
print(theGeo2)
)
)
on butRTT pressed do
(
-- add project modifier and projection objects
fn addProjMod lowResObj highResObjs cageOffset =
(
modMode = getCommandPanelTaskMode()
setCommandPanelTaskMode #modify
projMod = projection()
addModifier lowResObj projMod
for obj in highResObjs do
(
projMod.addObjectNode obj
)
projMod.resetCage()
projMod.pushCage cageOffset
projMod.displayCage = true
projMod.name = "ProjMod"
setCommandPanelTaskMode modMode
projMod
)
-- define variables
renderSize = 512
fileName = theObj.name + ".tga"
print(fileName)
filePath =SourceDirectoryName_STR --+ diff.filename
--filePath = SourceDirectoryName_STR +"\\" --+ diff.filename
print(filePath)
--This will setup the file with the correct name and format to be exported
--destinationFile = SourceDirectoryName_STR + "\\" + b + ".FBX"
-- the bake object needs to be selected
select theObj
-- set up the bake interfaces
bakeProps = theObj.INodeBakeProperties
bakeProjProps = theObj.INodeBakeProjProperties
-- add diffuse element
diff = LightingMap()
bakeProps.addBakeElement diff
-- file name
diff.filename = fileName
diff.fileType = filePath
-- map size
diff.outputSzX = renderSize
diff.outputSzY = renderSize
diff.enabled = true
-- projection
bakeProjProps.enabled = true
bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
-- open and close RTT
macros.run "Render" "BakeDialog"
destroyDialog gTextureBakeDialog
-- do the render
curBM = bitmap renderSize renderSize
render rendertype:#bakeSelected frame:0 to:curBM vfb:true cancelled:&wasCanceled
close curBM
)
on browse pressed do
(
--Get the location of where we want to export the file to.
SourcePath_Var = getSavePath caption:"Please select a Folder to export";
--If there is no path selected promt the user to select a path.
if SourcePath_Var == undefined then
(
messagebox "Please select an Export location";
)
-- This stores the soruce path as a string.
else
(
SourcePath.text = SourcePath_Var
--SourceDirectoryName_STR = SourcePath_Var
)
)
)
createDialog mainRoll 175 450
What I do not get is why this part does not work as I am doing pretty much the same thing as the code I found below.
-- define variables
renderSize = 512
fileName = theObj.name + "_Diffuse.tif"
filePath = "c:\\" + diff.filename
-- add diffuse element
diff = DiffuseMap()
bakeProps.addBakeElement diff
-- file name
diff.filename = fileName
diff.filetype = filePath
Even now if I change the filePath variable in my code to say “C:\” it still errors out with can not create a bitmap. I just do not get it at all. I have been trying at this all day and I still do not get why this does not work.
Just looking at a bake script I wrote some time back and I recall having trouble getting it to save. Here’s what I set…
local validFile = (substituteString file "/" "\\")
bakeTexture.filename = filenameFromPath validFile
bakeTexture.fileType = validFile
look what i changed in your code
on butRTT pressed do
(
-- add project modifier and projection objects
fn addProjMod lowResObj highResObjs cageOffset =
(
modMode = getCommandPanelTaskMode()
setCommandPanelTaskMode #modify
projMod = projection()
addModifier lowResObj projMod
for obj in highResObjs do
(
projMod.addObjectNode obj
)
projMod.resetCage()
projMod.pushCage cageOffset
projMod.displayCage = true
projMod.name = "ProjMod"
setCommandPanelTaskMode modMode
projMod
)
-- define variables
renderSize = 512
fileName = theObj.name + ".png"
print(fileName)
filePath = SourceDirectoryName_STR --+ diff.filename
--filePath = SourceDirectoryName_STR +"\\" --+ diff.filename
print(filePath)
--This will setup the file with the correct name and format to be exported
--destinationFile = SourceDirectoryName_STR + "\\" + b + ".FBX"
-- set up the bake interfaces
bakeProps = theObj.INodeBakeProperties
bakeProps.removeAllBakeElements()
bakeProjProps = theObj.INodeBakeProjProperties
-- add diffuse element
diff = LightingMap()
-- file name
diff.filename = fileName
diff.fileType = filePath + filename
-- map size
diff.outputSzX = renderSize
diff.outputSzY = renderSize
diff.enabled = true
diff.shadowsOn =true --enable shadows
diff.filterOn = true --enable filtering
bakeProps.addBakeElement diff --add first element
bakeProps.bakeEnabled = true --enabling baking
bakeProps.bakeChannel = 1 --channel to bake
bakeProps.nDilations = 1 --expand the texture a bit
-- projection
bakeProjProps.enabled = true
bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
-- open and close RTT
-- macros.run "Render" "BakeDialog"
-- destroyDialog gTextureBakeDialog
-- the bake object needs to be selected
select theObj
-- do the render
render rendertype:#bakeSelected frame:0 vfb:off progressBar:true outputSize:[renderSize, renderSize] cancelled:&wasCanceled
)
on browse pressed do
(
--Get the location of where we want to export the file to.
SourcePath_Var = getSavePath caption:"Please select a Folder to export";
--If there is no path selected promt the user to select a path.
if SourcePath_Var == undefined then
(
messagebox "Please select an Export location";
)
-- This stores the soruce path as a string.
else
(
SourcePath.text = SourcePath_Var + "\\"
SourceDirectoryName_STR = SourcePath.text
)
)
That works exactly the way that I wanted it to…
:bowdown:
Ahh you have no idea how happy this just made me as I have been hitting nothing but dead ends all day. Thanks again for all of the help I will keep updating as I get more and more done. Here is the working code that I have now incase anyone in the future might need it.
-- Store the selected path so that we can use it / change it later on.
-- This needs to be up here or it will not allow the saving of the path. This will conflict with the other sctipt as I do n
-- Makes sure that we have only one window open at a time.
if (( mainRoll != undefined) and ( mainRoll.isdisplayed)) do
(destroyDialog mainRoll ) -- test if dialog exist
rollout mainRoll "Unreal Multi Tool"
(
group "RTT"
(
button hp "High Poly" align:#left width:85 height:20
button lp "Low Poly" align:#left width:85 height:20
button browse "Texture Location" align:#left width:85 height:20
edittext SourcePath "Export File Location :" text: "<Select Valid source path>" fieldWidth:150 align:#left readOnly:true labelOnTop:true
button butRTT "RTT"align:#left width:70 height:20
)
On hp pressed do
(
fn geometryHP = isKindOf obj Geometry
(
theGeo1 = selectByName title:"Select High Poly" buttonText:"Select Mesh" showHidden:false single:true
global theProjObj = theGeo1
print(theGeo1)
)
)
On lp pressed do
(
fn geometryLP = isKindOf obj Geometry
(
theGeo2 = selectByName title:"Select Low Poly" buttonText:"Select Mesh" showHidden:false single:true
global theObj = theGeo2
print(theGeo2)
)
)
-- set up the objects
--theObj = $SM_TestBox_LP
--theProjObj = $SM_TestBox_HP
on butRTT pressed do
(
-- add project modifier and projection objects
fn addProjMod lowResObj highResObjs cageOffset =
(
modMode = getCommandPanelTaskMode()
setCommandPanelTaskMode #modify
projMod = projection()
addModifier lowResObj projMod
for obj in highResObjs do
(
projMod.addObjectNode obj
)
projMod.resetCage()
projMod.pushCage cageOffset
projMod.displayCage = true
projMod.name = "ProjMod"
setCommandPanelTaskMode modMode
projMod
)
-- define variables
renderSize = 512
fileName = theObj.name + ".tga"
print(fileName)
filePath = SourceDirectoryName_STR
print(filePath)
-- the bake object needs to be selected
select theObj
-- set up the bake interfaces
bakeProps = theObj.INodeBakeProperties
bakeProps.removeAllBakeElements()
bakeProjProps = theObj.INodeBakeProjProperties
-- add diffuse element
diff = LightingMap()
-- file name
diff.filename = fileName
diff.fileType = filePath + filename
-- map size
diff.outputSzX = renderSize
diff.outputSzY = renderSize
diff.enabled = true
--New options that I need to look up what they do.
diff.shadowsOn =true --enable shadows
diff.filterOn = true --enable filtering
bakeProps.addBakeElement diff --add first element
bakeProps.bakeEnabled = true --enabling baking
bakeProps.bakeChannel = 1 --channel to bake
bakeProps.nDilations = 1 --expand the texture a bit
-- projection
bakeProjProps.enabled = true
bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
-- open and close RTT
macros.run "Render" "BakeDialog"
destroyDialog gTextureBakeDialog
-- do the render
curBM = bitmap renderSize renderSize
render rendertype:#bakeSelected frame:0 to:curBM vfb:true cancelled:&wasCanceled
close curBM
)
on browse pressed do
(
--Get the location of where we want to export the file to.
SourcePath_Var = getSavePath caption:"Please select a Folder to export";
--If there is no path selected promt the user to select a path.
if SourcePath_Var == undefined then
(
messagebox "Please select an Export location";
)
-- This stores the soruce path as a string.
else
(
SourcePath.text = SourcePath_Var + "\\"
SourceDirectoryName_STR = SourcePath.text
)
)
)
createDialog mainRoll 175 450
i think you should read this help page from autodesk:
help page
and read the render to texture code (search “Macro_BakeTextures.mcr” in your computer).
I dont understand why you open and close the render to texture window.
Thanks for the link. I have been looking at that page as well as the RTT macro script inside of 3Ds Max for reference as well. I guess I just needed a bit longer to digest and understand the code as now I have multiple maps baking on various button clicks.
For now I open and close the RTT window so that I can make sure that everything is working. Again I like to work in steps, starting out small and going bigger and bigger. This way I understand more of what is happening behind the scenes. As soon as I have everything working the way that I want it, I will then remove them as they are not needed.
Ahh I feel so dumb but the code that I posted above will not work unless you add the following line of code to the top of the code.
Global SourceDirectoryName_STR = SourcePath_Var
I must have removed it at some point and I just found out, after almost losing my sanity, that 3Ds Max must keep Global variables in memory even if you are not using them. It makes sense now but when I went back to work today after closing my 3Ds Max session I was almost certain someone was messing with me until I figured this out…Anywho this is probably a well know fact to most 3Ds Max Scripting experts and is now something that I will never forget.
But its not been all in vain as I do have an update with the code. I have added some controls for for the cage displacement amount and to change the ray miss trace color. I am going to try and now work on using only one cage, as each time you press the render button you get a new cage and that is not really what someone would want to do in a workflow. Here is an update if anyone is interested or has any feedback. Also please keep in mind that once everything is working I will separate each section out and make sure that it is all fancy.
-- Store the selected path so that we can use it / change it later on.
-- This needs to be up here or it will not allow the saving of the path. This will conflict with the other sctipt as I do n
Global SourceDirectoryName_STR = SourcePath_Var
-- Makes sure that we have only one window open at a time.
if (( mainRoll != undefined) and ( mainRoll.isdisplayed)) do
(destroyDialog mainRoll ) -- test if dialog exist
rollout mainRoll "Unreal Multi Tool"
(
group "RTT"
(
button hp "High Poly" align:#left width:85 height:20
button lp "Low Poly" align:#left width:85 height:20
button browse "Texture Location" align:#left width:85 height:20
edittext SourcePath "Export File Location :" text: "<Select Valid source path>" fieldWidth:150 align:#left readOnly:true labelOnTop:true
button butRTT "RTT"align:#left width:70 height:20
)
On hp pressed do
(
fn geometryHP = isKindOf obj Geometry
(
theGeo1 = selectByName title:"Select High Poly" buttonText:"Select Mesh" showHidden:false single:true
global theProjObj = theGeo1
print(theGeo1)
)
)
On lp pressed do
(
fn geometryLP = isKindOf obj Geometry
(
theGeo2 = selectByName title:"Select Low Poly" buttonText:"Select Mesh" showHidden:false single:true
global theObj = theGeo2
print(theGeo2)
)
)
on butRTT pressed do
(
-- add project modifier and projection objects
fn addProjMod lowResObj highResObjs cageOffset =
(
modMode = getCommandPanelTaskMode()
setCommandPanelTaskMode #modify
projMod = projection()
addModifier lowResObj projMod
for obj in highResObjs do
(
projMod.addObjectNode obj
)
projMod.resetCage()
projMod.pushCage cageOffset
projMod.displayCage = true
projMod.name = "ProjMod"
setCommandPanelTaskMode modMode
projMod
)
-- define variables
renderSize = 512
fileName = theObj.name + ".png"
print(fileName)
filePath = SourceDirectoryName_STR --+ diff.filename
--filePath = SourceDirectoryName_STR +"\\" --+ diff.filename
print(filePath)
--This will setup the file with the correct name and format to be exported
--destinationFile = SourceDirectoryName_STR + "\\" + b + ".FBX"
-- set up the bake interfaces
bakeProps = theObj.INodeBakeProperties
bakeProps.removeAllBakeElements()
bakeProjProps = theObj.INodeBakeProjProperties
-- add diffuse element
diff = LightingMap()
-- file name
diff.filename = fileName
diff.fileType = filePath + fileName
-- map size
diff.outputSzX = renderSize
diff.outputSzY = renderSize
diff.enabled = true
diff.shadowsOn =true --enable shadows
diff.filterOn = true --enable filtering
bakeProps.addBakeElement diff --add first element
bakeProps.bakeEnabled = true --enabling baking
bakeProps.bakeChannel = 1 --channel to bake
bakeProps.nDilations = 1 --expand the texture a bit
-- projection
bakeProjProps.enabled = true
bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
-- open and close RTT
-- macros.run "Render" "BakeDialog"
-- destroyDialog gTextureBakeDialog
-- the bake object needs to be selected
select theObj
-- do the render
render rendertype:#bakeSelected frame:0 vfb:off progressBar:true outputSize:[renderSize, renderSize] cancelled:&wasCanceled
)
on browse pressed do
(
--Get the location of where we want to export the file to.
SourcePath_Var = getSavePath caption:"Please select a Folder to export";
--If there is no path selected promt the user to select a path.
if SourcePath_Var == undefined then
(
messagebox "Please select an Export location";
)
-- This stores the soruce path as a string.
else
(
SourcePath.text = SourcePath_Var + "\\"
SourceDirectoryName_STR = SourcePath.text
)
)
)
createDialog mainRoll 175 450