Page 1 of 1

SetRenderQueue only works if objects have same coordinates?

Posted: Sat Jan 11, 2014 12:04 am
by MightyMAC
Hi guys,

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

Re: SetRenderQueue only works if objects have same coordinat

Posted: Sat Jan 11, 2014 12:44 am
by Samuel
I asked the same question a couple months ago.
http://www.purebasic.fr/english/viewtop ... 36&t=57019
Comtois wrote: this function is missing (we'll add it for the next version)
I heard the next update will be early this year.

EDIT:
Let me rephrase that last part.
I don't now for sure there is an update, but I'm assuming Fred's big announcement comes with an update.

Re: SetRenderQueue only works if objects have same coordinat

Posted: Sat Jan 11, 2014 1:27 am
by Samuel
Nope, just going off of what Fred said.
Fred wrote: Merry christmas to all of you ! Looking forward to 2014 with a big announcement coming early the next year ! :)
Sounds like an update to me, but I could be wrong.

@MightyMAC
If you can't wait for an update. You could try the material script Comtois posted. It's in the link from my previous post.

Re: SetRenderQueue only works if objects have same coordinat

Posted: Sat Jan 11, 2014 11:45 pm
by MightyMAC
I think I'll give the material script workaround a try. Thanks!