Ngon

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

On 25/09/2010 at 19:47, xxxxxxxx wrote:

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

---------
I am using the Modeling Library to add some points,  then delete the original points.

What I am looking for is this....

Here is the code I am using:

  
  
  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();  
  LONG * points = new LONG;  
  Real width = bc->GetReal(CHAMFER_WIDTH);  
  
  Neighbor n;  
  n.Init(pointCount, polys, polyCount, NULL);  
  
  PolyInfo *pli = n.GetPolyInfo(0);  
  if (!pli) return FALSE;  
  
  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, pointB, pointA, width);  
          mod->SplitEdge(objPoly, pointA, pointB, width);  
    
      }  
  }  
  
  //Delete Original Points  
  for (int i=0; i < pointCount; i++)  
  {  
      mod->DeletePoint(objPoly, i);  
      //mod->SetNgonFlags(objPoly, i, MODELING_SETNGON_FLAG_NGONQUADS);  
  }  
    
    
  
  if (!mod->Commit(objPoly, MODELING_COMMIT_NONE, NULL)) return FALSE;  
    
  EventAdd();  
  
  
  mod->ReleaseObject(objPoly);  
  
    
  return TRUE;  
  

When I compile this code and run the plugin in C4D this is what I get...

From what I can tell,  the points are being placed correctly but the ngons are not being created correctly.  How do I build the ngons based on the new points that exist?  It looks to me that some ngons are being created but because the indices are all over the place, it is not creating them correctly.

Anyone have a solution for how to build the ngons correctly?

Thanks,

Shawn

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

On 26/09/2010 at 12:51, xxxxxxxx wrote:

Any thoughts on this one?  🙂

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

On 30/09/2010 at 02:57, xxxxxxxx wrote:

You can't just delete these points. You have first to connect the newly created points.

Just try it for yourself. Comment out mod- >DeletePoint(objPoly, i) and run your code. Then in Cinema delete the points manually. You will get the same messed up result. If you display the Ngon lines you will see why.

cheers,
Matthias