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

    GeRayCollider.GetIntersection ()["points"] ???

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 553 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

      On 29/08/2013 at 08:29, xxxxxxxx wrote:

      From Python SDK:

      Retrieves the intersection, found by GeRayCollider.Intersect(), by index:

      intersection = rc.GetIntersection(id)

      intersect["face_id"] # The polygon index, int
      intersect["tri_face_id"] # If first half of quad or triangle face_id + 1, else -(face_id + 1), int
      intersect["hitpos"] # Position of the intersection, c4d.Vector
      intersect["distance"] # Distance to the intersection, float
      intersect["f_normal"] # Face normal. (Not normalized.), c4d.Vector
      intersect["barrycoords"] #Barrycentric coordinates of the intersection. (x = u, y = v, z = d), c4d.Vector
      intersect["backface"] # True if the intersected face's normal points away from the camera, otherwise False, bool

      the intersection to points, is it possible?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 29/08/2013 at 09:59, xxxxxxxx wrote:

        Originally posted by xxxxxxxx

        the intersection to points, is it possible?

        Please clarify your question, nobody knows what you are talking about. An intersection is
        a point in 3D space, if this is what you mean.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 29/08/2013 at 10:49, xxxxxxxx wrote:

          Hi NiklasR.
          I would like to move an object and the object must target one of the point of another object

          example:

          obj = doc.GetActviveObject()

          obj_target= doc.GetFirstObject()

          I would like to move, with GeRayCollider, obj to obj_target.

          My intersection  would be a point of obj_target points.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 29/08/2013 at 11:49, xxxxxxxx wrote:

            Hi Runner,

            The quote you posted tells you:  intersect["hitpos"] # Position of the intersection, c4d.Vector

            After you have successfully initialized the GeRayCollider and sent a ray through time and space,
            you can use GeRayCollider.GetIntersectionId() to retrieve information about one of the
            intersections the collider figured. The returned value is a dictionary and contains the hit position
            as the documentation states.
                
                import c4d
                
                def main() :
                    target = doc.GetFirstObject()
                    if not op or not target:
                        return
                    if not isinstance(target, c4d.PolygonObject) :
                        return c4d.gui.MessageDialog("First object must be a polygon object.")
                
                    collider = c4d.utils.GeRayCollider()
                    if not collider.Init(target) :
                        return c4d.gui.MessageDialog("GeRayCollider failed to initialize.")
                
                    bd = doc.GetActiveBaseDraw()
                    cam = bd.GetSceneCamera(doc)
                    cam_mg = cam.GetMg()
                
                    ray_p = cam_mg.off
                    ray_d = cam_mg.v3
                    length = 1000000000
                
                    does_intersect = collider.Intersect(ray_p, ray_d, length)
                    if not does_intersect:
                        return c4d.gui.MessageDialog("No Intersection found.")
                
                    inter = collider.GetNearestIntersection()
                    mg = op.GetMg()
                    mg.off = inter["hitpos"]
                    doc.AddUndo(c4d.UNDOTYPE_CHANGE_SMALL, op)
                    op.SetMg(mg)
                    c4d.EventAdd()
                
                main()

            Usage: Make the first object in the scene editable. Select another object and place the camera
            so that the center directly points on a polygon on the surface of the first object.

            Please note that the documentation (R14.041) is wrong here: The "goal" parameter does not
            only need to be a BaseObject, it even needs to be a PolygonObject. You can convert any object
            to a polygon object, there's plenty information here in the fourm.

            Cheers,
            -Niklas

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 29/08/2013 at 13:50, xxxxxxxx wrote:

              Thanks NiklasR 🙂

              but i have have successfully initialized the GeRayCollider, with intersect["hitpos"]...

              but my object is positioned of polygon surface...

              I want the new op.SetMg(mg) is only points of first object... no surface....  You can only get points from ["hitpos"] library?  
              How?... 🙂

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 08/09/2013 at 16:12, xxxxxxxx wrote:

                Hi Runner,

                I am sorry, but I can not understand what you are saying. Do you want to calculate "intersections"
                with points rather than a polygon surface?

                Best regards,
                -Niklas

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