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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Position of the polygons and Sweep Nurbs

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 379 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 31/08/2006 at 12:23, xxxxxxxx wrote:

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

      ---------
      Hi!
      I'm trying to implement some objects constructed from a Sweep Object containing two splines (one for the path and one for the enveloppe).
      I would like to know what are the positions of the points of the polygons of the Sweep Object when it is converted into a polygon object.  Is it possible to find or to compute them?
      Thanks,
      Myel.

      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 31/08/2006 at 12:49, xxxxxxxx wrote:

        Either using the cache (if you will only be reading the polygon points) or the converted polygon object, you need to do these:

        // Cast the object to a polygon object. This just saves time recasting. Make sure that you have a polygon object.  
        if (!obj->IsInstanceOf(Opolygon)) // not a polygon object  
        PolygonObject* pobj = ToPoly(obj);  
          
        // Get the Polygon and Vector arrays and counts.  
        CPolygon*     polys = pobj->GetPolygon();  
        Vector*          verts = pobj->GetPoint();  
        LONG          pcount = pobj->GetPolygonCount();  
        LONG          vcount = pobj->GetPointCount();  
        if (!(polys && verts)) // raise an error  
          
        // Traverse the polygon list and get the polygon points  
        CPolygon*     lp =     polys+pcount;  
        Vector*          v[4];  
        for (polys; polys != lp; polys++)  
        {  
             v[0] = verts[polys->a];  
             v[1] = verts[polys->b];  
             v[2] = verts[polys->c];  
             v[3] = verts[polys->d];  
        }
        

        v[] contains the Vectors of the polygon. The Vector class contains the (X,Y,Z) coordinates of the point. For Polygons that are triangles, polys->c == polys->d.

        These are the UNtransformed point coordinates. If you need the transformed coordinates, you'll need to get the object's global matrix and multiply to the points:

        Matrix mg = pobj->GetMg();  
        v[0] = v[0] * mg;  
        v[1] = v[1] * mg;  
        ...  
        

        If animation is involved, you'll need to AnimateDocument() or AnimateObject() and possibly GetCache() or GetDeformCache().

        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 03/09/2006 at 06:16, xxxxxxxx wrote:

          Thanks,
          But this doesn't work when the object "obj" is a sweep nurbs object (type Osweep). I think that there is no solution because we can only access to the polygons of an object when this one was converted into a Polygon Object.
          Am I wrong?

          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 03/09/2006 at 13:19, xxxxxxxx wrote:

            No, you are not wrong.

            Yes, of course, the object must be a polygon object. You said "when it is converted into a polygon object" so I assumed that you were either calling "SendModelingCommand()" with MCOMMAND_MAKEEDITABLE or using a cache (which is alway turned into a polygon object). To access an object's polygon points, the object must be a polygon object (either directly or converted). That is a given. Procedural, deformer, and generator objects do not have polygons - even if the latter 'generates' them in the cache.

            If you need to do this while retaining the original procedural object, just make a copy (clone) and convert that to get the points, removing it from the document and deleting it when done.

            Just to add: if you only need to read the points of the converted polygon object and not change them, it would be best to use the cached object (let Cinema do the work for you). Check out BaseObject::GetCache() and GetDeformCache().

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