Iterate through all Edges of PolygonObject[SOLVED]



  • On 29/04/2015 at 22:21, xxxxxxxx wrote:

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

    ---------
    Hello,

    I want to iterate through all edges of an PolygonObject and get their vectors. How can I do that?
    I've done this already with Python by using a BaseSelect, but I think, there must be a better way.

    Thanks ;)



  • On 30/04/2015 at 06:21, xxxxxxxx wrote:

    I found the solution in the SDK documentation:

    Example:
    The following code browses through all available edges:
    Int32 a, b;
    Neighbor neighbor;
    if (!neighbor.Init(pcnt, vadr, vcnt, nullptr))
    return false;
    for (i=0; i<polyCount; i++)
    {
    > PolyInfo* polyInfo = neighbor->GetPolyInfo(i);
    >
    > for (side=0; side<4; side++) // Test all 4 sides of a polygon
    >
    > {
    >
    >> // Only proceed if the edge has not already been processed and edge really exists
    >>
    >> // For triangles side 2 from c..d does not exist as c==d
    >>
    >> // One can also skip the side==2 && vadr _.c==vadr _.d test as pli- >mark[2] is always true for triangles
    >>
    >> if (pli->mark[side] || side==2 && vadr _.c==vadr _.d)
    >>
    >>> continue;
    >>
    >> switch (side)
    >>
    >> {
    >>
    >>> case 0: a = vadr _.a; b = vadr _.b; break;
    >>>
    >>> case 1: a = vadr _.b; b = vadr _.c; break;
    >>>
    >>> case 2: a = vadr _.c; b = vadr _.d; break;
    >>>
    >>> case 3: a = vadr _.d; b = vadr _.a; break;
    >>
    >> }
    >
    >> // Do something with the edge a..b
    >
    > }
    }



  • On 30/04/2015 at 08:31, xxxxxxxx wrote:

    Actually there's also the AtomArray in our cinema4dsdk examples, which shows this in "living" code.



  • On 30/04/2015 at 18:14, xxxxxxxx wrote:

    Thanks for the hint. The other examples are also very interesting!


Log in to reply