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

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?

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.

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.

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

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?... 🙂

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