Using more than one camera

Blitz3D Forums/Blitz3D Beginners Area/Using more than one camera

Bankie(Posted 2006) [#1]
I am working on a large project and it's going very well but I still seem to lack some fundamental knowledge on B3D. This time, it's cameras.

My problem is that I'm using SpriteCandy for my GUI, and to use this I need the minimum CameraRange to be set to 1 or less, or it won't display. However, my game needs the minimum range to be a bit higher than this to get rid of the usual frustrum jaggy edge problems.

I thought that a way around this would be to create another camera, and use that for the GUI (no problem) but then this new camera is used for all rendering rather than just the GUI elements.

Am I on the right lines with trying to use 2 cameras? If so, how do I tell Blitz which items to draw using which camera? Or am I completely misunderstanding the use of cameras and I need to use the same minimum CameraRange value for everything? I've been flaffing around for ages with my code and getting nowhere, so even a wee prod in the right direction would be greatly appreciated.


Sledge(Posted 2006) [#2]

Am I on the right lines with trying to use 2 cameras? If so, how do I tell Blitz which items to draw using which camera?



The only way (AFAIK) is either by manually hiding everything from the appropriate camera, rendering separately, then compositing the renders OR separating elements for each camera (spatially) so that they fall only within the intended camera's view and having them render over the top of one another:

Graphics3D 800,600,0,2
cam1=CreateCamera()
cam2=CreateCamera() : CameraClsMode cam2,False,True

PositionEntity cam2,0,0,1000


cube=CreateCube() : EntityColor cube,100,100,200
sphere=CreateSphere() : EntityColor sphere,200,100,100

PositionEntity cube,0,0,10

While Not KeyHit(1)
TurnEntity cube,1,2,3
sphereX=sphereX+1 : If sphereX>359 Then sphereX=sphereX-360
PositionEntity sphere,Cos(sphereX),0,1010


RenderWorld
Flip
Wend



Bankie(Posted 2006) [#3]
Thanks for your reply, Sledge. My understanding of what's going on is still a bit sketchy, but I've managed to implement your explanation and it works so I guess that's the main thing for now. Cheers!


Sledge(Posted 2006) [#4]

My understanding of what's going on is still a bit sketchy



The cameras render in the order they were created with Cam2 set so that it does not clear the backbuffer (otherwise you'd only get what Cam2 can see).

Cam1 can see the blue cube only; Cam2 can see the red sphere only. You will note that the generated scene shows the blue cube with the red sphere overlayed: If you think of the red sphere as your GUI elements and Cam2 as your "GUIcam", you would simply squirrel these GUI-objects far away from the main in-game scene and camera (parenting both to Cam1 might be a good idea if Cam1 is able to travel far) so they get rendered in isolation.


Myrmydon(Posted 2006) [#5]
You can also have it like this

Graphics 3d xx,yy,zz/2

and the screen is divided in two for two different cameras but you need to create the cameras first


Stevie G(Posted 2006) [#6]
Eh, what you on about Myrmidon? You can't create cameras until the 3d scene is set and what purpose does dividing the screen depth by 2 serve?

Stevie


Myrmydon(Posted 2006) [#7]
I read wrong in a book I found on Blitz3d so scracth that last post