How to use NewObj for arrays



  • On 08/12/2017 at 02:49, xxxxxxxx wrote:

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

    ---------
    Hi everyone.

    In cinema R19's documentation is suggested to always use cinema memory model
    (NewObj(), DeleteObj(), etc )
    https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_advice_for_developers.html
    but is not expecified how to instanciate arrays using cinema memory model, 
    i.e. instanciate a plain objet in the heap in the standard way is

    MyClass * obj = new MyClass();
    

    and using cinema memory model will be in this way

    MyClass * obj = NewObj(MyClass); 
    

    Instanciate an array in the heap in C++ standard way is

    MyClass * arrayOfMyClass = new MyClass[100]; 
    

    (just to give a quick example)
    but I can't figure out how to instanciate an array in the heap using NewObj()

    thanks in advance

    --Julio Angulo



  • On 08/12/2017 at 08:20, xxxxxxxx wrote:

    Hello and welcome to the PluginCafe forums,

    for an array of elements you should not use NewObj(). For an array of elements always use the BaseArray template class. You find some example code in arraytutorial.cpp.

    best wishes,
    Sebastian


Log in to reply