Adding points



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

    On 20/09/2009 at 12:08, xxxxxxxx wrote:

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

    ---------
    Here is the code that I have. I'll explain what it does.

    > `

      
    \>    
    \>    
    \>       for (lngI=0;lngI<lngPolygonCount;lngI++)  
    \>       {       
    \>    
    \>          if (IsCrossPoly(arrPolygons,arrPoints,lngI,lngSymPlane))  
    \>          {              
    \>                 GePrint("Polygon " + LongToString(lngI) + " has crossed the symmetry plane.");  
    \>              arrCrossPolys[lngJ] = lngI;  
    \>                GePrint("arrCrossPoly[" + LongToString(lngJ) + "] = " + LongToString(arrCrossPolys[lngJ]));  
    \>                   
    \>    
    \>                 if (PointOnEditableSide(arrPoints, arrPolygons[lngI].a, lngSymPlane, lngMirroredSide, true))  
    \>                 {  
    \>                      arrPointStillExists[(lngJ*4)+0]=arrPolygons[lngI].a;   
    \>                 }  
    \>                 if (PointOnEditableSide(arrPoints, arrPolygons[lngI].a, lngSymPlane, lngMirroredSide, true))  
    \>                 {  
    \>                      arrPointStillExists[(lngJ*4)+1]=arrPolygons[lngI].b;   
    \>                 }  
    \>                 if (PointOnEditableSide(arrPoints, arrPolygons[lngI].a, lngSymPlane, lngMirroredSide, true))  
    \>                 {  
    \>                      arrPointStillExists[(lngJ*4)+2]=arrPolygons[lngI].c;   
    \>                 }  
    \>                 if (PointOnEditableSide(arrPoints, arrPolygons[lngI].a, lngSymPlane, lngMirroredSide, true))  
    \>                 {  
    \>                      arrPointStillExists[(lngJ*4)+3]=arrPolygons[lngI].d;   
    \>                 }  
    \>    
    \>                 //For testing in the console - can be removed later.  
    \>                 GePrint("The points for arrCrossPolys[" + LongToString(lngJ) + "] are:" + LongToString(arrPolygons[lngI].a) +","+ LongToString(arrPolygons[lngI].b) +","+ LongToString(arrPolygons[lngI].c) +","+ LongToString(arrPolygons[lngI].d));  
    \>                 GePrint("arrPointStillExists[" + LongToString(arrPointStillExists[lngJ]) + "]");  
    \>    
    \>              
    \>            lngJ++;  
    \>            }  
    \>       }  
    \>    
    \>    
    \>  
    

    `

    This code cycles through the polygons on an object and determines which polygons have crossed a predetermined symmetry plane. Then, it determines which points are part of thos polygons. And contains them in an array.

    I would like to now take the polygons that cross the symmetry plane and divide them so that there are points that fall directly on the symmetry plane instead. How would add points in the middle of the already existing polygons?

    Any help would be greatly appreciated.

    Thanks,

    ~Shawn



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

    On 20/09/2009 at 12:42, xxxxxxxx wrote:

    PolygonObject::ResizeObject(). You'll be splitting each crossing polygon into two polygons with between 1 or 2 new points shared between them (that each lies on the symmetry plane). There is only one case where no new points are needed and that would be if two existing points on a quadrangle lie exactly on the symmetry plane.

    You will need to precalculate the change in polygon and point count - there isn't a (reasonable) way around this. New polygons and points are appended to the end of the CPolygon and Vector arrays for the object (GetPolygonW() and GetPointW()). So, you need to re-get these arrays after calling ResizeObject.

    To do the polygon splitting, use a simplified clipping plane algorithm (just the one clippling plane - symmetry plane - needs to be used).


Log in to reply