Posted tagged ‘Papervision3D’

Considerations in Collision Detection with PV3D

February 28, 2008
use left and right arrows.

The collision detection in Papervision3D is not a big deal. Is easy to detect collision between two DisplayObject3D for that task PV3D provide us with two methods

public function hitTestPoint( x:Number, y:Number, z:Number ):Boolean

public function hitTestObject( obj:DisplayObject3D,multiplier:Number=1 ):Boolean

The first method is to test if the current DisplayObject3D is hitting a point in the scene and the second one is to detect if the current object is hitting another DisplayObject3D in the scene.
This is quite similar to the display architecture used by flash and its DisplayObject the difference is when we have a main DisplayObject3D with other objects 3D as childs.
In that case we would be tempted to use hitTestObject assuming that the collision test will be tested using the parent DisplayObject3D and their childs but that is wrong.