Triggering the IRR / reading IRR data

On 02/05/2014 at 17:32, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   14+ 
Platform:   Windows  ;   
Language(s) :     C++  ;


I can't quite figure out how to access the Interactive Render Region programmatically. Currently, I'm just trying to refresh the IRR after a view change. I set the camera, then call DrawViews(), works all fine...

...but even with DRAWFLAGS_FORCEFULLREDRAW, the IRR just switches black, and I don't see a DRAWFLAG that specifically addresses the IRR.

So, I assume that DrawViews() does not automatically refresh the IRR. But what is the correct method?

StartEditorRender() does render something into the BaseDraw, but has no flags to set that would tell the renderer to use the IRR.

Manually using the IRR settings with StartEditorRender() does not really work for me, since I can't read the IRR data (at least activation and window coordinates would be required, but I am aware that the IRR has further settings for which StartEditorRender() doesn't even have a plug).

RenderDocument() seems a better choice, since its render flags at least offer a RENDERFLAGS_IRR value. This is a heavyweight function however which requires cloning the document, using the active render data (as opposed to the IRR settings), defining two hooks, and last not least passing a bitmap to render into, which I can't deliver since I want to render into the editor's bitmap.

So, how do I trigger the IRR if necessary after a camera change?

On 26/05/2014 at 13:57, xxxxxxxx wrote:

Need to push this up once more.

I currently refresh the IRR by triggering the "Refresh" function from the menu. That DOES re-render the IRR. Unfortunately, its refresh also triggers the evaluation of the animation, which is not the desired effect in my case - all objects jump back to their animation tracks, although I just want to redraw! So, this is not a good solution.

I really need to trigger the IRR refresh in some way... but the API doesn't show me any special functions, and I can't find an example how to handle the IRR programmatically.

On 27/05/2014 at 02:14, xxxxxxxx wrote:

I would do it myself.
So, render to a bitmap and show that in a User Area. That gives you also more control over the render process (resolution, ANTIALIASING, etc.).

On 27/05/2014 at 03:27, xxxxxxxx wrote:

Originally posted by xxxxxxxx

I would do it myself.
So, render to a bitmap and show that in a User Area. That gives you also more control over the render process (resolution, ANTIALIASING, etc.).

Yes, if the render was the primary goal I would probably do that.

However, my plugin is a controller for the 3DConnexion Space Mouse. Its primary goal is to control the camera of the viewport, and trigger a redraw when necessary. Since the IRR is part of the viewport, I need to refresh exactly this IRR, with exactly the IRR settings, in the same way any camera move with the mouse does it.

I have looked into the render options in the API but I don't quite see what would refresh the IRR... or, if we need to render ourselves and then add the bitmap to the viewport, how this is supposed to be done in a C4D compliant way...

On 28/05/2014 at 03:12, xxxxxxxx wrote:

I can not reconstruct your problem. Using EventAdd() or DrawViews() from the Script Manager
refreshes the IRR, tested in R14 and R15.

On 28/05/2014 at 15:40, xxxxxxxx wrote:

I have had issues having the IRR update on change of texture image on a material even with EventAdd() and DrawViews().  It ended up requiring a call to "Reload Image" (from the context menu) after updating the image to prod an IRR update.

	// Simulate user-click on Reload Image button
	BaseShader*		pShader =	pChannel->GetShader();
	if (!pShader)
		AddToLog("Failed to retrieve Reflection Channel Shader");
		return FALSE;
	DescriptionCommand	kickCmd; =						DescID(DescLevel(BITMAPSHADER_RELOADIMAGE,DTYPE_BUTTON,0L));
	pShader->Message(MSG_DESCRIPTION_COMMAND, &kickCmd);

On 02/06/2014 at 15:29, xxxxxxxx wrote:

Ah, I think that is the solution - EventAdd()!

I was using only DrawViews() before, as documented, and while it works nicely to update one or all views, it does not refresh the IRR, at least not while using the C++ API (don't know how the ScriptManager would do "more", I have not tried Coffee or Python). I haven't found any flag in the DrawViews flag collection that sounds like IRR refresh either ("no reduction" and "full refresh" don't do it).

Adding EventAdd() after the call to DrawViews() however does the trick - the IRR gets refreshed (without any further action or explicit rendering from my side).

Thanks, this should solve the issue.