StartEditorRender to my ''own'' window

On 26/06/2013 at 12:10, xxxxxxxx wrote:

For my preview window, I can EditorRender to to a view using

        bd = doc.GetActiveBaseDraw()  
        c4d.StartEditorRender(active_only=False, raybrush=False, 
            x1=0, y1=0, x2=dx2, y2=dy2, 
            bt=None, bd=bd, newthread=True)

But I like more control over this window. E.g. add my own menu and buttons.
- when using a 'New View Panel', I cannot set my own menu or buttons (I think)
- when using a dialog with a UserArea I cannot Editor Render to it, because I do not have the bd** ([BaseDraw](file:///D:/pgrooff/Documents/pim/c4d/Python%20Help%20R14/help/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseView/BaseDraw/index.html#c4d.BaseDraw)) of my dialog / User Area.

I do like the EditorRender, because I can see the progress of the rendering.
That is better than to use  RenderDocument, wait for the output and show the result in my preview window.


On 01/07/2013 at 05:56, xxxxxxxx wrote:

Ok, using a CommandPlugin, I do the following:

- Create a new viewpanel

        if (id == MY_ONOFF) :                #On/Off
                c4d.CallCommand(12544) # New View Panel...
       = doc.GetActiveBaseDraw()

- Start the EditorRender

def starteditrender (bd) : 
    if (not c4d.CheckIsRunning(c4d.CHECKISRUNNING_EDITORRENDERING)) :
        dimensions = bd.GetFrame()
        dx2 = dimensions["cr"] 
        dy2 = dimensions["cb"]
        c4d.StartEditorRender(active_only=False, raybrush=False, x1=0, y1=0, x2=dx2, y2=dy2, bt=None, bd=bd, newthread=True)
    return True

- wait for event using user input and CoreMessages

    def Command(self, id, msg) :
        if (id == MY_AASETTING) :
            if (self.GetBool(MY_ONOFF)) : starteditrender(  
            return True
    def CoreMessage(self, id, msg) :
        if ((id == c4d.EVMSG_CHANGE) or 
            (id == 651)              or    #bucket fill
            (id == 701)              or    #Clone
            (id == 12342342)) :             #Paint
            print "Redraw obv CoreMessage."
            if (self.GetBool(MY_ONOFF)) : 
        return True

However, when using the user input, in this example MY_AASETTING, the render is started, but reacting on CoreMessage nothing happens?
It looks like the editor is stopped because another request / events comes in?
I tried checking for CHECKISRUNNING_EDITORRENDERING, but that did not help.

Any suggestions?

Note: Nitroman with MagicPreview is doing this wonderful!

On 01/07/2013 at 10:15, xxxxxxxx wrote:

MagicPreview doesn't use a window.
He is using a UserArea inside of GeDialog plugin.
What he's doing is rendering the current scene to a bitmap image.
Then displaying that bitmap image in the UserArea of the GeDialog plugin.

The menu items. And the sliders are nothing special either.
They are all just standard GeDialog gizmos that the SDK provides.
Here's a thread with an example how to add menu items to a dilaog:

If you search the forums for "UserArea". You should find some threads with code in them on how to make them. But I don't remember if anyone has posted code to load bitmaps into a UA yet.
If you're having trouble finding them. Look for threads with NiklasR in them.
He has posted the most UA code in this forum.


On 01/07/2013 at 12:53, xxxxxxxx wrote:

Thanks for the answer, but I do think that Nitroman is using the EditorRender and not RenderDocument.

Using EditorRenderer you can specify whether you want to see just the final result (newthread=False) or also the progress (newthread=True). When you try EditorRendered it is exactly as Nitromans renderer.

I can use a UA to render the current scene to a bitmap image and then display it (even as a thread and thus show a progress bar).

What I like about the Editorrenderer and Nitromans preview, is that you can see the progress (the squares) of the rendering (especially with GI when it takes a long time). I do not think that you can do that using renderdocument where you can only show the resulting bitmap.

On 01/07/2013 at 13:47, xxxxxxxx wrote:

Well. To me it looks like an obvious UA. Not a window.
But hey. I could be wrong.

Have you tried e-mailing him and asking him about it?
I once e-mailed him a question a long time ago and he was pretty nice and helpful. But that was long time ago.
Now that he's charging money for his stuff. He might not be as open as he once used to be.


On 02/07/2013 at 12:01, xxxxxxxx wrote:

Hi ScottA,

Sorry to bother you again and I think it is more likely that I'm wrong.
I'll follow your proposal and send Nitroman an email.

I do agree with you that menus and sliders are easily done with a UA.
I can renderdocument to a bmp and display that bmp in the UA (using threading also).

I try to explain why I think it is not a renderdocument in a UA but in a viewpanel:
When you see the example, , and what you can test yourself, just do a starteditorrender, is that you see the progress of the render.
You see all those squares rendering and building up the final image.

When you do a renderdocument, you do not see that. You get the final result, a bmp file and you display that bmp file. You do not see the render progress.

That made me believe that renderdocument is only giving you the final result and not the progress itself. Also I did not find a way to editorrender directly to a UA.

So, because I cannot render realtime (show the progress) to a UA, that made me believe that the render is done in a viewpanel.

Regards, Pim

On 04/07/2013 at 08:40, xxxxxxxx wrote:

Yes. I see what you mean regarding seeing the rendering blocks in the plugin's window.
It very well could be a view panel window.
But the way he has it set up to turn it on/off by clicking on the window. Screams User Area to me.
So I really can't say for sure exactly what he's doing in there.

This is why I always give away the source with my freebies.
That way if anyone wants to spend the time and learn how it works. They have the code.
Hopefully he will answer your e-mail with some helpful information.


On 04/07/2013 at 12:48, xxxxxxxx wrote:

Well, I think I'm wrong on assuming he is editorrendering to another view.
This cannot be, because if you change the camera settings in the main view it is  not automatically updated in the 'preview' view and thus the render in the main view will be different from the the preview view.

His preview always renders / shows the main view. In my solution, I render what is in the preview panel, which could be different from the main view.

Could it be he uses OpenGL?

So far, no answer. I'll trigger him again next week or so.


On 04/07/2013 at 12:57, xxxxxxxx wrote:

Could it be he uses DrawScene (suggested by César )?

**Does anyone knows how to use this one?


Draw a scene into the framebuffer.

Parameters: flags  (int) – Private.
Return type: bool
Returns: Success of drawing the scene.


On 05/07/2013 at 03:42, xxxxxxxx wrote:

It's very curious, it draw the exact view of your scene when you right clic on his plugin, but not when you choose a tool who modify the display :

Note : the OpenGL is disable in the screenshot.

There is also artefact refresh when you slide a panel over it, so I still think it's a bitmap :

I was indeed thinking about DrawScene because it may draw the scene... but as pgrooff said, is there anyone who know how it works ?