Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    delete vertex from quad-poly delets the poly

    Cinema 4D SDK
    2
    6
    868
    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.
    • D
      datamilch
      last edited by ferdinand

      hi there,

      i have the case, where i want to delete some vertecies of quad-polies and want them to turn into tri-polies.
      this would feel quite intuitive to me. but instead the whole poly gets deleted. (i suppose there are cases where this behavior is also quite useful)

      the neighbors need to stay in their exact spot - so 'optimize' or melting with neighors is out.

      probably stitchandsew would be an option, but it would involve quite some code, compared to a simple 'delete'.

      so is there any other tool or trick, that might do what i want?

      delete points 01.JPG

      delete points 02.JPG

      ferdinandF 2 Replies Last reply Reply Quote 0
      • ferdinandF
        ferdinand @datamilch
        last edited by

        Hello @datamilch,

        Thank you for reaching out to us. While you were posting, I did some work on the forum and the file attachments went into test instance of our Forum which I did not end up using due multiple incompatibilities of plugins which we use. In case you consider these image relevants to your question, I have to ask you to provide them again.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        D 1 Reply Last reply Reply Quote 0
        • D
          datamilch @ferdinand
          last edited by ferdinand

          @ferdinand

          thanks for the advice, i noticed the down time 🙂

          these were the images ...

          delete points 01.JPG

          delete points 02.JPG

          ferdinandF 1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand @datamilch
            last edited by

            Hey @datamilch,

            Thank you for providing them again and please excuse the inconvenience.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand @datamilch
              last edited by ferdinand

              Hey @datamilch,

              Thank you for reaching out to us. Your question is a bit ambiguous, as you talk about wanting to 'delete vertices of quad-polys and want them to turn into tri-polys' but show us an image series which just deletes two quads. You do not need any commands (CallCommand, SendModelingCOmmand) for that, as the core of the operation is quite simple. When you have a quad Q {a, b, c, d}, then removing the point n in it just means leaving it out and repeating the last point.

              So, to construct a tri with b being removed would be a, c, d, d, and constructing a tri for d being removed would be a, b, c, c. It is important to keep the order of vertices, as the winding direction of a polygon determines its normal. So, a, c, d, d and d, c, a, a occupy the same space but have reversed normals. Only a, c, d, d has the same winding order and normal as its origin quad a, b, c, d. So, it would be something like this:

              quad: c4d.CPolygon # A polygon
              i: int # A vertex index
              
              # Construct a triangle with the point with the index #i being removed from #quad.
              if not quad.IsTriangle() and quad.b == i:
                  tri: c4d.CPolygon = c4d.CPolygon(quad.a, quad.c, quad.d, quad.d)
              

              This all might sound a bit complicated but is not that hard to do. What is a bit trickier is to detect the point to remove. Here your question is also a bit ambiguous as you do not specify if the points which should be removed are provided by the user or should be detected. If not, you would to test:

              1. For each polygon P in a mesh M:
                1. Test if it is triangle, and if so continue.
                2. For each point q in the polygon P:
                  1. Test if both edges e1 and e2 connected to q have only one polygon (i.e., Q) attached to them.
                  2. If so, you found a point of a quad that is at the border of the mesh. There are of course literal corner cases where this little test might not produce an output humans consider sensible: Imagine a singular perfect right-angled quad as the input mesh. This algorithm would turn it into a triangle. Intended? Catching these special cases can get much more involved.

              For 1.2.1 you can use Neighbor.GetEdgePolys. You should start with writing the script yourself, we will help you then along the way when you struggle, but we cannot write things from start to finish for you.

              Cheers,
              Ferdinand

              MAXON SDK Specialist
              developers.maxon.net

              D 1 Reply Last reply Reply Quote 0
              • D
                datamilch @ferdinand
                last edited by

                @ferdinand thanks for your explanation and sorry for the ambiguouty!

                the second image showed what currently happens, but not what i wanted.

                so converting a quad to tri is more like reordering the verticies and leaving one out. makes sens. hope i find the time to test it next weekend ...

                finding the points is already done, but thanks for the hint. most of the time i use a little trick: select all points, shrink selection, grow selection. then points, that were only connectet to two border-verticies will not be reselectet, you can invert the selection and have the points. but border-points of n-gons will be selectet too. for these i do have a script that makes use of the neighbor function.

                1.2.2. yes i'm aware of the right-angled quad cases, and luckily they don't matter in my case. but thanks for pointing it out. i find it super cool how alert you are! appreciate it alot.

                1 Reply Last reply Reply Quote 0
                • ferdinandF ferdinand moved this topic from General Talk on
                • First post
                  Last post