Changing current render RenderData [SOLVED]



  • On 09/11/2015 at 04:49, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R13-R16 
    Platform:    Mac  ;  
    Language(s) :     C++  ;

    ---------
    Hi!

    I've been trying to change the current render RenderData without success.
    There's a few posts talking about this, they seem to work if I change the GetDocumenit() RenderData, but, if I want to change the current render, when it starts, it will not affect it.

    It's a VideoPost plugin, I tried this code inside Message() listening to MSG_MULTI_RENDERNOTIFICATION, Alloc() and Execute(). If I print the RenderData pointer on Message() and Execute(), it's the same, but the values I've set are not passed to Execute().

    > This is my code:
    >
    > // Document (persistent)
    >
    > RenderData *rd = GetActiveDocument()->GetActiveRenderData();
    >
    > rd->GetDataInstance()->SetBool( RDATA_STEREO, true );
    >
    > rd->GetDataInstance()->SetFloat( RDATA_XRES, 100.0f );
    >
    > rd->Message(MSG_UPDATE);
    >
    > // Current render?
    >
    > RenderNotificationData* rnd = (RenderNotificationData* )data;
    >
    > rd = rnd->doc->GetActiveRenderData();
    >
    > rd->GetDataInstance()->SetBool( RDATA_STEREO, true );
    >
    > rd->GetDataInstance()->SetFloat( RDATA_XRES, 100.0f );
    >
    > rd->Message(MSG_UPDATE);
    >
    > // rd->SetDirty( DIRTYFLAGS_DATA );
    >
    > rnd->doc->Message(MSG_UPDATE); // not sure if need this
    >
    > GetActiveDocument()->Message(MSG_UPDATE); // not sure if need this
    >
    > EventAdd();

    There's 2 reasons I want to do that.
    One is to force a low-res render on a demo version.
    The other is to enable Stereo when certain conditions . The render is not stereo per se, but I use stereo channels to render the scene multiple times from multiple angles. I'm not sure if there's another way to do it, but I really need to render each frame multiple times and then combine them in the end, so the stereo workflow is perfect for that. I can tell the user to turn ON stereo but it sounds hacky, I would like to turn it on and off without having to force him into doing it.

    If it's not possible, can I somehow abort the render? Then I can display a dialog asking to turn it on manually and try again.
    Or better, I set the document RenderData, abort and trigger a new render.



  • On 10/11/2015 at 02:35, xxxxxxxx wrote:

    Hello,

    in Cinema 4D the "active document" is the document that is currently shown in the editor window. When Cinema renders a document, this document is typically cloned so the document rendered is not the active document (you can press "Render To Picture Viewer" and then close the current document). So one should never use GetActiveDocument() in any NodeData based plugin since such plugins will be executed in background threads, on Team Render clients or command line versions. Always use GetDocument() instead.

    When you look at RenderDocument() you see that the actual used render settings are defined in an extra BaseContainer. You can get this BaseContainer in a VideoPost with GetRenderData() from the Render member of the VideoPostStruct. So you could try to edit the settings with SetRenderData() but I'm not sure if changing the resolution inside the rendering process is something that should be done.

    You can always abort the render process by returning something else than RENDERRESULT_OK in Execute(), for example RENDERRESULT_OUTOFMEMORY.

    If you want to limit the resolution of your demo, why don't you simply render only in the allowed resolution and let the rest of the image black?

    Best wishes,
    Sebastian



  • On 11/11/2015 at 15:49, xxxxxxxx wrote:

    Thanks Sebastian, worked as expected!

    The resolution area was set, but not the total canvas size. But it's not a big deal, as you suggested I can render black outside.

    This snippet did the trick for the active render, inside Message() :

    case MSG_MULTI_RENDERNOTIFICATION:
    {
    RenderNotificationData* rnd = (RenderNotificationData* )data;
    BaseContainer rd = rnd->render->GetRenderData();
    rd.SetBool( RDATA_STEREO, true );
    rd.SetFloat( RDATA_XRES, 100.0f );
    rnd->render->SetRenderData( rd );
    }


Log in to reply