Loading files and NET Server/Client!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 23/11/2010 at 15:16, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R10-R12 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    This is truly a problematic situation.  My soon-to-be-released plugin loads a set of C4D document files at startup which contain stock objects used by the generator plugin.  But when running NET Server or Client, the plugin fails specifically in loading these documents which causes Server or Client to fail and not start.

    ETA: These files are local and in the plugin's 'res' folder.  So it shouldn't be an issue with the network.  I also note that the documents seem to load (LoadDocument) but that removing the objects and appending them to an allocated AtomArray for memory storage is where the failure occurs.  Why that is is a mystery.  Maybe cloning the object would help?  There are no problems doing this with Cinema 4D,  just Net Server and Net Client.

    How am I supposed to circumvent this problem in order that the plugin can be used with Server/Client?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/11/2010 at 13:03, xxxxxxxx wrote:

    Any information on this?  I really can't sit here for two weeks with virtually no income while everyone eats turkey.

    Thanks,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/11/2010 at 13:58, xxxxxxxx wrote:

    main.cpp

    Bool PluginStart()  
    {  
      ...  
      // Greebler Demo or Registered  
      if (kdzSerial)                                            greebler =    RegisterGreebler(network, kdzSerial->mode, kdzSerial->time);  
      // Cinema 4D Demo  
      else                                                    greebler =    RegisterGreebler(network, 3, 2147483647L);  
      ...  
      return TRUE;  
    }
    

    Greebler.cpp

    // *** ****  
    // Global Registrant Method for Greebler Command plugin  
    //*---------------------------------------------------------------------------*  
    Greebler* RegisterGreebler(const Bool& network, const UCHAR& mode, const LONG& time)  
    //*---------------------------------------------------------------------------*  
    {  
      Greebler*    gree =    gNew Greebler();  
      if (!gree)            return NULL;  
    #ifdef    C4D_R12  
      if (RegisterCommandPlugin(ID_GREEBLER, String("Greebler Library Manager"), 0L, AutoBitmap("greebler.tif"), String("Greebler Library Manager"), gree))  
      {  
          if (gree->Init(network, mode, time))    return gree;  
      }  
    #else  
      if (RegisterCommandPlugin(ID_GREEBLER, String("Greebler Library Manager"), 0L, String("greebler.tif"), String("Greebler Library Manager"), gree))  
      {  
          if (gree->Init(network, mode, time))    return gree;  
      }  
    #endif  
      return NULL;  
    }  
      
    // Greebler.Init  
    // - Initialize arrays, stock objects, and custom objects  
    //*---------------------------------------------------------------------------*  
    Bool Greebler::Init(const Bool& t_network, const UCHAR& t_mode, const LONG& t_time)  
    //*---------------------------------------------------------------------------*  
    {  
      network =                                    t_network;  
      mode =                                        t_mode;  
      time =                                        t_time;  
      
      // Get Library folder from C4D Prefs container  
      if (!GetDataFolder())                        return ErrPrt("Greebler.Greebler.Init.GetDataFolder() failed!");  
      
      // Allocate Copy Array  
      copy_array =                                AtomArray::Alloc();  
      if (!copy_array)                            return ErrPrt("Greebler.Greebler.Init.copy_array failed!");  
      
      // Allocate Stock Shape Array  
      array_stock =                                AtomArray::Alloc();  
      if (!array_stock)                            return ErrPrt("Greebler.Greebler.Init.array_stock failed!");  
      
      // Load Shape objects into Arrays (memory)  
      if (network)                                return TRUE;  
      if (!LoadStockLibrary())                    return FALSE;  
      
      // Return if NET Client or Server  
      if (network)                                return TRUE;  
      
      // Create Custom Shape and Nurnie Libraries  
      Filename    fn =                            Filename(datafolder)+Filename(GeLoadString(GRES_LIB_CUSTOMSHAPES));  
      if (!library_shape.Init(fn, "ggicon"))        return FALSE;  
      fn =                                        Filename(datafolder)+Filename(GeLoadString(GRES_LIB_CUSTOMNURNIES));  
      if (!library_nurnie.Init(fn, "gnicon"))        return FALSE;  
      if (!LoadShapeLibrary())                    return FALSE;  
      if (!LoadNurnieLibrary())                    return FALSE;  
      
      return TRUE;  
    }  
      
    // Greebler.LoadStockLibrary  
    //*---------------------------------------------------------------------------*  
    Bool Greebler::LoadStockLibrary()  
    //*---------------------------------------------------------------------------*  
    {  
      // Get .c4d files in this folder  
      Filename        path =                        GeGetPluginPath()+Filename("res")+Filename("StockShapes");  
      if (!LoadItem(path, "Cube.c4d"))            return FALSE;  
      if (!LoadItem(path, "T.c4d"))                return FALSE;  
      if (!LoadItem(path, "L.c4d"))                return FALSE;  
      if (!LoadItem(path, "C.c4d"))                return FALSE;  
      if (!LoadItem(path, "H.c4d"))                return FALSE;  
      if (!LoadItem(path, "D.c4d"))                return FALSE;  
      if (!LoadItem(path, "Box.c4d"))                return FALSE;  
      if (!LoadItem(path, "CubeCC.c4d"))            return FALSE;  
      if (!LoadItem(path, "OblongOctagon.c4d"))    return FALSE;  
      return TRUE;  
    }  
    // Greebler.LoadItem  
    //*---------------------------------------------------------------------------*  
    Bool Greebler::LoadItem(const Filename& path, const Filename& file)  
    //*---------------------------------------------------------------------------*  
    {  
      // Insert Stock Library Object(s)  
      BaseDocument*    doc =    LoadDocument(path+file, SCENEFILTER_OBJECTS, NULL);  
      if (!doc)  
      {  
          MessageDialog("Greebler.Greebler.LoadItem("+file.GetString()+") failed!");  
          return ErrPrt("Greebler.Greebler.LoadItem("+file.GetString()+") failed!");  
      }  
      BaseObject*        op =    doc->GetFirstObject();  
      if (!op)  
      {  
          KillDocument(doc);  
          MessageDialog("Greebler.Greebler.LoadItem("+file.GetString()+").op failed!");  
          return ErrPrt("Greebler.Greebler.LoadItem("+file.GetString()+").op failed!");  
      }  
      BaseObject*        cop =    static_cast<BaseObject*>(op->GetClone(COPYFLAGS_0, NULL));  
      if (!cop)  
      {  
          KillDocument(doc);  
          MessageDialog("Greebler.Greebler.LoadItem("+file.GetString()+").cop failed!");  
          return ErrPrt("Greebler.Greebler.LoadItem("+file.GetString()+").cop failed!");  
      }  
      //op->Remove();  
      if (!array_stock->Append(cop))  
      {  
          KillDocument(doc);  
          MessageDialog("Greebler.Greebler.LoadItem("+file.GetString()+").array_stock.Append() failed!");  
          return ErrPrt("Greebler.Greebler.LoadItem("+file.GetString()+").array_stock.Append() failed!");  
      }  
      KillDocument(doc);  
      return TRUE;  
    }
    

    Note that the failure occurs in LoadItem(), but, despite checking every possible error, none of the MessageDialog()s is displayed.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/11/2010 at 12:41, xxxxxxxx wrote:

    Bump...

    Anything at all?  There is not a single mention of NET Client/Server in the SDK documentation that would help guide me here.  And nothing here at PluginCafe (as far as searches have revealed).

    Thanks



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/11/2010 at 02:10, xxxxxxxx wrote:

    I'm probably going to make myself look a total idiot here, so be gentle...

    Looking at your third post, you say that none of the error messages are displayed. In that case, either the call to LoadItem is successful, which it clearly isn't, or it's never called. Since it is called by LoadStockLibrary, if LoadItem is never called, LoadStockLibrary isn't being called either.

    Looking in Greebler::Init, you have these lines:

      
        // Load Shape objects into Arrays (memory)   
        if (network)                                return TRUE;   
        if (!LoadStockLibrary())                    return FALSE;   
      
        // Return if NET Client or Server   
        if (network)                                return TRUE;   
    

    How I read this is that if you're in NET Client or Server, Init returns before it ever calls LoadStockLibrary.

    Is that any use or have I completely misread the code (most likely!)?

    Steve



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/11/2010 at 07:07, xxxxxxxx wrote:

    I put that line above "if (!LoadStockLibrary())" to see if the Client crash stopped (which it did).  I also tried loading the objects in the object plugin part of the plugin to see if that helped (thus the early abort here) but no.  LoadStockLibrary() and LoadItem() are being called otherwise (and crashing the Client).  It is always bailing on array_stock->Append(op) (or cop).  array_stock has been allocated and checked (early in the code posted).  But, the message dialog never shows for an error.  The Client must be bailing rather hastily for that to happen.

    I'm currently internalizing the objects (all 36 **** of them!!!) which is a friggin' hassle.  There are 9 sets of 4 objects each with Polygon and Point selection tags.  This is what I want to do: spend all of my days off of work typing in endless numbers and hoping that there are no mistakes in all of that coding. :(


Log in to reply