I'm trying to implement an alternative SkySphere-System to my game and I thought I could use SetRenderQueue to let a small sphere which is always located at my cameras position be rendered behind all other objects. But SetRenderQueue does not work the way I thought it should. When I take a look at the SetRenderQueue example from the 3d demos the two cubes are switching render priorities when pressing F5/F6 but if you move one of the cubes nearer to the camera it does not work anymore. Is SetRenderQueue only working if objects have the same positions in the world? Did I misunderstand the command?
Try this:
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - SetRenderQueue
;
; (c) 2013 - Fantaisie Software
;
; ------------------------------------------------------------
;
;Use [F5]/[F6]
IncludeFile "Screen3DRequester.pb"
#CameraSpeed = 1
#Camera = 0
#Entity0 = 0
#Entity1 = 1
#Material0 = 0
#Material1 = 1
#Mesh = 0
#Texture0 = 0
#Texture1 = 1
If InitEngine3D()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data/Packs/skybox.zip", #PB_3DArchive_Zip)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
CreateMaterial(#Material0, LoadTexture(#Texture0, "clouds.jpg"))
CreateMaterial(#Material1, LoadTexture(#Texture1, "Dirt.jpg"))
CreateCube(#Mesh, 20)
CreateEntity(#Entity0, MeshID(#Mesh), MaterialID(#Material0), 5, 0, 10) ; <=- with z=0 it works!
CreateEntity(#Entity1, MeshID(#Mesh), MaterialID(#Material1), -5, 0, 0)
SkyBox("stevecube.jpg")
CreateCamera(#Camera, 0, 0, 100, 100)
MoveCamera(#Camera, 0, 40, 150, #PB_Absolute)
Repeat
Screen3DEvents()
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_F5)
SetRenderQueue(EntityID(#Entity0), 1)
SetRenderQueue(EntityID(#Entity1), 0)
ElseIf KeyboardReleased(#PB_Key_F6)
SetRenderQueue(EntityID(#Entity0), 0)
SetRenderQueue(EntityID(#Entity1), 1)
EndIf
EndIf
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End

