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

    Manual subdivision

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 378 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 11/09/2011 at 13:03, xxxxxxxx wrote:

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

      ---------
      Hey everyone,,  I am trying to subdivide a single polygon manually using the modeling class..

      Here's the code I am working with so far

        
        
      for(int i = 0; i < polyCount; i++)  
        {  
            LONG a, b, c, d;  
            LONG na, nb, nc, nd;  
        
            a = polys[i].a;  
            b = polys[i].b;  
            c = polys[i].c;  
            d = polys[i].d;  
        
            ctr = points[a] + points[b] + points[c] + points[d] / 4;  
        
            na = mod->SplitEdge(polyObj, a, b, .5);  
            nb = mod->SplitEdge(polyObj, b, c, .5);  
            nc = mod->SplitEdge(polyObj, c, d, .5);  
            nd = mod->SplitEdge(polyObj, d, a, .5);  
        
            LONG pg1 = mod->SplitPolygon(polyObj, i, na, nc);  
        
        }  
        
      

      When I run this code, I do not get a split in the polygon.   Does anyone see a reason why?

      I have used the Modeling Class in the past but can't seem to figure out why it is not working here..  Any thoughts?

      Thanks,

      Shawn

      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 11/09/2011 at 15:38, xxxxxxxx wrote:

        Howdy,

        Well, did you make the call to Modeling::Commit() after the loop?

        Adios,
        Cactus Dan

        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 11/09/2011 at 15:57, xxxxxxxx wrote:

          Hey Dan,

          I ended up going a slightly different route.

            
            
            AutoAlloc<Modeling> mod;  
            if (!mod || !mod->InitObject(polyObj)) return FALSE;  
            
            for(int i = 0; i < polyCount; i++)  
            {  
                LONG a, b, c, d;  
                LONG n1, n2, n3, n4, n5;  
                  
                a = polys[i].a;  
                b = polys[i].b;  
                c = polys[i].c;  
                d = polys[i].d;  
            
                ctr = (points[a] + points[b] + points[c] + points[d]) / 4;  
                top = (points[a] + points[b]) / 2;  
                right = (points[b] + points[c]) / 2;  
                bottom = (points[c] + points[d]) / 2;  
                left = (points[d] + points[a]) / 2;  
            
                mod->DeleteNgon(polyObj,i, FALSE);  
                n1 = mod->AddPoint(polyObj, ctr);  
                n2 = mod->AddPoint(polyObj, top);  
                n3 = mod->AddPoint(polyObj, right);  
                n4 = mod->AddPoint(polyObj, bottom);  
                n5 = mod->AddPoint(polyObj, left);  
            
                LONG na1[4] = {a, n2, n1, n5};  
                LONG na2[4] = {n2, b, n3, n1};  
                LONG na3[4] = {n1, n5, d, n4};  
                LONG na4[4] = {n3, n1,n4, c};  
                  
                mod->CreateNgon(polyObj, na1, 4, MODELING_SETNGON_FLAG_FIXEDQUADS);  
                mod->CreateNgon(polyObj, na2, 4, MODELING_SETNGON_FLAG_FIXEDQUADS);  
                mod->CreateNgon(polyObj, na3, 4, MODELING_SETNGON_FLAG_FIXEDQUADS);  
                mod->CreateNgon(polyObj, na4, 4, MODELING_SETNGON_FLAG_FIXEDQUADS);  
            
            }  
            
            if(!mod->Commit(polyObj, MODELING_COMMIT_REFRESH, NULL)) return NULL;  
            
          

          Now the only problem is that I want to be able to loop through this code any given number of times but every time on the second run of the loop, it crashes..

          is it possible to run init and commit multiple times in a loop?

          Thanks,

          Shawn

          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 11/09/2011 at 16:03, xxxxxxxx wrote:

            Howdy,

            No, I think you have to init and commit only once outside the loop.

            Have you looked at the edge cut example from the cinema4dsdk project?

            Adios,
            Cactus Dan

            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 11/09/2011 at 16:13, xxxxxxxx wrote:

              Hey Dan .. Yes I have looked at the edge cut tool.  I will keep playing around to see if I can get the result I am looking for.  I think part of the problem is that I am declaring the PolygonObject in this function so it is continuously starting over with a certain number of polygons.

              Thanks,

              Shawn

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