EntityOrder problem

Blitz3D Forums/Blitz3D Programming/EntityOrder problem

Hey, check this out

Graphics3D 800,600
SetBuffer BackBuffer()


Global camera = CreateCamera()
CameraRange camera,0.1,1000

Global gun = CreateCylinder(8,True,camera) ; create a 8 seg cylinder, filled, and parented to the camera
PositionEntity gun,1,-0.2,0
ScaleEntity gun,0.3,2,0.3
RotateEntity gun,90,0,0


Global light = CreateLight()

Global world = CreatePivot() ; create a pivot called world

;just set up some cubes so there is something on screen. Parent these cubes to the world pivot, so
; you only need to hide the world pivot, to hide the level :o)

Dim cube(40)
For loop = 0 To 40
	cube(loop) = CreateCube(world) ; parent all the objects in the level to the world pivot, for easy hiding
	EntityColor cube(loop) , Rand(100,255), Rand(100,255), Rand(100,255)
	PositionEntity cube(loop) , Rnd(-15,15), 0, Rnd(5,35)
Next



While Not KeyHit(1)


	If KeyDown(203) Then TurnEntity camera,0,1,0
	If KeyDown(205) Then TurnEntity camera,0,-1,0
	If KeyDown(200) Then MoveEntity camera,0,0,0.2
	If KeyDown(208) Then MoveEntity camera,0,0,-0.2

	If KeyHit(2) Then HideEntity world
	
	HideEntity gun ; hide the gun. You don't really NEED to hide the gun, as the next render will render over it, but no point in rendering it twice :)
	CameraClsMode camera,True,True ; set the camera cls mode so the last renderworld gets cleared
	UpdateWorld
	RenderWorld ; render the world
	
	ShowEntity gun ; show the gun and
	HideEntity world ; hide the world
	CameraClsMode camera,False,True ; set the camera cls mode so the last render to the backbuffer won't be cleared, only written on top of
	RenderWorld ; render the gun

	Flip ; flip the back buffer so it can be seen
	
	ShowEntity world ; show the world again for the next time
	
Wend
End


Uses two renders. Firstly renders the world and hides the gun. Then shows the gun and hides the world. All the level objects are parented to the one pivot called "World", so to hide the world you just hide the pivot, and anything parented to the pivot will get hidden too. Hope that helps a little :o)