creating a custom node system



  • On 15/08/2014 at 22:18, xxxxxxxx wrote:

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

    ---------
    I know that this topic may seem mad, but I want to create a system similar to xpresso, but I will process it in a different way

    now the main question, how to create a custom widget "a typical node like xpresso ones", or may be a hint to where to start from



  • On 16/08/2014 at 03:09, xxxxxxxx wrote:

    My first thought would be look into GeUserArea and then start implementing custom gui objects which represent different classes of code.  But thats as far as i go, im still learning that area of the API :)



  • On 16/08/2014 at 08:56, xxxxxxxx wrote:

    You can create xpresso node plugins too.  Why reinvent the wheel unless you have a very specific need that could not be addressed by the xpresso interface.



  • On 16/08/2014 at 10:34, xxxxxxxx wrote:

    xpresso lacks a lot of things, after all it is single threaded and lacks array holders
    just need a very simple hint of where to start "any simple custom gui example in the SDK?"



  • On 16/08/2014 at 11:59, xxxxxxxx wrote:

    To continue Eclectrik's thoughts, you will need a GeUserArea in a dialog to allow GUI for the node system (display, user interaction, actions, etc.).  The nodes themselves can be represented as classes however you want.  I'd suggest a base node class containing all of the general node data and methods from which your other nodes can be derived.  Connections should be a class used for each connection and stored in the nodes either as an array or a pointer list or something similar so that connections are independent of the nodes themselves.  You will need a direction tree to go from start to end of the node processing.  Consider whether your nodal system always starts with a single node, ends with a single output node, or allows for multiple starts and/or multiple outputs.



  • On 16/08/2014 at 13:07, xxxxxxxx wrote:

    seems like a nightmare xD, I guess I will do it in Qt and embed it somehow



  • On 16/08/2014 at 13:34, xxxxxxxx wrote:

    Qt?



  • On 16/08/2014 at 13:50, xxxxxxxx wrote:

    http://qt-project.org/



  • On 16/08/2014 at 14:43, xxxxxxxx wrote:

    Ah!  First thing that i thought was QuickTime, was confused :D

    I have to be honest i`m still trying to get my head around how the custom GUI etc stuff works in C4D, without many solid examples ( at least that i can find ) it is really really difficult to put the different parts of the puzzle together..

    But in saying that - for me its been like that with everything in the api, its like a maze.  Once you know how it works you realise it is actually really simple.  Give people more and better example code and practical reference material Maxon guys ffs!!!  I cant stress that enough!!  I could have saved literally weeks if id had the knowledge i have now, laid out in an organised and accessible way, to learn from.

    Anyway, i completely digress.  The point i was going to make was, maybe its worthwhile learning the GeUserArea stuff.  If you use an alternative framework such as Qt for UI, youre still going to have to implement all the object classes, data classes, etc etc..  So why not :)



  • On 16/08/2014 at 17:52, xxxxxxxx wrote:

    And, as a warning, interfacing OpenGL Qt with Cinema 4D is not a done deal.  I have had no success and it appears that others have had similar issues getting them to play well together.



  • On 18/08/2014 at 07:47, xxxxxxxx wrote:

    Howdy,

    If by chance you can get in touch with David Farmer (darf), he may be able to offer you some advice, as he had started a plugin for R7 called Blunt Trauma that was a node based expression plugin.

    Adios,
    Cactus Dan



  • On 18/08/2014 at 09:31, xxxxxxxx wrote:

    @Robert I think I know the way to put Qt UI inside Cinema4D  , testing it today

    @Cactus Dan does he have any website or email so I contact him?



  • On 18/08/2014 at 09:47, xxxxxxxx wrote:

    Howdy,

    His user name here on plugin cafe is "darf". You might be able to send him a PM.

    Adios,
    Cactus Dan



  • On 18/08/2014 at 13:54, xxxxxxxx wrote:

    Hello,
    creating your own node system is an ambitious task. And as stated before you may use a GeUserArea within a GeDialog.
    So the first thing to do is to create you own dialog. You just need a dialog class based on GeDialog. An example is the ActiveObjectDialog in the SDK.

    class ExampleDialog : public GeDialog  
    {  
    public:  
      ExampleDialog()  
      {  
      
      };  
      
      virtual Bool CreateLayout()  
      {  
          SetTitle("My Node System");  
          return true;  
      }  
    };
    

    The layout of the dialog is defined in the CreateLayout function. Elements are not placed by absolute coordinates but are arranged in groups like in Cinemas *.res files. You can add Cinema's default widgets, menues and your own interactive widgets. Such a widget must be based on GeUserArea. An example is the SDKGradientArea in the SDK.

    class ExampleUserArea : public GeUserArea  
    {  
    public:  
      
      virtual void DrawMsg(Int32 x1, Int32 y1, Int32 x2, Int32 y2, const BaseContainer& msg)  
      {  
          // we will draw the widget here  
      };  
      virtual Bool InputEvent(const BaseContainer& msg)  
      {  
          // we will handle user input here  
          return true;  
      };  
    };
    

    The widget is drawn in DrawMsg :

        virtual void DrawMsg(Int32 x1, Int32 y1, Int32 x2, Int32 y2, const BaseContainer& msg)  
      {  
          OffScreenOn();  
      
          // draw background  
          DrawSetPen(Vector(0.8, 0.8, 0.8));  
          DrawRectangle(0, 0, 400, 400);  
      
          // draw a simple rectangle  
          DrawSetPen(Vector(0.4, 0.4, 0.9));  
          DrawRectangle(100, 100, 200, 200);  
      };
    

    You want to be able to interact with your nodes by clicking on them. To catch user interaction events use the InputEvent function:

        virtual Bool InputEvent(const BaseContainer& msg)  
      {  
          GeData data;  
      
          // check if mouse event  
          msg.GetParameter(DescLevel(BFM_INPUT_DEVICE), data);  
          if (data.GetInt32() == BFM_INPUT_MOUSE)  
          {  
              // check if left mouse button  
              msg.GetParameter(DescLevel(BFM_INPUT_CHANNEL), data);  
              if (data.GetInt32() == BFM_INPUT_MOUSELEFT)  
              {  
                  // now get the coordinates  
                  msg.GetParameter(DescLevel(BFM_INPUT_X), data);  
                  const Int32 xCoordiante = data.GetInt32();  
      
                  msg.GetParameter(DescLevel(BFM_INPUT_Y), data);  
                  const Int32 yCoordiante = data.GetInt32();  
      
                  GePrint("UserArea hit at " + String::IntToString(xCoordiante) + " : " + String::IntToString(yCoordiante));  
              }  
          }  
      
          return true;  
      };
    

    Finally you need to use your UserArea within your dialog:

        virtual Bool CreateLayout()  
      {  
          SetTitle("My Node System");  
      
          C4DGadget * userAreaGadget = this->AddUserArea(1000, BFH_LEFT, 400, 300);  
          this->AttachUserArea(_exampleUserArea, userAreaGadget);  
      
          return true;  
      }
    

    You simply create a new C4DGadget of the type UserArea and then attach an instance of your UserArea (_exampleUserArea) to this gadget.
    Based on the user interaction you can update your node system; in DrawMsg you can draw you node system. Another thing is when you want to solve your node system; when should it be executed? This can happen when a new frame is processed; you may take a look at this thread.

    With these elements you are able to build your own fully functional GUI. But still, building your own node system is a big undertaking that needs good planning.
    Best wishes,
    Sebastian



  • On 18/08/2014 at 13:58, xxxxxxxx wrote:

    Holy hell good post ^



  • On 18/08/2014 at 15:40, xxxxxxxx wrote:

    @Sebastian really thanks a lot for this info, I really like it, will do my best to replace xpresso soon :)


Log in to reply