c4d.utils.GeRayCollider
¶
Evaluates intersections between a ray and a polygon object. The ray is defined by a point, a ray and length.
In the following example a ray intersects a cube:
c4d.utils.
GeRayCollider
¶
GeRayCollider.Init()
GeRayCollider.Intersect()
GeRayCollider.GetIntersectionCount()
GeRayCollider.GetIntersection()
GeRayCollider.GetNearestIntersection()
GeRayCollider.
__init__
(
)
¶
Return type: | c4d.utils.GeRayCollider |
---|---|
Returns: | A new ray collider. |
GeRayCollider.
Init
(
goal
[
,
force=False
]
)
¶
Initalizes the ray collider with the object specified by goal .
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if successful, otherwise False . |
GeRayCollider.
Intersect
(
ray_p
,
ray_dir
,
length
[
,
only_test=False
]
)
¶
Checks if the line segment specified by ray_p to ray_p + ray_dir*ray_length intersects the object.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if there was in intersection, otherwise False |
GeRayCollider.
GetIntersectionCount
(
)
¶
Returns the number of intersections found by
Intersect()
.
Return type: | int |
---|---|
Returns: | Number of intersections. |
GeRayCollider.
GetIntersection
(
number
)
¶
Retrieves the intersection information, 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["s_normal"] # Same as f_normal (reserved for phong normal at the intersection (Not normalized)), c4d.Vector 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
Parameters: | number ( int ) – Intersection index. |
---|---|
Raises: |
IndexError
– If intersection index is out of range :
0<=number<
GetIntersectionCount()
.
|
Return type: | dict |
Returns: | The intersection information. |
GeRayCollider.
GetNearestIntersection
(
)
¶
Retrieves the intersection, found by
Intersect()
, closest to the start of the ray.
Return type: | dict |
---|---|
Returns: | The nearest intersection or None if there was no intersection. |