frustrum culling (camera inside shadow volume) ?

Blitz3D Forums/Blitz3D Programming/frustrum culling (camera inside shadow volume) ?

I'm not sure if this works, I don't know how to test it.
;-------------------------------------------------------------------------------------------------------
;											TestForArea()
;-------------------------------------------------------------------------------------------------------
;combine IsInRedArea and IsBelowCaster
Function TestForArea(camera, light, entity, radius)

	test1 = IsInRedArea(camera, light, entity, radius)
	test2 = IsBelowCaster(camera, light, entity, radius)
	
	Return (test1 And test2)
	
End Function

;-------------------------------------------------------------------------------------------------------
;											 IsInRedArea()
;-------------------------------------------------------------------------------------------------------
;if camera is within red area
Function IsInRedArea(camera, light, entity, radius )

	;distance light-entity
	dist1# = EntityDistance(light, entity)
	;distance light-camera
	dist2# = EntityDistance(light, camera)
	
	;light x,y,z	
	x1# = EntityX(light)
	y1# = EntityY(light)
	z1# = EntityZ(light)
	
	;entity x,y,z
	x2# = EntityX(entity)
	y2# = EntityY(entity)
	z2# = EntityZ(entity)
	
	;extrapolate entity position to the same distance as the distance from camera to light
	x# = ((x2 - x1) * dist2 / dist1) + x1
	y# = ((y2 - y1) * dist2 / dist1) + y1
	z# = ((z2 - z1) * dist2 / dist1) + z1
	
	;position a pivot at that location	
	temppivot = CreatePivot()
	PositionEntity temppivot, x, y, z
	
	;distance camera-new location
	dist# = EntityDistance(camera, temppivot)
	FreeEntity temppivot	
	
	;check if this distance is within the radius	
	Return (dist < radius)
	
End Function

;-------------------------------------------------------------------------------------------------------
;										   IsBelowCaster()
;-------------------------------------------------------------------------------------------------------
;if camera is outside entity radius and farther away from the light than the entity
Function IsBelowCaster(camera, light, entity, radius)
	
	;if the camera is closer to the light than the entity, return 0
	If EntityDistance(camera, light) < EntityDistance(camera, entity) Then Return 0
	;return if the distance camera-entity is outside the radius
	Return (EntityDistance(camera, entity) > radius)
	
End Function