Vertical Split screen script request SOLVED

SOLVED: see post number two by Cthames for answer and post number two by Sunjay03 for another solution.

Hi there guys!

Is there any up to date vertical split screen script? I’m trying to use this old piece of Python, but it returns many errors and it renders just one camera… (Please take a look at the attached Blend file).

from Rasterizer import *
cont = GameLogic.getCurrentController()
own = Owner()
    
own.enableViewport(1)
own.setViewport(getWindowWidth()*.5, getWindowHeight()*.0, getWindowWidth()*1, getWindowHeight()*1)

Thank you!

Attachments

BrokenVerticalSplitScreen.blend (141 KB)

I changed the camera to the yellow side of the box, it it worked 0.o

No it doesn’t, sorry. You just moved the linked one to another position. I need two cameras working and no errors inside the terminal. But thankx anyway…

Here goes another version, i hope someone understand my setup: i have 3 cameras need to see the other 2 inside the active one. Please check my updated file.

Attachments

BrokenVerticalSplitScreenB.blend (141 KB)

hi Thorgal,

The first problem is that you were trying to use floats and setViewport only uses integers. You have to use 1/2 instead of 0.5.

Second problem was that you were placing the two viewports in the same place. One on top of the other.

I fixed the code but I left the python as 2.48 like you had it.

Clark

Attachments

BrokenVerticalSplitScreen_Fixed.blend (143 KB)

Hey Clark thank you very much! You’re awesome.

ok… So here is my tentative to update the method.

I’m getting the following warnings inside the terminal with Clark’s (Cthames) version:

Blender Game Engine Started

Method getOwner() is deprecated, please use the owner property instead.
Blue:8
Method enableViewport(bool) is deprecated, please use the useViewport property instead.
Blue:20

Blender Game Engine Finished

So I’m trying to fix the script like this

# get owner
own = cont.getOwner()

Should be:

# get owner
own = cont.owner

and

# set viewport
own.setViewport(width * 1/2, height * 0, width, height * 1)

Should be:

# set viewport
own.useViewport(width * 0, height * 0, width * 1/2, height * 1)

Is it right? Is it supposed to work just inside 2.5? Because with this substitution I’m getting the following error inside 249.2:

Blender Game Engine Started

Python script error from controller “cont#CONTR#1”:
Traceback (most recent call last):
File “Blue”, line 17, in ?
TypeError: ‘bool’ object is not callable
Python script error from controller “cont#CONTR#1”:
Traceback (most recent call last):
File “Yellow”, line 17, in ?
TypeError: ‘bool’ object is not callable

Blender Game Engine Finished

Thank you!

Yours,

Ortiz.

PS: latest .blend file (error message one):

Attachments

BrokenVerticalSplitScreen_FixedB.blend (143 KB)

Im going to post my script. its just one script that handles both cameras. just put it into your game and change the objects in the first variables.

ill post the script later.

hi Thorgal,

Leave setViewport as it is and replace
own.enableViewport(True)
with
own.useViewport = True

link to documentation for useViewport

Clark

Attachments

BrokenVerticalSplitScreen_2.49.blend (143 KB)

Ok. Im uploading.

Here is is:
View Ports example.blend (141 KB)

Hey guys thank you very much you’re very kind!

:yes:

Clark,

thx for the example file. Your resources are also very helpful. One request though:

Could you please add to your description (at http://www.tutorialsforblender3d.com/GameModule/ClassKX_Camera_11.html)
that the 0/0 point lies in the lower left corner? That info could help others (like me) who go crazy because their cam script doesn’t work correctly. I assumed 0/0 would be in the top left corner… :confused:

stuipid me, but could you please add that info nethertheless?

hmmm, have you all noticed that the different viewports are shaded awkwardly?

I have a scene in which the viewport consists of 3 camera views of a cube: top/ side/ front

Now the problem is, that the shading of the cube seen in each of the 3 camera views is only depending on the position of view in the moment you press “p” to start the game engine! Just stop the GE, move a bit around with MMB and press p again…
But that’s stuipid! The shading of the cube should only depend on the view of the single cameras and the light source. You can even position your view so that everything is black all the time. (Just hit Num-0 and than p).

Anyone knows what’s going on there? I think it’s a bug or am I doing something wrong here?

So what’s the limitation of setViewport anyway? Should it work with GLSL Mats and Textures as well?

Thx,

-zapman

Attachments

CAD.blend (149 KB)

hi zapman,

zapman wrote:

Clark,
thx for the example file. Your resources are also very helpful. One request though:Could you please add to your description that the 0/0 point lies in the lower left corner?
Sure. I can do that.

Clark