Rendering half screen

Blitz3D Forums/Blitz3D Programming/Rendering half screen

syntax(Posted 2007) [#1]
Is there any way of rendering one camera at a time? I have a horizontal splitscreen and I was wondering if there would be some way of showing a model on one screen but not the other.


t3K|Mac(Posted 2007) [#2]
how about using CameraViewport camera,x,y,width,height? i think this command should help.


Uncle(Posted 2007) [#3]
You can do 2 renders before your flip. Render the first camera, and disable the second by using the cameraprojmode to hide the camera you dont want to render. Then hide your entity and the first camera using cameraprojmode again, then render the second camera (making sure you have unhidden it).


Rob Farley(Posted 2007) [#4]
or just have 2 cameras with different viewports and they'll both render when you do renderworld

Graphics3D 1024,768,32,2

light1 = CreateLight()
TurnEntity light1,20,20,0

camera1 = CreateCamera()
CameraViewport camera1,0,0,1024,384
camera2 = CreateCamera()
CameraViewport camera2,0,384,1024,384
Cam1Mesh = CamMesh(camera1)
Cam2Mesh = CamMesh(camera2)


middle = CreatePivot()

For n=1 To 10
	c = CreateCube()
	RotateEntity c,Rand(0,359),Rand(0,359),Rand(0,359)
	EntityColor c,Rand(0,255),Rand(0,255),Rand(0,255)
	PositionEntity c,Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)
Next

MoveEntity camera1,Rand(-20,20),Rand(-20,20),Rand(-20,20)
MoveEntity camera2,Rand(-20,20),Rand(-20,20),Rand(-20,20)


Repeat

	ms# = Float(MilliSecs())/100.0

	PositionEntity camera1,Sin(ms)*10,0,Cos(ms)*15
	PositionEntity camera2,-Sin(ms)*15,-Sin(ms)*10,-Cos(ms)*12
	
	
	PointEntity camera1,middle
	PointEntity camera2,middle
	
	RenderWorld
	Flip
Until KeyHit(1)

Function CamMesh(Parent)

	c1 = CreateCube()
	c2 = CreateCone(6)
	PositionMesh c2,0,-1,0
	
	AddMesh c1,c2
	FreeEntity c1
	
	RotateMesh c2,-90,0,0
	ScaleMesh c2,.5,.5,.5
	
	EntityParent c2,parent
	
	Return c2
End Function



syntax(Posted 2007) [#5]
well the problem that i had with Uncle's idea was that when you call render world the second time to process the second camera, the renderer overwrites the first camera. EntityAutoFade is the only command that I saw that came close to what I need becuase it will fade an object according to how far each camera is from it. Unfortunatly, with my situation, I need the opposite effect that EntityAutoFade has. I guess i could render and copy the first camera's image and paste it after the second camera renders, but I don't know what kinda syntax to do that in.
Anyway thanks for the help so far.


Andy(Posted 2007) [#6]
>well the problem that i had with Uncle's idea was that
>when you call render world the second time to process the >
>second camera, the renderer overwrites the first camera.

Not if you use the CameraViewport command.

>EntityAutoFade is the only command that I saw that came
>close to what I need becuase it will fade an object
>according to how far each camera is from it.

What does that have to do with split screen?

>I guess i could render and copy the first camera's image
>and paste it after the second camera renders, but I don't
>know what kinda syntax to do that in.

What is wrong with ¿?'s example? It does exactly what you asked for!

Andy


Uncle(Posted 2007) [#7]
Indeed for it to work properly you need to set up your viewports. Im working on an editor which has 4 viewports, and 5 cameras. It has one camera for each viewport and a final camera which is renders the GUI. Here it is in action...

http://www.youtube.com/watch?v=zSRheTOWz10

Here is the code used to set up the cameras...

Function InitCameras()
	hudcam=CreateCamera()
	CameraViewport hudcam,0,0,GraphicsWidth(),GraphicsHeight()
	CameraClsMode hudcam,0,1
	
	cube=CreatePivot()
	
	;TOP VIEW CAMERA
	topcam=CreateCamera() ;create camera
	CameraViewport topcam,0,(height#),GraphicsWidth()/2,(height#); set viewport
	CameraClsColor topcam,110,110,110
	TranslateEntity topcam,0,50,0
	CameraZoom topcam,TopZoom#
	CameraRange topcam,0.1,8000
	PointEntity topcam,cube
	
	;SIDE VIEW CAMERA
	sidecam=CreateCamera()
	CameraViewport sidecam,0,0,GraphicsWidth()/2,height#
	CameraClsColor sidecam,110,110,110
	TranslateEntity sidecam,-50,0,0
	CameraZoom sidecam,SideZoom
	CameraRange sidecam,0.1,8000
	PointEntity sidecam,cube
	
	;FRONT VIEW CAMERA
	frontcam=CreateCamera()
	CameraViewport frontcam,GraphicsWidth()/2,0,GraphicsWidth()/2,height#
	CameraClsColor frontcam,110,110,110
	TranslateEntity frontcam,0,0,-50
	CameraZoom frontcam,FrontZoom
	CameraRange frontcam,0.1,8000
	PointEntity frontcam,cube
	
	prevcam=CreateCamera()
	CameraViewport prevcam,GraphicsWidth()/2,height#,GraphicsWidth()/2,height#
	CameraClsColor prevcam,110,110,110
	TranslateEntity prevcam,50,20,-50
	PointEntity prevcam,cube
	CameraZoom prevcam,1.8
end function


and here is the code I use to render the windows.

Function RenderAll()
	ClsColor 50,50,50
	Cls
	CameraProjMode topcam,2
	CameraProjMode frontcam,2
	CameraProjMode sidecam,2
	CameraProjMode prevcam,1
	CameraProjMode hudcam,0
	RenderWorld()
	CameraProjMode topcam,0
	CameraProjMode frontcam,0
	CameraProjMode sidecam,0
	CameraProjMode prevcam,0
	CameraProjMode hudcam,1
	RenderWorld()
        flip 0
End Function


Hopefully this will help.


Ross C(Posted 2007) [#8]
Don't you need to change the cameraclsmode?


cyberyoyo(Posted 2007) [#9]
I don't know if that would work but you could try using only one camera.
Set its cameraviewport to top half of screen, renderworld with entity, hide entity, set cameraviewport to bottom half of screen, renderworld, flip.


cyberyoyo(Posted 2007) [#10]
I don't know if that would work but you could try using only one camera.
Set its cameraviewport to top half of screen, renderworld with entity, hide entity, set cameraviewport to bottom half of screen, renderworld, flip.


It works!
try this little program to see an example
Graphics3D 1024,768,32
SetBuffer BackBuffer() 

camera=CreateCamera()

cube=CreateCube()
EntityColor cube,255,0,0
PositionEntity cube,0,0,0

sphere=CreateSphere()
EntityColor sphere,0,255,0
PositionEntity sphere,2,0,0

light=CreateLight()
PointEntity light,cube

circ=0
Repeat
	PositionEntity camera,Cos(circ)*5,0,Sin(circ)*5
	PointEntity camera,cube
	circ=circ+1

	ShowEntity sphere
	CameraViewport camera,0,0,512,768
	RenderWorld 

	HideEntity sphere
	CameraViewport camera,512,0,512,768
	RenderWorld 

	Flip

Until KeyHit(1)

End