Creating a renderer using a video post plugin

Introduction

In this tutorial we will be setting up the basic framework for rendering images to the viewport in Cinema4D. And to test this we will be creating a VideoPost plugin that will add a new renderer, our renderer, to the list of available renderers in Cinema4D. We will then set the renderer to simply color the entire viewport red.
Before we begin make sure you have Visual Studio C++ Express Edition and Cinema4D 11.5 installed. If you do not have these tools setup then I suggest you follow through this tutorial to get your development environment setup.

Copy and Rename the Plugin Template

Create a new folder in the Cinema4D/plugins directory and call it rendererpart1. Unzip the plugin template zip file to this folder.
Right click on Visual Studio C++ Express Edition and choose "Run as Administrator". From the File menu browse to your Cinema4d/plugins/rendererpart1 folder and load the pluigntemplate.sln file.
Choose  "Build Solution" from the build menu to build the project.
Delete the myplugin.cpp file. And in the Main.cpp file remove the lines
Bool RegisterMyBitmapSaver();
and
if(!RegisterMyBitmapSaver()) return FALSE;

Creating the Renderer Plugin

Right click on the Source Code folder and choose "Add->New File". Choose "C++ File (.cpp)" and give it the name renderer.cpp. Make sure the Location path is pointing to the source folder. Mine would be c:\Program Files\MAXON\CINEMA 4D R11.5\plugins\rendererpart1\source.
Press "Add" to add the new file.

Create a VideoPostData Plugin

To start with we going to make our own renderer and register it as a VideoPostData plugin. Copy the following code to the renderer.cpp file.
#include "c4d.h"


#define ID_RENDERER 1232123  //Make sure you get your own Unique ID from the maxon plugin cafe
class RendererVideoPostData : public VideoPostData
{
public:
 virtual LONG GetRenderInfo(PluginVideoPost* node);
 virtual void ExecutePixel(PluginVideoPost* node, PixelPost* pp, LONG x, LONG subx, LONG suby);


public:
static NodeData *Alloc() { return gNew RendererVideoPostData; }


};


LONG RendererVideoPostData::GetRenderInfo(PluginVideoPost* node)
{
return VIDEOPOST_EXECUTEPIXEL; //Tell it to execute per pixel
}


void RendererVideoPostData::ExecutePixel(PluginVideoPost* node, PixelPost* pp, LONG x, LONG subx, LONG suby)
{
pp->col[0] = 1.0; //Red
pp->col[1] = 0.0;
pp->col[2] = 0.0;
}


Bool RegisterRendererVideoPostData()
{
   return RegisterVideoPostPlugin(ID_RENDERER, "My Renderer", PLUGINFLAG_VIDEOPOST_ISRENDERER, RendererVideoPostData::Alloc, "MyRenderer", 0, 0);
}
Update your Main.cpp file to have the following...
// forward declarations
Bool RegisterRendererVideoPostData();


Bool PluginStart(void)
{
RegisterRendererVideoPostData();
return TRUE;
}
Looking at the code above it simply Registers a new VideoPostPlugin and tells Cinema4D that it is a new kind of renderer via the flag PLUGINFLAG_VIDEOPOST_ISRENDERER. The code then tells Cinema4D to call it for every pixel and also in the ExecutePixel method it simply sets the resulting color to always be red.

Compile and Run the plugin

Choose Build->Build Solution from the main menu.
Right click on  the pluginTemplate project and select "Set as startup project".
Select "Debug->Start Debugging". If a dialog appears asking for an Executable then select "Browse" from the drop down menu and locate your copy of Cinema4D. Make sure to select the Cinema4D.exe. Mine is located at C:\Program Files\MAXON\CINEMA 4D R11.5\Cinema4D

Change the renderer to use yours

With Cinema4D running we now need to tell it to use your renderer whenever the render button is pushed.
From the Render menu in Cinema4D choose "Render Settings". Make sure you have the General section selected on the top left. You should now see a list of available renderers that you have in Cinema4D, Full Render, Software Preview, Hardware Preview... followed by your renderer which in this tutorial se called "MyRenderer". Select the radio button for this renderer and close the dialog.

Do a test render

From the Render menu choose "Render View". The viewport should now be a solid red color.

Conclusion

We have completed our first step to creating a renderer. In this tutorial you created your own VideoPostData plugin that gets added as a new renderer to Cinema4D. The next step is to add some code to render some of the geometry in the scene. That will be the subject of a later tutorial.

Comments

  1. Maxon CINEMA 4D Is Very Useful.To Download Click The Link...

    ReplyDelete
  2. Many thanks for sharing such incredible knowledge. It's really good for your website.
    The info on your website inspires me greatly. This website I'm bookmarked. Maintain it and thanks again.
    I'm really impressed with your writing skills, as smart as the structure of your weblog.
    Maxon CINEMA 4D Studio Crack

    ReplyDelete
  3. Thanks For Sharing, Here New Version Are Available;

    https://licensedinfo.com/maxon-cinema-4d-studio-crack/

    ReplyDelete

Post a Comment

Popular posts from this blog

Selecting a Game Engine

C++ Code Generation using T4 Templates