vcanim.gif (8357 bytes)Bounding Box Collision Detection
Home ] Sales ] Products ] Services ] Support ] Downloads ]

 

 


bbdetectcoll

bbdetectcoll is a library function which detects if bounding boxes of two objects collide.

package require SWU

bbdetectcoll objA_trnMatrixID objB_trnMatrixID objA_minVertexID objA_maxVertexID objB_minVertexID objB_maxVertexID
objA_trnMatrixID
Transformation matrix of object A.
objB_trnMatrixID
Transformation matrix of object B
objA_minVertexID
Coordinates of the lower vertex of the bounding box of the object A.
objA_maxVertexID
Coordinates of the upper vertex of the bounding box of the object A.
objB_minVertexID
Coordinates of the lower vertex of the bounding box of the object B.
objB_maxVertexID
Coordinates of the upper vertex of the bounding box of the object B.

Return Value

If the procedure succeeds then it returns 1 if the objects collide and 0 if they don't collide. Otherwise the procedure returns an error message (shown on the Tk console command line).

Side Effects

None.

Examples

set curScene [SAA_AllocScene]
Scene2
SAA_sceneGetCurrent $curScene
package require SW
1.0
set objectAID [SW_name2Element sphere1 $curScene]
Elem4
set objectBID [SW_name2Element sphere2 $curScene]
Elem6
set objA_trnMatrixID [SAA_AllocMatrix]
Matrix7
SAA_modelGetMatrix $curScene $objectAID $SAA_Constants(SAA_COORDSYS_GLOBAL) $objA_trnMatrixID
set objB_trnMatrixID [SAA_AllocMatrix]
Matrix8
SAA_modelGetMatrix $curScene $objectBID $SAA_Constants(SAA_COORDSYS_GLOBAL) $objB_trnMatrixID
SAA_modelGetBoundingBox $curScene $objectAID minX minY minZ maxX maxY maxZ
package require SWU
1.0
set objA_minVertexID [SWU_listToCArray [list $minX $minY $minZ] float]
FloatArray9
set objA_maxVertexID [SWU_listToCArray [list $maxX $maxY $maxZ] float]
FloatArray10
SAA_modelGetBoundingBox $curScene $objectBID minX minY minZ maxX maxY maxZ
set objB_minVertexID [SWU_listToCArray [list $minX $minY $minZ] float]
FloatArray11
set objB_maxVertexID [SWU_listToCArray [list $maxX $maxY $maxZ] float]
FloatArray12
bbdetectcoll $objA_trnMatrixID $objB_trnMatrixID $objA_minVertexID $objA_maxVertexID $objB_minVertexID $objB_maxVertexID
1

This retrieves transformation matrices and bounding boxes for sphere1 and sphere2 and detects if bounding boxes collide.


Behaviors Overview ] Behavior Evaluate ] Behavior Edit ] Debugger ] Console ] Find ] SAA Library ] SW library ] SWC library ] SWN library index ] SWU library ] Attributes Index ] Scripting Examples ]

copyright Video-Collage Inc.