entity in view question

Blitz3D Forums/Blitz3D Programming/entity in view question

Ross C(Posted 2003) [#1]
is there anyother way to find out if an entity can be seen by the camera. reason being it's a bit inaccurate. please run the following code to demonstrate. move the camera so the entity is out of view, it should still say entity in view becasue it only check the bounding box. This will be used to hide entities that are not in the cameras view.

Graphics3D 800,600
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,0,-10


light=CreateLight()


shape=CreateCylinder()
ScaleEntity shape,1,15,1
RotateEntity shape,0,0,45


While Not KeyHit(1)
	
	If KeyDown(203) Then MoveEntity camera,-0.2,0,0
	If KeyDown(205) Then MoveEntity camera,0.2,0,0
	If KeyDown(200) Then MoveEntity camera,0,0.2,0
	If KeyDown(208) Then MoveEntity camera,0,-0.2,0
	
	
	
	
	
	UpdateWorld
	RenderWorld
	If EntityInView(shape,camera) Then Text 0,0," i can see you!!!"
	Flip
Wend
End



Jeremy Alessi(Posted 2003) [#2]
Trying to determine if an entity can be seen by the camera is very difficult to do right. That is why a good occlusion system is hard to come by and involves some pretty complex code.

It really depends on the entity you're trying to search for. I had to create a small occlusion system for lens flares in True-Vol. There were only up to 7 per level and I used Linepick(), which is a very expensive call in terms of processing.

To get around the speed issues I put the calls on a timer so that they would only be called every few frames like every 50 - 100 milliseconds. It sped the game up tremedously and I was able to hide the lights although not super fast. I recommend always using picks as few times as possible and put a timer on them unless it's for something that needs to be updated fast every frame like a shadow directly underneath the player (something I have to do in Aerial Antics to help with gameplay should the user have the real time shadows turned off).


Ross C(Posted 2003) [#3]
so line picks are the way to go. thanks for your reply :)