(SDK) Creating objects at rendertime


I want to create/delete a series of objects at render time. Not at the beginning/end of rendering, but at the beginning/end of each individual frame.

I have a SimpleObject2 that I tried registering with a NOTIFY_RENDER_PREEVAL callback. However, if I create objects in the resulting callback function, they don’t appear in the render…my guess is because by the time that callback is called for my SimpleObject2, all scene objects have already been iterated and so any new objects are skipped.

I noticed that if I register the same callback with the maxscript “callbacks.addscript”, the objects created in the callback function do appear in the render, probably because the maxscript callbacks object is processed prior to the iteration of all scene nodes.

Is there a straight-forward way to create objects in a node-specific callback at rendertime? Or do I have to do some kind of workaround, like calling my node’s callback function from a maxscript-created callback?


Whoops, I thought “#preRenderEval” for the maxscript version was letting me create objects at rendertime, but I was accidentally using “#preRender”. “#preRenderEval” doesn’t work either…


can you use Interface::CurRendererRenderFrame and just create the objects before it’s called then delete after and repeat for all frames.

or similar with OpenRenderer and Renderer::Render


Thanks for the suggestion…main issue is that I’m trying to do it all through callbacks so that I don’t have to control the renderer. The ideal solution would do all the object creation/deletion silently whenever the user decides to render, rather than controlling the entire process myself.


if you defined the render function by yourself , you can control everything
i wrote a channel render script , change materials between frames, every frame i called ‘render()’ manual .