The Occlusion challenge

Blitz3D Forums/Blitz3D Programming/The Occlusion challenge

I see what your saying Koriolis :) This is a bit of learning for me here.

@Todd

Thanks :o) Well, i think that would be the first step if i were to do occlusion, get rid of all the stuff that wasn't needed. I don't really know where to go from there. Maybe entity in view would be better, again tho it wouldn't be a very fullproof idea, as i think that everything has to be pickable and it doesn't work too well:

Graphics3D 800,600
SetBuffer BackBuffer()


camera=CreateCamera()

camera_overhead=CreateCamera()

PositionEntity camera_overhead,0,60,0
HideEntity camera_overhead

sphere=CreateCone()
PositionEntity sphere,0,-1,0
ScaleEntity sphere,1,1,3
EntityParent camera,sphere
PositionEntity camera,0,1,0


PointEntity camera_overhead,sphere

light=CreateLight()

Type cube
	Field ent
	Field x#,y#,z#
	Field hidden
End Type


For loop=0 To 20
	c.cube=New cube
	c\ent=CreateCube()
	c\x=Rnd(-20,20)
	c\y=0
	c\z=Rnd(-20,20)
	PositionEntity c\ent,c\x,c\y,c\z
	c\hidden=0
	EntityPickMode c\ent,2
Next


While Not KeyHit(1)



	If KeyDown(200) Then MoveEntity sphere,0,0,0.2
	If KeyDown(208) Then MoveEntity sphere,0,0,-0.2
	If KeyDown(203) Then TurnEntity sphere,0,1,0
	If KeyDown(205) Then TurnEntity sphere,0,-1,0
	
	If KeyHit(2) Then
		ShowEntity camera
		HideEntity camera_overhead
	End If
	If KeyHit(3) Then
		ShowEntity camera_overhead
		HideEntity camera
	End If
	
	Gosub checkvis
	UpdateWorld
	RenderWorld
	Flip
Wend
End

.checkvis
	For c.cube=Each cube
		If EntityInView(c\ent,camera) Then
			If EntityVisible(camera,c\ent) Then
				If c\hidden=1 Then
					ShowEntity c\ent
					c\hidden=0
				End If
			Else
				If c\hidden=0 Then
					HideEntity c\ent
					c\hidden=1
				End If
			End If
		Else
			If c\hidden=0 Then
				HideEntity c\ent
				c\hidden=1
			End If
		End If
	Next
Return


Entities disappear even tho they can still be seen.