Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Visualize Ngons

    Scheduled Pinned Locked Moved SDK Help
    8 Posts 0 Posters 706 Views
    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 Offline
      Helper
      last edited by

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

      On 21/04/2009 at 08:06, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R11.026 
      Platform:   Windows  ;   Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hello,

      i want to visualize ngons with the GetVirtualObject-Method in my generatorobject after i already visualized normal polygons. In principle my "datatype" has the same information as the code from the documentation below.

      > \> BaseObject \*ret = BaseObject::Alloc(Onull); \> \> AutoAlloc<PolygonObject> obj(0,0); //begin of example \> if (!obj) return FALSE; \> \> AutoAlloc<Modeling> mod; \> if (!mod || !mod->InitObject(obj)) return FALSE; \> \> LONG a = mod->AddPoint(obj, Vector(0,0,0)); \> LONG b = mod->AddPoint(obj, Vector(100,0,0)); \> LONG c = mod->AddPoint(obj, Vector(150,50,0)); \> LONG d = mod->AddPoint(obj, Vector(100,100,0)); \> LONG e = mod->AddPoint(obj, Vector(0,100,0)); \> if (!a || !b || !c || !d || !e) return FALSE; \> \> LONG padr[] = {a,b,c,d,e}; \> LONG cnt = sizeof(padr)/sizeof(padr[0]); \> \> LONG i = mod->CreateNgon(obj, padr, cnt); \> if (!i) return FALSE; \> \> if (!mod->Commit()) return FALSE; //end of example \> \>    obj->InsertUnderLast(ret); \>

      Did i forget something or did i overlook a fault?

      Thanks for help

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

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

        On 22/04/2009 at 09:09, xxxxxxxx wrote:

        Did i missed a step between
        > mod->CreateNgon(obj, padr, cnt);
        and
        > obj->InsertUnderLast(ret)
        to "connect" the ngon-information with the PolygonObject so that thePolygonObject internally generates polygons out of the ngons or something like that?
        I don't find the missing link. I need a food for thought.

        cheers

        Oli

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

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

          On 22/04/2009 at 09:25, xxxxxxxx wrote:

          This line looks wrong.

          > AutoAlloc<PolygonObject> obj(0,0)

          With AutoAlloc allocated objects have only a scope-based lifetime. The polygon object will not be avaible anymore after GetVirtualObjects() has been processed. Use PolygonObject::Alloc(0,0) instead in this case.

          cheers,
          Matthias

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

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

            On 23/04/2009 at 01:22, xxxxxxxx wrote:

            It works :-).
            What a stupid fault...oh my god.

            Thanks a lot Matthias!

            cheers,

            Oli

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

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

              On 29/04/2009 at 04:47, xxxxxxxx wrote:

              Same Topic, other problem.

              Now i want to visualize more than one ngon.

              So i use a loop to allocate/free the memory of the PolygonObject and to insert them into the BaseObject.
              In principle it looks like this.

              > <code>BaseObject *ret = BaseObject::Alloc(Onull);
              >
              > AutoAlloc<Modeling> mod;
              >
              > for(LONG ngonCount = 0; ngonCount < ngons; ngonCount++){
              >
              > PolygonObject* obj = PolygonObject::Alloc(0,0);
              >
              > if (!obj) return FALSE;
              >
              > if (!mod || !mod->InitObject(obj)) return FALSE;
              >
              > LONG a = mod->AddPoint(obj, Vector(0,0,0));
              >
              > LONG b = mod->AddPoint(obj, Vector((ngonCount+1)*100,0,0));
              >
              > LONG c = mod->AddPoint(obj, Vector((ngonCount+1)*150,(ngonCount+1)*50,0));
              >
              > LONG d = mod->AddPoint(obj, Vector((ngonCount+1)*100,(ngonCount+1)*100,0));
              >
              > LONG e = mod->AddPoint(obj, Vector(0,(ngonCount+1)*100,0));
              >
              > if (!a || !b || !c || !d || !e) return FALSE;
              >
              > LONG padr[] = {a,b,c,d,e};
              >
              > LONG cnt = sizeof(padr)/sizeof(padr[0]);
              >
              > LONG i = mod->CreateNgon(obj, padr, cnt);
              >
              > if (!i) return FALSE;
              >
              > if (nognCount == ngons-1 && !mod->Commit()) return FALSE;
              >
              >    obj->InsertUnderLast(ret);
              > }
              > </code>

              I know the values of the points not reallymake sense :-).

              My problem is, that this solution worked yesterday and today every time i get a Modeling Kernel Error: internal Error.
              I know i should not use Commit without arguments in a loop (->documentation), but i "commit" not before the last run.

              And how i said, yesterday it worked.

              If there was a magic dragon in my pc yesterday :-), has anybody an other idea to insert more than one ngon into the BaseObject or an idea why it works and than not.

              cheers,

              Oli

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

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

                On 29/04/2009 at 05:29, xxxxxxxx wrote:

                This seems to work fine here. Maybe just exchange the call to Commit() with mod- >Commit(obj, MODELING_COMMIT_NONE, NULL).

                cheers,
                Matthias

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

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

                  On 29/04/2009 at 07:05, xxxxxxxx wrote:

                  Thanks for the fast reply Matthias.
                  I have two things.
                  1.) If i exchange the call, i only see the last ngon i inserted, but it works :-).

                  2.) With your solution i was aible to isolate the fault. In the concrete case i wanted to create a cube with three ngons. So i copied the Cinema-Cube (position of points and the polygonpoints). Ngon 2 and 3 create the ground or rather the top. Ngon 1 should create the four sides of the cube.
                  So i get these three arrays for the polygonpoints:
                  Ngon 1: 0,1,3,2,2,3,5,4,4,5,7,6,6,7, 1 ,0
                  Ngon 2: 1,7,5,3
                  Ngon 3: 6,0,2,4

                  The marked "1" is the reason for the Modeling Kernel Error.

                  If i change the number to "3" for example it works. And if i change the call to Commit() again, i see all ngons :-).

                  So any idea why i get the error if there is a "1".

                  Thanks,

                  Oli

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

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

                    On 05/05/2009 at 07:41, xxxxxxxx wrote:

                    I solved the problem.
                    The process flow direction of the polygon was wrong at this point :-).

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