LC #42 Pipers Alley

View Full Version : callback and rendering

09-09-2009, 01:24 PM
hi all, first post in maxscript.

i have 300~ objects with names from 01 to 300, i want to show only one of them at each rendered frame. i guess i want to hide all the rest but cant find the method to tie the [hide] to current rendered frame.
now i use a callback to the slider, only after it worked i red it doesnt perform in render...
i tried with [animate on] but [hide] doesnt animate (i think) and anyways i would like to know if i can without...

btw. ignore the pad function, i ripped it from another thread ( to handle the padding in the objects name.

unRegisterTimeCallback calcVisiblityOfCloud

fn pad inp ln ch:"0" = (
inp = inp as string
while inp.count < ln do inp = ch + inp

fn calcVisiblityOfCloud =
/* PlyMesh01 - 284*/
iFrame = pad (currentTime.frame as integer) 2
hide $*plyMesh*
showMe = execute("$PlyMesh"+iFrame)
unhide showMe

registerTimeCallback calcVisiblityOfCloud

09-09-2009, 04:45 PM
Why not just animate the visibility?

Your first nine objects will need to be single numbers, not '01' but '1'.

My objects where "box1" -> "Box300" you can change the prefix in the script in the getnodeby name function.

for i=1 to 300 do
TempNode = getnodeByName ("box"+( i as string))
if ( isValidNode TempNode == true ) do
-- create Controller and set to zero
local tnCont= Bezier_Float()
tnCont.value = 0.0
animate on
-- add invisible key before and after time you want it to be visible
tnKey = addNewKey tnCont (i-1)
tnKey = addNewKey tnCont (i+1)
-- add visible key at the time you want to see it
tnKey = addNewKey tnCont (i)
tnKey.value = 1.0
-- apply controller to node
TempNode.visibility.controller = tnCont

09-09-2009, 05:24 PM
thanks, i found many useful syntax tidbits in your script.

actully, i guess hidden or invisible my script demands a diffrent method.
i have too many polygons for keeping max stable.
i need to delete and add modifiers at each frame.
i currntly use the callback mathod that ends with a call to a render frame.

so... there is no way to have things happen depending on the current frame at render time?

09-09-2009, 05:34 PM
Max does not like things changing in scene when rendering a range. If you have it working as you like on the slider, you can just call a series of individual renders, instead of trying to render a sequence.

for i= 1 to 300 do
sliderTime = i
render filename:("D:\\temp\\Fileout_"+(i as string)+".jpg")

09-09-2009, 06:35 PM
thanks so much,
just a quick typo, the render should get a outputfile: and not filename:

09-09-2009, 06:39 PM
oh yeah... Sorry about that.. That's the problem with coding directly to the forum...

CGTalk Moderation
09-09-2009, 06:39 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.