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

    Modeling Question.

    Scheduled Pinned Locked Moved SDK Help
    17 Posts 0 Posters 1.3k 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 25/09/2010 at 11:55, xxxxxxxx wrote:

      Thanks for the reply Dan.

      I added what you mentioned and am still getting the same result.    Here's the code I have.

        
        
      BaseDocument *doc = mdat.doc;  
        BaseObject *op = doc->GetActiveObject();  
        BaseContainer *bc = mdat.bc;  
        
        PolygonObject *objPoly = (PolygonObject * )op;  
        if(!objPoly) return FALSE;  
         
        AutoAlloc<Modeling> mod;  
        if (!mod || !mod->InitObject(objPoly)) return FALSE;  
        
        LONG pointCount = objPoly->GetPointCount();  
        LONG polyCount    = objPoly->GetPolygonCount();  
        
        CPolygon * polys = objPoly->GetPolygonW();  
        Real width = bc->GetReal(CHAMFER_WIDTH);  
        
        Neighbor n;  
        n.Init(pointCount, polys, polyCount, NULL);  
        
        GePrint("BEFORE");  
        
        PolyInfo *pli  = NULL;  
        if (!pli) return FALSE;  
        
        GePrint("AFTER");  
        
        LONG pointA = 0, pointB = 0;  
          
        //Iterate Through Edges  
        for ( int i=0; i < polyCount; i++)  
        {  
            pli = n.GetPolyInfo(i);  
        
            for (int side = 0; side < 4; side++) // test all 4 sides of a polygon  
            {  
                // only proceed if edge has not already been processed  
                // and edge really exists (for triangles side 2 from c..d does not exist as c==d)  
                if (pli->mark[side] || (side==2 && (polys->c == polys->d))) continue;  
        
                switch (side)  
                {  
                      
                    case 0: pointA = polys[i].a; pointB = polys[i].b; break;  
                    case 1: pointA = polys[i].b; pointB = polys[i].c; break;  
                    case 2: pointA = polys[i].c; pointB = polys[i].d; break;  
                    case 3: pointA = polys[i].d; pointB = polys[i].a; break;  
                              
                }  
        
                //Split Edges  
                mod->SplitEdge(objPoly, pointA, pointB, width);  
                EventAdd();  
          
            }  
        }  
        
        //Delete Original Points  
        for (int i=0; i < pointCount; i++)  
        {  
        
            mod->DeletePoint(objPoly, i);  
        }  
          
        
        if (!mod->Commit()) return FALSE;  
          
        EventAdd();  
          
        return TRUE;  
        
      

      You may notice there are GePrint()  before and after the check for the pli pointer.  Only the BEFORE shows up in the console..  For some reason pli is not available?

      Any other thoughts?

      Thanks again.

      ~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 25/09/2010 at 12:02, xxxxxxxx wrote:

        Howdy,

        Hehehe, well take a good look at these 2 lines:

        PolyInfo *pli = NULL;   
        if (!pli) return FALSE;
        

        ... can you say DOH!

        Hey, I've been there; done that; before, too.

        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 25/09/2010 at 12:06, xxxxxxxx wrote:

          LOL..  HAHAHAHAHA.  So basically I set it to nothing and then check if it's nothing.  HAHAHAH   I'm a genious.   Thanks Dan.

          ~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 25/09/2010 at 12:08, xxxxxxxx wrote:

            What do I initialize pli to?   for a Polyinfo ?

            Could I do

            PolyInfo *pli = new PolyInfo;

            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 25/09/2010 at 12:16, xxxxxxxx wrote:

              hmmmm.. .  I am initializing it before it's used with ..

              pli = n.GetPolyInfo(i);  
              

              Why am I getting an error that it's not initialized..  That's weird

              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 25/09/2010 at 12:18, xxxxxxxx wrote:

                problem solved..  I just initialized it first with

                n.GetPolyInfo(0)

                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 25/09/2010 at 12:46, xxxxxxxx wrote:

                  One more question,   Is there a way to reindex the points in my object?   I am creating a bunch of new points which are all indexed as they are added which makes the indices all over the place and when the geometry is created the shape looks crazy.  The points are in the right spot but the indices are all over the place..   🙂

                  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 26/09/2010 at 07:43, xxxxxxxx wrote:

                    Howdy

                    Well, I think the modeling functions normally add new points to the end of the points array, and new polygons to the end of the polygons array.

                    It would be trivial to insert a point in the middle of an array. You'd simply create a new array sized to the new point count, copy the block of memory above the insertion position to the new array, then copy the block of memory below the insertion position to the new array but move it 1 position down in the array, and finally copy the new point into the insertion position of the array.

                    This would be fine if you're just dealing with points. But, since polygons only hold point indices, for each point you add, you'll have to loop through all of the polygons, checking their existing point indices and if any polygons have point indices greater than or equal to the index of the inserted point, you'll have to add +1 to those indices. This also would be trivial if the object only has a few polygons, but if you have a mesh with thousands of polygons, it could get costly.

                    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 26/09/2010 at 07:48, xxxxxxxx wrote:

                      Hey thanks for the reply Dan.  I think this is gonna take a little investigating to figure out why I am getting the results I am.  I have been reading through the3 Modeling Library documentation and am beginning to think it is more of a problem with the ngons.

                      see  this thread:

                      https://developers.maxon.net/forum/topic/5210/5204_ngon

                      I think I need to divert my attention to ngons.  🙂

                      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 26/09/2010 at 08:09, xxxxxxxx wrote:

                        Howdy,

                        Oh, OK I see. I misunderstood the question. I'm not really sure what's going on with that example in the other thread, as I haven't really delved too deeply into the modeling functions.

                        But, looking at your code again, I think you can do away with these lines:

                        PolyInfo *pli = n.GetPolyInfo(0);   
                        if (!pli) return FALSE;   
                        

                        ... and simply change this:

                        pli = n.GetPolyInfo(i);
                        

                        ... to this:

                        pli = n.GetPolyInfo(i); if(!pli) continue;
                        

                        ... or this:

                        pli = n.GetPolyInfo(i); if(!pli) return FALSE;
                        

                        EDIT:
                        Actually in c++ it doesn't take any more processor time to define a variable type within a loop, so you don't really need to define the variable outside the loop.

                        You could do this:

                        PolyInfo *pli = n.GetPolyInfo(i); if(!pli) continue;
                        

                        ... inside the loop as long as the variable will only be used inside 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 26/09/2010 at 12:49, xxxxxxxx wrote:

                          Thanks for the code improvement Dan.  Anyone else know anything about manipulating ngons in C4D?

                          This thread is where my problem is located.

                          https://plugincafe.maxon.net/topic/5210/5204_ngon

                          In fact,  I will stop posting on this Modeling thread now and go over there.  🙂

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