Porting plugin functionality to melange



  • On 10/02/2016 at 02:08, xxxxxxxx wrote:

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

    ---------
    Hello to the C4D plugin community.
    First some general info:
    Our project uses C4D R13 and its plugin infrastructure as a basis for HMI modelling tool.
    The models created with our product, are exported (via dedicated plugin) to a custom XML format.
    Recently I've started exploring options to do this particular step without full blown Cinema and I've discovered the Melange SDK. It essentially gives a different implementation of some C4D SDK base classes and some additional APIs.

    My idea was to use the Melange SDK (V5.1.71785) to load a C4D file (obtaining BaseDocument* ) and then passing that handle to the same code that is part of our "Export to XML" plugin.

    I've run into several challenges:
    1. It seems that melange and C4D SDK are not compatible on preprocessor level (same header names). So I couldn't specify if I want to include a C4D SDK header or a melange header. I separated the part that uses melange in another static lib, which solved that.
    2. Now after I call this lib, I get the BaseDocument* handle from a .c4d file, but when I try to pass it to the plugin code, on the first usage of any C4D class (like String , BaseContainer , etc.), I get an exception. It comes from the C4DOS symbol being NULL ( I guess C4D initializes this internal OS object on startup). So I can't use the same code as the plugin. Whenever I include some C4D SDK headers, they rely on C4DOS (duh... obvious right), but the problem is if I try to use the same code with melange, I am missing some of the headers (like c4d.h) which are exclusive to the C4D plugin SDK.

    I can try to fool it with some dummy headers - for example dummy c4d.h including the melange c4d_system.h and this is what I am trying right now, but is melange capable of providing all data access SDK functionality? Am I going even in the right direction?



  • On 11/02/2016 at 01:55, xxxxxxxx wrote:

    Hello,

    The Melange libray is used to read from and write into the c4d file format. Its classes may look like the classes of the Cinema SDK but Melange is a completely different technology. So it makes no sense to include "c4d" header files in a Melange project.

    Cinema 4D SDK code that was build using the cinema.framwork library can only work inside Cinema 4D (because the functionality relies on the C4DOS pointer that can only be provided by Cinema).

    So the only safe approach would be to rewrite your code solely using the functionality of the Melange library.

    Best wishes,
    Sebastian



  • On 11/02/2016 at 04:05, xxxxxxxx wrote:

    Thanks a lot for the answer, Sebastian. :)


Log in to reply