[Closed] Pause script, till radiosity complete?
Ok im trying to get radiosity to render out before my script continues on its merry way.
The problem i have currently is that i start the radiosity, and my script continues, which disables the radiosity and i get no lighting.
Ive tryed doing the following but it didnt help.
while sceneRadiosity.radiosity.doesSolutionExist() == false do (print "here")
It does allow the radiosity solution to begin, then it continues, with the same result…
Any ideas?
Cheers
Ok ive found the following notifications, but i am unshure how to get my script to add a notification,pause till it returns something.
Thanks
[left]#radiosityProcessDone: undefined
[/left]
[left]Called when the Radiosity process has finished.
[/left]
[left]
[/left]
callbacks.addScript #radiosityProcessDone [color=maroon]“function here?”[/color] id:#radiosityTest
callbacks.removeScripts id:#radiosityTest
… if i use a callback, it seems to goto an infinite loop
Anyone know why putting a function in a callback results in an infinite loop? Is there any way around this?
Thanks
ok basically it goes like this
fn fnDoSomething =
(
callbacks.removescripts #radiosityProcessDone id:#radiositydone
print "hi"
select $teapot_01 -- this is where it crashes to infiniteloop
)
on mybutton pressed do
(
sceneRadiosity.radiosity.Reset true true
sceneRadiosity.radiosity.Start()
callbacks.addScript #radiosityProcessDone "fnDoSomething()" id:#radiositydone
)
Any ideas?
Hi.
The only thing I can see is wrong is the line:
callbacks.removescripts #radiosityProcessDone "" id:#radiositydone
callbacks.removeScripts receive only two parameters, the callback type and, optionally, the event id. So it should be:
callbacks.removescripts #radiosityProcessDone id:#radiositydone
Hope that helps…
ops my bad. Yeah i have that correctly in my code, just not here on the forums.
Anyway yeah it still crashes, does this kina thing work on anyoneelse machine? Its whenever i use any form of selection it crashes…
I might be slow, but why do you register the callback AFTER pressing the button?
Isn’t it a better idea to register the callback and then run the process that might trigger it?
It might not be related to your problem, but it seems fishy…
Yeah i had tryed that too, i just thought maybe it was order dependant…
Would it be better to execute the callback when the script loads? is there an onload function or something for MAXscript?
Hey guys, ive tryed a few other ways/ideas with no succes. Can somone try somethign similar, add the callback, then select something when the callback is done in a function.
Ive tryed creating and object deleting it then selecting, this doesnt work.
Ive tryed adding in the callback manually in the script editor, this doesnt work either.
Any other ideas or theorys why it wont let me select anything or use anything with a selection.
Hi.
I’ve tried with this script:
fn fnDoSomething =
(
callbacks.removeScripts #radiosityProcessDone id:#radiosityDone
messageBox "Radiosity Process Done!"
select $*
)
rollout roTestRadiosity "RadiosityCB" width:162 height:78
(
button btnStart "Start" pos:[16,20] width:128 height:32
on btnStart pressed do (
callbacks.addScript #radiosityProcessDone "fnDoSomething()" id:#radiosityDone
sceneRadiosity.radiosity.Reset true true
sceneRadiosity.radiosity.Start()
)
)
createDialog roTestRadiosity
The first time worked fine for me, that is, the radiosity process started and when finished showed me a messagebox and then selected the teapot. But I realized that the second time I run the script, the messagebox instruction was being executed twice and then three times and so on. That’s because, for some reason (maybe because you can’t remove a callback function inside itself), the instruction:
callbacks.removeScripts #radiosityProcessDone id:radiosityDone
fails. So the script is being created every time the rollout is opened (or in your case, everytime you press the button).
So I guess you could register your callback function at the beginning, when MAX starts. This is done with the notification #postSystemStartup. And then you can remove it with #preSystemShutdown (although I don’t know if it makes sense because MAX is closing so who cares!). I guess the function that register you callback function should be placed in the script’s startup folder. This way it will be executed when MAX starts.
And that’s all I can tell you right know!. Hope it helps, someway…
HalfVector.
PS: ok, forget what I’ve said about the removeScripts issue. I was missing the # character in the notification id. I’ve edited the script above. Now it works fine for me.
hrmm ok thanks, ive tryed your script it works fine, however when i copy it into my script it crashes… Must be something else…
Edit: Ok that has helped alot, its definatley something else in my script…
EDIT: ok the problem seems to be when assign vertex colors, not when selecting stuff.
DOH! sorry about that, so now my problem is with the following line…
AssignVertexColors.ApplyNodes $
So im trying to assign vertex colors after doing my radiosity, but it doesnt like it…
Any ideas possibly do it with the vertexcolor modifier? How do i assign vertex colors using that instead of the one in the utilities panel like ive been using?
Cheers!