Collision in TV3DEngine. TVMesh

TVMesh.Collision( linestart As D3DVECTOR, lineend As D3DVECTOR, CheckType As CONST_TV_TESTTYPE, Ret_Distance As Single)

Does a simple a collision test on this mesh. This is basically a ray collision test, that returns the closest hit between the line start and line end (or the first hit found if you specify so)


Arguments :
linestart Start point of the line test
lineend End point of the line test
CheckType Defines the type of test that will be done for collision detection. Bounding box or bounding sphere are the fastest ones, but give less accurate information.
Ret_Distance (Optional, value = 0) Returns the distance from t


Returns :
Boolean Returns True if there was a collision with an element of the mesh.


Remark:



Code Sample :

// detect collision for a player.
Dim CollisionResult As TV_COLLISIONRESULT
IF SceneMesh.Collision(OldPlayerPosition, NewPlayerPosition,
TV_TESTTYPE_ACCURATETESTING, 0) = True Then
// collision happened, move back the player
PlayerPosition = OldPlayerPosition
Else
// no collision, so the player can move
PlayerPosition = NewPlayerPosition
End If



Copyright Truevision3D LLC 2003 - www.truevision3d.com