ArcBasicDocs
3DPhysicsArcBasic extension

PhysicsOverlapBox

Number of physics bodies touching a box.

PhysicsOverlapBox ( x#,y#,z#,width#,height#,depth#[,pitch#][,yaw#][,roll#] )

Parameters

x#, y#, z#
the middle of a box
width#, height#, depth#
its size
pitch#, yaw#, roll# (optional)
how it is turned

Description

Returns the number of physics bodies touching a box, and remembers which they are for OverlapEntity.

Bodies are found where they are now, even if they have moved since the last UpdateWorld. Mesh shapes are hollow, so a box entirely inside one does not find it.

Example

PhysicsOverlapBox.absOpen in editor
; Physics queries example (an ArcBasic extension); A turning laser shows what it hits; Space sets off a blast that throws; everything nearby into the airGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,10,-14TurnEntity camera,35,0,0light=CreateLight()RotateEntity light,50,30,0ground=CreatePlane()EntityColor ground,60,90,60EntityPhysics ground,1For i=1 To 30	c=CreateCube()	ScaleEntity c,.4,.4,.4	PositionEntity c,Rnd(-6,6),.4,Rnd(-4,6)	EntityPhysics c,2Nextlaser=CreatePivot()PositionEntity laser,0,.5,0beam=CreateCube()EntityColor beam,255,40,40EntityFX beam,1dot=CreateSphere(6,beam)ScaleEntity dot,.15,.15,.15While Not KeyHit(1)	TurnEntity laser,0,1,0	TFormVector 0,0,20,laser,0	hit=PhysicsLinePick(EntityX(laser),.5,EntityZ(laser),TFormedX(),0,TFormedZ())	If lastHit Then EntityColor lastHit,255,255,255	If hit		length#=PickedTime()*20		EntityColor hit,255,120,120	Else		length#=20	EndIf	lastHit=hit	; stretch the beam from the laser to what it hit	ScaleEntity beam,.03,.03,length/2	PositionEntity beam,0,.5,0	RotateEntity beam,0,EntityYaw(laser),0	MoveEntity beam,0,0,length/2	If KeyHit(57)		; everything within 4 units of the middle is thrown outwards		For i=1 To PhysicsOverlap(0,0,1,4)			e=OverlapEntity(i)			If e<>ground				dx#=EntityX(e)-0 : dz#=EntityZ(e)-1				ApplyImpulse e,dx*.4,1.5,dz*.4			EndIf		Next	EndIf	UpdateWorld	RenderWorld	Text 0,0,"Space: blast   Cubes in the box in front: "+PhysicsOverlapBox(0,.5,-3,6,1,2)	FlipWendEnd

See also