Panda3D手册:碰撞记录

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.
对于每一个碰撞检测,都要建立一个新的 CollisionEntry 对象。CollisionEntry 会记录所有的碰撞信息,包括参与碰撞的两个物体(节点),还有碰撞的位置以及进入物体的表面法线。

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 CollisionHandlerQueue.
CollsinoEntry 物体由 CollisionHandlerEvent 传递给事件处理程序;它也会通过 CollsiionHandlerQueue 在队列中保留碰撞记录。

However you get a handle to CollisionEntry object, you can query it for information using the following methods:
要得到 CollisionHandlerEvent 对象的句柄,您可以使用下面的查询方法:

entry.getFromNodePath()Returns the NodePath of the "from" object. This NodePath will contain a CollisionNode.
返回 “from” 的 NodePath 。这个 NodePath 包含一个 CollisionNode。
entry.getIntoNodePath()Returns the NodePath of the "into" object. This NodePath will contain a CollisionNode, or if the collision was made with visible geometry, a GeomNode.
返回 “into” 的 NodePath 。这个 NodePath 包含一个 CollisionNode ,或者是一个 GeomNode。
entry.getFrom()Returns the actual CollisionSolid of the "from" object. This is useful if there were more than one CollisionSolid in the "from" CollisionNode.
从 “from” 物体中返回一个 CollisionSolid 。在 “from” CollisionNode 拥有多个 CollisionSolid 的情况下很有用。
entry.getInto()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.
从 “into” 物体中返回一个 CollisionSolid 。然而,如果碰撞是由可见的多边形产生的,就不会返回 CollisionSolid 了,并且会称为一个无效的调用。
entry.hasInto()Returns true if the collision was made into a CollisionSolid as opposed to visible geometry, and thus the above call will be valid.
如果碰撞是由 CollisionSolid 产生的,则返回 true ,上面的调用也是有效的。
entry.getSurfacePoint(nodePath)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.
返回三维空间中的一个点,这个点代表物体碰撞的位置,在 NodePath 提供的坐标系空间中。这个点通常是 “into” 物体表面上的一个点。
entry.getSurfaceNormal(nodePath)Returns the 3-D surface normal of the "into" object at the point of the collision, in the coordinate space of the supplied NodePath.
返回三维空间中的一个表面法线,这个法线是 “into” 物体碰撞位置的法线,坐标系由 NodePath 提供。
entry.getInteriorPoint(nodePath)Returns the 3-D point, within the interior of the "into" object, that represents the depth to which the "from" object has penetrated.
返回三维空间中的一个点,这个点在 “into” 物体的内部,代表 “from” 物体在其内部的深度。


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:
最后三种可以返回一组点或一组向量的方法,都接受一个 NodePath 作为参数。它可以是场景中的任何 NodePath ;它提供一个坐标空间,让您获得以这个空间为参照的位置。例如,如果您希望得到相对于 “into” 物体的一个点的位置,您可以使用:

point = collisionEntry.getSurfacePoint(collisionEntry.getIntoNodePath())

If you wanted to put an axis at the point of the collision to visualize it, you might do something like this:
如果您想把一个碰撞的位置形象化,您可以这样做:

axis = loader.loadModel('zup-axis.egg')
axis.reparentTo(render)
point = collisionEntry.getSurfacePoint(render)
normal = collisionEntry.getSurfaceNormal(render)
axis.setPos(point)
axis.lookAt(point + normal)