[Closed] Oh time you funny fella! SKD Render
I have a plugin that needs to change it’s geo depending the render frame. The render callback NotifyRenderBegin() is great to setup my objects. Then I call NOTIFY_PRE_RENDERFRAME at each render frame.
Now at NOTIFY_PRE_RENDERFRAME how would I get that frame number?
Thanks
I think I need to use RenderGlobalContext to get current time. I just can’t find how to use it?
I have a plugin that gets the current time in a NOTIFY_RENDER_PREEVAL callback…I’m assuming the NOTIFY_PRE_RENDERFRAME callback is similar.
Here’s how I do it:
RegisterNotification(RenderFramePre,this,NOTIFY_RENDER_PREEVAL); //this goes in your 'RenderBegin' definition
...
static void RenderFramePre(void *param, NotifyInfo *info)
{
TimeValue *t = (TimeValue*) info->callParam;
}
I tried your way and spit out a bit of debug on every rendered frame from my
RegisterNotification(NotifyPreFrameRender, this, NOTIFY_PRE_RENDERFRAME);
void SiClone::NotifyPreFrameRender(void* param, NotifyInfo *info){
TimeValue *t = (TimeValue*) info->callParam;
MCHAR Debug[256];
swprintf(Debug, _T("NotifyFrameRend Time: %i
"), t);
mprintf(Debug);
mflush();
swprintf(Debug, _T("NotifyFrameRend Time2: %i
"), GetCOREInterface()->GetTime());
mprintf(Debug);
mflush();
}
but every frame spits out the same info…
NotifyFrameRend Time: 1022700256
NotifyFrameRend Time2: 0
NotifyFrameRend Time: 1022700256
NotifyFrameRend Time2: 0
NotifyFrameRend Time: 1022700256
NotifyFrameRend Time2: 0
NotifyFrameRend Time: 1022700256
NotifyFrameRend Time2: 0
NotifyFrameRend Time: 1022700256
NotifyFrameRend Time2: 0
NotifyFrameRend Time: 1022700256
NotifyFrameRend Time2: 0
NotifyFrameRend Time: 1022700256
NotifyFrameRend Time2: 0
Any thoughts?
I have looked though the blobmesh sample to see how it deals with changes to its mesh in a pre frame render and there is no NOTIFY_PRE_RENDERFRAME call back being used??
It looks like it used…
int RenderBegin(TimeValue t, ULONG flags);
int RenderEnd(TimeValue t);
Is this Old? should I not be using
RegisterNotification(NotifyRenderBegin, this, NOTIFY_PRE_RENDER);
RegisterNotification(NotifyRenderEnd, this, NOTIFY_POST_RENDER);
RegisterNotification(NotifyPreFrameRender, this, NOTIFY_PRE_RENDERFRAME);
I’m a bit confused now.
RenderBegin and RenderEnd are only called once per render. That means if you’re rendering a sequence of images, you’ll only ever get the time of the start/end frame.
The callback I listed is called at the start of every frame, allowing you to accurately get the time of every frame rendered.
The value my callback returns is a pointer, that’s why it’s returning a long integer when you try to print to the listener. You have to dereference it to get the actual time value (sorry I should have mentioned that but I thought it was obvious ;)).
TimeValue *t = (TimeValue*)info->callParam;
mprintf(_T("Current time: %i
"), *t); //dereference the time pointer by adding a preceeding asterisk!
GetCOREInterface()->GetTime() should never be used at rendertime in order to get the current time. On a render slave, for example, it will always return “0”, because the time slider is not updated when max is running in no-UI mode, and GetCOREInterface()->GetTime() just returns the current slider time.
Also, what kind of plugin are you making? Most plugin classes have a method to update their data that passes the current time value (so you don’t need to use these render callbacks at all). For geo plugins it’s the “BuildMesh” function, for modifiers it’s the “ModifyObject” function, etc.
The plugin is a replacement for the spacer tool. The last part I’m trying to fix has to do with picking a spline that would exclude the items on render time. Like an exclude spline.
Any object pos that is inside this spline would not be replaced and render. This all works if you render a still, but if I render an animation I need to get the frame to get the spine information if the spline is animated.
I need to use the render callbacks to replace my dots with the real geo.
Yes, dumb me didn’t dereference the pointer.
The other question I was asking was what is the difference between…
int myclass::RenderBegin(TimeValue t, ULONG flags){
and
RegisterNotification(NotifyRenderEnd, this, NOTIFY_PRE_RENDER);
with all that said
TimeValue t = (TimeValue)info->callParam;
mprintf(_T(“Current time: %i
“), *t);
still spits out the same each render frame from NOTIFY_PRE_RENDERFRAME call
Current time: 1024152072
Current time: 1024152072
Current time: 1024152072
Current time: 1024152072
Current time: 1024152072
Ok, Got it!!! Sorry I missed the NOTIFY_RENDER_PREEVAL change too.
Thanks so much that works great!