Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How To use DrawPolygonObject ?

    SDK Help
    0
    21
    11.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

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

      On 19/03/2010 at 10:51, xxxxxxxx wrote:

      i have a question related to this topic,
      in my plugin i have an atomarray with some polygon object in it, i clone all object of this array and i append this in another atom array.
      now i'dd like to draw the cloned object with some tranformation via modeling lib, but not is drawed on the screen..

      any idea ?
      Franz

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        On 06/06/2012 at 19:08, xxxxxxxx wrote:

        Originally posted by xxxxxxxx

        The problem in your code is that you allocate a Generator object, the sphere. This has not yet be processed by the drawing pipeline, no caches are being build yet. I recommend to use the GeneratePrimitive() function instead of BaseObject::Alloc(). You can cast this directly into a polygon object.

        Hi Matthias,

        I also tried your suggestion in one of my projects but I have a problem with it!

        My test code (for R12), based on your example, looks like this:

          
        DRAWRESULT BaseDrawTest::Draw(BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, BaseDrawHelp *bh)   
        {   
             if (drawpass==DRAWPASS_OBJECT)   
             {   
                  PolygonObject* sphere = NULL;   
                  sphere = (PolygonObject* )GeneratePrimitive(bh->GetDocument(), Osphere, BaseContainer(), 1.0, FALSE, NULL);   
                  if (!sphere)     return DRAWRESULT_SKIP;   
                  bd->DrawPolygonObject(bh, sphere, DRAWOBJECT_0, op, NULL);   
                  PolygonObject::Free(sphere);   
             }   
             return DRAWRESULT_OK;   
        }   
        

        Unfortunately, C4D crashes from the:

        PolygonObject::Free(sphere);
        

        Without it, it works but I have memory leaks of course!

        Edit:
        I don't know, why my code is shown with interlines here in this post.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

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

          On 06/06/2012 at 20:35, xxxxxxxx wrote:

          I allocate draw objects at the Init() of my plugin and free at Free() of my plugin.  While they exist for the entire existence of my plugin (or Cinema 4D session), they never need to be allocated/freed in the Draw() method.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

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

            On 06/06/2012 at 20:51, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            I allocate draw objects at the Init() of my plugin and free at Free() of my plugin.  While they exist for the entire existence of my plugin (or Cinema 4D session), they never need to be allocated/freed in the Draw() method.

            Yes, that makes perfect sence. I was just confused by Matthias example!
            Thank you Robert.

            Kind regards,
            Tom

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

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

              On 07/06/2012 at 09:22, xxxxxxxx wrote:

              Can you possibly explain how you do that Robert?

              All of the SDK examples use global functions to create the objects. And I'd like to try out your method.
              But when I try to create the objects inside of the Init() method. I of course, run into scope problems.
              I don't know how you are able to Draw() an object that was created inside of the Init() method.

              -ScottA

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

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

                On 07/06/2012 at 16:14, xxxxxxxx wrote:

                Declare a member of your class as a pointer to the object and use that to extend the scope to the entire class and its methods.

                  
                MyClass  
                {  
                 ...  
                PolygonObject*  drawObj;  
                }  
                  
                MyClass::MyClass()  
                {  
                drawObj = NULL;  
                }  
                  
                MyClass::Init()  
                {  
                // Whatever you are using to allocate the object  
                drawObj = PolygonObject();  
                }  
                  
                MyClass::Free()  
                {  
                PolygonObject::Free(drawObj);  
                }
                
                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

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

                  On 07/06/2012 at 16:14, xxxxxxxx wrote:

                  Originally posted by xxxxxxxx

                  Can you possibly explain how you do that Robert?

                  I second that request!

                  Originally posted by xxxxxxxx

                  All of the SDK examples use global functions to create the objects. And I'd like to try out your method.But when I try to create the objects inside of the Init() method. I of course, run into scope problems.I don't know how you are able to Draw() an object that was created inside of the Init() method.-ScottA

                  To declare the PolygonObject in the class declaration works, but I guess that's not a very good place for it.

                  I'd really like to come to know where the best place for that would be.
                  And how to do it the right way.

                  Here is my example code so far:

                    
                  /////////////////////////////////////////////////////////////   
                  // basedrawtest.cpp                                        //   
                  /////////////////////////////////////////////////////////////   
                    
                  #include "c4d.h"   
                  #include "c4d_symbols.h"   
                  #include "obasedrawtest.h"   
                    
                    
                  /////////////////////////////////////////////////////////   
                  // Class functions   
                  /////////////////////////////////////////////////////////   
                    
                  class BaseDrawTest : public ObjectData   
                  {   
                       INSTANCEOF(BaseDrawTest, ObjectData)   
                    
                       public:   
                            virtual Bool Init(GeListNode* node);   
                            virtual void Free(GeListNode* node);   
                    
                            virtual EXECUTIONRESULT Execute(BaseObject* op, BaseDocument* doc, BaseThread* bt, LONG priority, EXECUTIONFLAGS flags);   
                            virtual DRAWRESULT Draw(BaseObject* op, DRAWPASS drawpass, BaseDraw* bd, BaseDrawHelp* bh);   
                    
                            static NodeData *Alloc(void) { return gNew BaseDrawTest; }   
                    
                    
                            PolygonObject* sphere;   
                  };   
                    
                    
                  Bool BaseDrawTest::Init(GeListNode *node)   
                  {   
                       sphere = (PolygonObject* )GeneratePrimitive(node->GetDocument(), Osphere, BaseContainer(), 1.0, FALSE, NULL);   
                    
                       return TRUE;   
                  }   
                    
                    
                  void BaseDrawTest::Free(GeListNode* node)   
                  {   
                      PolygonObject::Free(sphere);   
                  }   
                    
                    
                  EXECUTIONRESULT BaseDrawTest::Execute(BaseObject* op, BaseDocument* doc, BaseThread* bt, LONG priority, EXECUTIONFLAGS flags)   
                  {   
                       return EXECUTIONRESULT_OK;   
                  }   
                    
                    
                  DRAWRESULT BaseDrawTest::Draw(BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, BaseDrawHelp *bh)   
                  {   
                       if (drawpass==DRAWPASS_OBJECT)   
                       {   
                            if (!sphere)     return DRAWRESULT_SKIP;   
                               
                            bd->DrawPolygonObject(bh, sphere, DRAWOBJECT_0, op, NULL);   
                       }   
                          
                       return DRAWRESULT_OK;   
                  }   
                    
                    
                    
                  /////////////////////////////////////////////////////////   
                  // Register function   
                  /////////////////////////////////////////////////////////   
                    
                  Bool RegisterBaseDrawTest(void)   
                  {   
                       // decide by name if the plugin shall be registered - just for user convenience   
                       String name = GeLoadString(IDS_BASEDRAWTEST); if (!name.Content()) return TRUE;   
                  #if API_VERSION < 12000   
                       return RegisterObjectPlugin(ID_BASEDRAWTEST,name,OBJECT_USECACHECOLOR,BaseDrawTest::Alloc,"Obasedrawtest","icon.tif",0);   
                  #else   
                       return RegisterObjectPlugin(ID_BASEDRAWTEST,name,OBJECT_USECACHECOLOR,BaseDrawTest::Alloc,"Obasedrawtest",AutoBitmap("icon.tif"),0);   
                  #endif   
                  }   
                    
                  
                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

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

                    On 07/06/2012 at 16:24, xxxxxxxx wrote:

                    It is perfectly good practice to include member variables in your class declaration.  This extends the variable's scope to the class level and as long as a class instance exists.  Since it is only a pointer, it only uses the space required to store the memory address (32-bits or 64-bits - 4 or 8 bytes).  You can declare it in the private: section if you want to disallow direct access to it from another class/method - this is usually only necessary if you expect external access (such as when developing a static/dynamic library or library code used by third parties).

                    The global scope is not the best place to declare these things in C++ and is more of a holdover from the old procedural connections to C.  Global variables are stored in the data segment (which could be heap or stack but most likely the stack).  If it ends up on the stack, which is a fixed size, and you use many of them, you may find your stack running out of memory since it also stores the method traceback, method arguments, and local variables within methods.

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

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

                      On 07/06/2012 at 16:33, xxxxxxxx wrote:

                      Originally posted by xxxxxxxx

                      It is perfectly good practice to include member variables in your class declaration.  This extends the variable's scope to the class level and as long as a class instance exists.  Since it is only a pointer, it only uses the space required to store the memory address (32-bits or 64-bits - 4 or 8 bytes).  You can declare it in the private: section if you want to disallow direct access to it from another class/method - this is usually only necessary if you expect external access (such as when developing a static or dynamic library or library used by third parties).The global scope is not the best place to declare these things in C++ and is more of a holdover from the old procedural connections to C.

                      Okay, thank you for the clarification, Robert.

                      Then I'll do it that way (but private ) if nobody else lay good reasons against it.

                      Kind regards,
                      Tom

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

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

                        On 07/06/2012 at 17:10, xxxxxxxx wrote:

                        Thanks for the clarification.
                        When you said you create your objects in the Init() method. I didn't know that you were also using a class member variable with it.

                        I was wondering how the heck you were creating something completely brand new in one method. And then pointing to it from another method. Without using a global, or class member variable, that they could both use to communicate with each other.
                        I thought I was about to learn a clever new trick on making two methods talk to each other.🙂

                        -ScottA

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

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

                          On 08/06/2012 at 08:57, xxxxxxxx wrote:

                          Okay, next problem:

                          How can I access the BaseContainer() of a BaseObject() created this way to manipulate it?

                          Neither the SetParameter/GetParameter nor the GetDataInstance method seems to work!

                          I can fill the base container with parameters and pass it to the object with GeneratePrimitive() but how can I change them afterwards?

                          I'm confused.

                            
                          /////////////////////////////////////////////////////////////   
                          // CINEMA 4D BaseDrawTest                                  //   
                          /////////////////////////////////////////////////////////////   
                          // (c) 2012 Thomas Chen, all rights reserved               //   
                          /////////////////////////////////////////////////////////////   
                          // basedrawtest.cpp                                        //   
                          /////////////////////////////////////////////////////////////   
                            
                          #include "c4d.h"   
                          #include "c4d_symbols.h"   
                          #include "obasedrawtest.h"   
                            
                            
                          #if API_VERSION < 12000   
                          #define EXECUTIONRESULT          LONG   
                          #define EXECUTIONFLAGS          LONG   
                          #define EXECUTIONRESULT_OK     EXECUTION_RESULT_OK   
                            
                          #define DRAWRESULT               Bool   
                          #define DRAWPASS               LONG   
                          #define DRAWRESULT_OK          TRUE   
                          #endif   
                            
                            
                          /////////////////////////////////////////////////////////   
                          // Class functions   
                          /////////////////////////////////////////////////////////   
                            
                          class BaseDrawTest : public ObjectData   
                          {   
                               INSTANCEOF(BaseDrawTest, ObjectData)   
                            
                               public:   
                                    virtual Bool Init(GeListNode* node);   
                                    virtual void Free(GeListNode* node);   
                            
                                    virtual EXECUTIONRESULT Execute(BaseObject* op, BaseDocument* doc, BaseThread* bt, LONG priority, EXECUTIONFLAGS flags);   
                                    virtual DRAWRESULT Draw(BaseObject* op, DRAWPASS drawpass, BaseDraw* bd, BaseDrawHelp* bh);   
                            
                                    static NodeData *Alloc(void) { return gNew BaseDrawTest; }   
                            
                               private:   
                                    BaseObject* plane;   
                          };   
                            
                            
                          Bool BaseDrawTest::Init(GeListNode *node)   
                          {   
                               //plane: GeneratePrimitive(), Osinglepoly   
                               BaseContainer bc_plane;   
                               bc_plane.SetReal(PRIM_POLY_WIDTH, 200.0);   
                               bc_plane.SetReal(PRIM_POLY_HEIGHT, 200.0);   
                               bc_plane.SetLong(PRIM_POLY_SUB, 1);   
                               bc_plane.SetBool(PRIM_POLY_TRIANG, FALSE);   
                               bc_plane.SetLong(PRIM_AXIS, PRIM_AXIS_ZN);   
                            
                               plane = (BaseObject* )GeneratePrimitive(node->GetDocument(), Osinglepoly, bc_plane, 1.0, FALSE, NULL);   
                            
                               return TRUE;   
                          }   
                            
                            
                          void BaseDrawTest::Free(GeListNode* node)   
                          {   
                              BaseObject::Free(plane);   
                          }   
                            
                            
                          EXECUTIONRESULT BaseDrawTest::Execute(BaseObject* op, BaseDocument* doc, BaseThread* bt, LONG priority, EXECUTIONFLAGS flags)   
                          {   
                               return EXECUTIONRESULT_OK;   
                          }   
                            
                            
                          DRAWRESULT BaseDrawTest::Draw(BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, BaseDrawHelp *bh)   
                          {   
                               if (drawpass==DRAWPASS_OBJECT)   
                               {   
                                    const Matrix &m; = bh->GetMg();   
                            
                                    //pplane: DrawPolygonObject(), Osinglepoly   
                                    if (plane)   
                                    {   
                            
                                         plane->SetParameter(DescID(PRIM_POLY_WIDTH), GeData(1000.0), DESCFLAGS_SET_0);          //<--- Doesn't work!   
                            
                            
                                         BaseContainer *bc = plane->GetDataInstance();                                           //<--- Doesn't work either!   
                                         bc->SetReal(PRIM_POLY_HEIGHT,1000.0);                                                  //<--- Doesn't work either!   
                            
                            
                                         plane->SetMg(m);                                                                       //<--- Okay, that works of course! ;o)   
                            
                                         bd->DrawPolygonObject(bh, plane, DRAWOBJECT_XRAY_ON, op, NULL);   
                                    }   
                               }   
                            
                               return DRAWRESULT_OK;   
                          }   
                            
                            
                          /////////////////////////////////////////////////////////   
                          // Register function   
                          /////////////////////////////////////////////////////////   
                            
                          Bool RegisterBaseDrawTest(void)   
                          {   
                               // decide by name if the plugin shall be registered - just for user convenience   
                               String name = GeLoadString(IDS_BASEDRAWTEST); if (!name.Content()) return TRUE;   
                          #if API_VERSION < 12000   
                               return RegisterObjectPlugin(ID_BASEDRAWTEST,name,OBJECT_USECACHECOLOR,BaseDrawTest::Alloc,"Obasedrawtest","icon.tif",0);   
                          #else   
                               return RegisterObjectPlugin(ID_BASEDRAWTEST,name,OBJECT_USECACHECOLOR,BaseDrawTest::Alloc,"Obasedrawtest",AutoBitmap("icon.tif"),0);   
                          #endif   
                          }   
                            
                          
                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

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

                            On 08/06/2012 at 13:30, xxxxxxxx wrote:

                            There's an object example plugin on Steve's(microbian) website called Diamond Object:http://www.microbion.co.uk/graphics/c4d/create_plugins6.htm

                            What's nice about it is that it's got everything tucked inside of the object class(no globals).
                            And it even uses an .h file to declare the class, member variables, and member methods.
                            It's a true OOP example of creating an object with the ObjectData class. Which is what you're doing.

                            You should be able to replace his diamond vectors code with your sphere code.
                            It might help you figure things out.

                            -ScottA

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

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

                              On 08/06/2012 at 15:41, xxxxxxxx wrote:

                              Originally posted by xxxxxxxx

                              There's an object example plugin on Steve's(microbian) website called Diamond Object:http://www.microbion.co.uk/graphics/c4d/create_plugins6.htmWhat's nice about it is that it's got everything tucked inside of the object class(no globals).And it even uses an .h file to declare the class, member variables, and member methods.It's a true OOP example of creating an object with the ObjectData class. Which is what you're doing.You should be able to replace his diamond vectors code with your sphere code. It might help you figure things out.-ScottA

                              I know this tutorial, thank you anyway, but there he uses GetVirtualObjects() and with that, things are handled different to Draw() (at least I think so).

                              I did it with GetVirtualObjects() myself before and I know how to use it, but I didn't want to create a real editable polygon object that appear in the object manager but a visual helper that is just drawn in the editor for an object Plugin.

                              In GetVirtualObjects() I did it with

                                
                              BaseObject* plane = BaseObject::Alloc(Osinglepoly);   
                              

                              But, as far as I remember, that doesn't work in Draw().

                              By the way, in fact I don't need a sphere but an "Osinglepoly" but that's just a side note.

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

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

                                On 08/06/2012 at 19:21, xxxxxxxx wrote:

                                Here's an altered version of your code that will generate a sphere object. But not create any actual geometry object in the OM(just the generator object itself).
                                It has one attribute to control the scale of it when the users changes it in the AM:

                                #include "c4d.h"  
                                #include "c4d_symbols.h"  
                                #include "myObject.h"  
                                  
                                // be sure to use a unique ID obtained from www.plugincafe.com  
                                #define PLUGIN_ID 1000007  
                                  
                                class MyObject : public ObjectData  
                                {  
                                  public:  
                                  
                                      virtual Bool Init               (GeListNode *node);  
                                      virtual DRAWRESULT Draw         (BaseObject *op, DRAWPASS type, BaseDraw *bd, BaseDrawHelp *bh);  
                                      virtual EXECUTIONRESULT       Execute(BaseObject *op,   
                                  
                                      BaseDocument *doc, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags);  
                                  
                                      static NodeData *Alloc(void) { return gNew MyObject; }  
                                  
                                private:  
                                  
                                      BaseObject *sphere;  
                                  
                                };  
                                  
                                Bool MyObject::Init(GeListNode *node)  
                                {  
                                  BaseObject    *op   = (BaseObject* )node;  
                                  BaseContainer *bc = op->GetDataInstance();  
                                  bc->SetReal(POLY_SCALE, 1.0);     //A gui attribute to change the size of the sphere  
                                  
                                  sphere = (BaseObject* )GeneratePrimitive(node->GetDocument(), Osphere, BaseContainer(), 1.0, FALSE, NULL);  
                                  
                                  return TRUE;  
                                }  
                                  
                                DRAWRESULT MyObject::Draw(BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, BaseDrawHelp *bh)  
                                {  
                                   if(drawpass==DRAWPASS_OBJECT)  
                                   {  
                                     const Matrix &m = bh->GetMg();  
                                  
                                     BaseContainer *data = op->GetDataInstance();  
                                     Real  s = data->GetReal(POLY_SCALE);  
                                     op->SetAbsScale(s);  
                                  
                                     sphere->SetMg(m);  
                                  
                                     bd->DrawPolygonObject(bh, sphere, DRAWOBJECT_XRAY_ON, op, NULL);  
                                   }  
                                  
                                  return DRAWRESULT_OK;  
                                }  
                                  
                                EXECUTIONRESULT MyObject::Execute(BaseObject *op, BaseDocument *doc, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags)  
                                {  
                                  return EXECUTIONRESULT_OK;  
                                }  
                                  
                                  
                                Bool RegisterMyObject(void)  
                                {  
                                  return RegisterObjectPlugin(PLUGIN_ID, GeLoadString(IDS_MYOBJECT), OBJECT_GENERATOR|OBJECT_ISSPLINE|OBJECT_CALL_ADDEXECUTION, MyObject::Alloc, "MyObject", AutoBitmap("MyIcon.tif"), 0);  
                                }
                                

                                First you said you were making a tool plugin..Then you posted generator plugin code(ObjectData class).
                                So I have to admit I'm a bit confused about what your end goal is.

                                -ScottA

                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

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

                                  On 08/06/2012 at 19:51, xxxxxxxx wrote:

                                  Hi Scott,

                                  first, thank you for your efforts trying to help me.

                                  Originally posted by xxxxxxxx

                                  Here's an altered version of your code that will generate a sphere object. But not create any actual geometry object in the OM(just the generator object itself).It has one attribute to control the scale of it when the users changes it in the AM:

                                  Unfortunately I can find nothing new to me in your code example and SetAbsScale() doesn't help me at all.
                                  That belongs to the same category as the SetMg() I used but has nothing to do with the BaseContainer() of the sphere (or plane, in my case)!

                                  What I need is access to PRIM_POLY_WIDTH, PRIM_POLY_HEIGHT, PRIM_POLY_SUB and PRIM_POLY_TRIANG of the "Osinglepoly".

                                  Okay, the last one is less important, I predefine it as quad and it needn't be changeable.

                                  Isn't it possible to use the BaseContainer() of an (with GeneratePrimitive() created) object in this context?

                                  Originally posted by xxxxxxxx

                                  First you said you were making a tool plugin...

                                  Where did I say that?

                                  Kind regards,
                                  Tom

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Helper
                                    last edited by

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

                                    On 08/06/2012 at 20:48, xxxxxxxx wrote:

                                    Sorry. My Bad.
                                    I got you confused with cineast2008.
                                    Maybe I'm being dense(again 😉). But what you're asking for doesn't make sense to me.
                                    It's true that a polygon primitive does have these attributes:

                                    enum  
                                    {  
                                      PRIM_POLY_WIDTH    = 1270, // REAL   
                                      PRIM_POLY_HEIGHT   = 1271, // REAL  
                                      PRIM_POLY_SUB      = 1272, // LONG  
                                      PRIM_POLY_TRIANG   = 1273 // BOOL  
                                    };
                                    

                                    But when you cast(convert) a primitive to a polygon object like this:

                                    plane = (BaseObject* )GeneratePrimitive(node->GetDocument(), Osinglepoly, bc_plane, 1.0, FALSE, NULL);
                                    

                                    You loose those primitive based attributes in the conversion. They aren't available any more because the object is now a polygon based object.
                                    At that point you have to grab the points, polygons, and edges and work with them manually.

                                    -ScottA

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Helper
                                      last edited by

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

                                      On 08/06/2012 at 22:48, xxxxxxxx wrote:

                                      Originally posted by xxxxxxxx

                                      Sorry. My Bad.I got you confused with cineast2008.

                                      No problem!   

                                      Originally posted by xxxxxxxx

                                      Maybe I'm being dense(again 😉). But what you're asking for doesn't make sense to me.It's true that a polygon primitive does have these attributes:
                                      But when you cast(convert) a primitive to a polygon object like this:

                                      plane = (BaseObject* )GeneratePrimitive(node->GetDocument(), Osinglepoly, bc_plane, 1.0, FALSE, NULL);
                                      

                                      You loose those primitive based attributes in the conversion. They aren't available any more because the object is now a polygon based object.At that point you have to grab the points, polygons, and edges and work with them manually.-ScottA

                                      Okay, of course that explains why it can't work!

                                      I didn't know, that GeneratePrimitive() in fact converts the primitive to an editable polygon object. I didn't find a word about that in the SDK doku or at least I didn't realize it.

                                      Then maybe I have to go back to use GetVirtualObjects() again for my intention, although I thought that's the wrong place for that kind of things.

                                      Or is there another way to use base objects in there parametric form inside Draw()?

                                      Kind regards,
                                      Tom

                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        Helper
                                        last edited by

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

                                        On 09/06/2012 at 09:52, xxxxxxxx wrote:

                                        Ack!Sorry again.
                                        There's so many versions of code in this thread I was getting them mixed up.

                                        Earlier Matthias posted this:

                                        sphere = (PolygonObject* )GeneratePrimitive(bh->GetDocument(), Osphere, BaseContainer(), 1.0, FALSE, NULL);
                                        

                                        Which converts a BaseObject to a polygon Object.
                                        But I now just noticed that you used this differently:

                                        sphere = (BaseObject* )GeneratePrimitive(node->GetDocument(), Osphere, BaseContainer(), 1.0, FALSE, NULL);
                                        

                                        Which should be ok.
                                        But I'm not sure you actually need to have the (BaseObject* ) code in there.

                                        I've never created a primitive object with a C++ generator plugin. But I do have a python example of doing that. And it's created in the GetVirtualObjects() method.
                                        Based on how "return" is used the same way to generate an object in both the pyGenerator object. And the C++ GetVirtualObjects() method. My guess is that GetVirtualObjects() is where we are supposed to do it.
                                        But that's just a guess.

                                        -ScottA

                                        1 Reply Last reply Reply Quote 0
                                        • First post
                                          Last post