For each collision detected, a new
CollisionEntry object is created. This
CollisionEntry stores all the information about the collision, including the two
objects (nodes) involved in the collision, and the point of impact and the
surface normal of the into object at that point.
The CollisionEntry object is passed to the event handler method by the
CollisionHandlerEvent and its derivatives; it is also the object stored in
the queue of collisions maintained by the
However you get a handle to CollisionEntry object, you can query it for information using the following methods:
Returns the NodePath of the “from” object. This NodePath will contain a CollisionNode.
Returns the NodePath of the “into” object. This NodePath will contain a CollisionNode, or if the collision was made with visible geometry, a GeomNode.
Returns the actual CollisionSolid of the “from” object. This is useful if there were more than one CollisionSolid in the “from” CollisionNode.
Returns the actual CollisionSolid of the “into” object. However, if the collision was made with visible geometry, there is no CollisionSolid, and this will be an invalid call.
Returns true if the collision was made into a CollisionSolid as opposed to visible geometry, and thus the above call will be valid.
Returns the 3-D point of the collision, in the coordinate space of the supplied NodePath. This point will usually be on the surface of the “into” object.
Returns the 3-D surface normal of the “into” object at the point of the collision, in the coordinate space of the supplied NodePath.
Returns the 3-D point, within the interior of the “into” object, that represents the depth to which the “from” object has penetrated.
The three methods that return points or vectors all accept a NodePath as a parameter. This can be any NodePath in the scene graph; it represents the coordinate space in which you expect to receive the answer. For instance, to receive the point of intersection in the coordinate space of the “into” object, use:
point = collisionEntry->get_surface_point(collisionEntry->get_into_node_path());
If you wanted to put an axis at the point of the collision to visualize it, you might do something like this: