Game Development Community

Camera Problems

by Simon OCallaghan · in Torque Game Builder · 11/12/2007 (1:32 pm) · 9 replies

I want to setup my game to support different screen sizes but I wanted to do some testing first. I originally designed the game for 1024x768 resolution. The camera in TGB is set to the following for testing:

Camera X:512 Y:384 Width:1024 Height:768 Design Resolution X: 800 Y:600

The screen is made up of a mixture of 2d sprites and 3d shapes using various layers for draw ordering. I have various background images and large amount of 3dshapes in the foreground. All the images and 3d shapes are shrunk down to the correct scale for the 800 x 600 resolution except one problem.

I have a couple of 2d images that I overlay on top of the screen (Layers 3-4) and when the 3dshapes (Layers 19-20) are visible on the screen the 2d images are set to the 1024x768 scale. As soon as I change the visibility on all the 3dshapes to 0 the 2d image pops back to the right scale 800 x 600.

This really does not make any sense because the 2d images behind the 3dshapes are fine, just the one's infront don't scale correctly with the rest of the screen. If I change the 2d sprites to a layer number lower than the 3dshapes they pops to the right scale (In real time!), its like the 3dshapes are interrupting something.

Is there something broken in the camera design resolution code? (I only have the basic version of TGB, no access to code just scripts)
Is there something wierd about 3dshapes and the camera design resolution?

I tried searching through the online documentation but found nothing, I really got no idea what to do next.

I have TGB v1.5.1 (Latest version I think)

Thanks
Simon OC

#1
11/12/2007 (6:16 pm)
Quote:
Camera X:512 Y:384 Width:1024 Height:768 Design Resolution X: 800 Y:600

I do not understand this bit. I keep seeing that people change the scale of their scene objects when changing resolution, I have no idea why.

TGB uses 1unit = 8px by default. It has a camera size of 100x75 and resolution of 800x600 (100*8 x 75*8).

When you change your resolution to 1024x768 you should keep the same ratio, just adjust the camera to size 128.5 x 96. This will keep everything in your scene in the same ratio and not require you to change any objects, physics, collision methods or anything else. If you do not keep the same ratio, then you may have to change many of the previously listed components.

If I am wrong, please somebody tell me before I make a Wiki article about resolutions and cameras!
#2
11/12/2007 (10:49 pm)
Hi,

I have made several illustrations as the TGB camera act with a screen.

1. Game world.
www.invitinggames.com/friends/GarageGames/002/GameWorld.jpg
2. Camera area.
www.invitinggames.com/friends/GarageGames/002/CameraArea.jpg
3. Screen projection for low resolution (eg 800x600).
www.invitinggames.com/friends/GarageGames/002/ScreenResolution800x600.jpg
4. Screen projection for hi resolution (eg 1600x1200)
www.invitinggames.com/friends/GarageGames/002/ScreenResolution1600x1200.jpg
Phillip as you can see, there is no any fixed scale between screen resolution and camera size.

EDIT: I'm sorry for a big size of my images.

EDIT: The Y-axis must be inverted for TGB.
#3
11/12/2007 (11:04 pm)
"If you don't screenshot it then it did not happen!"

This is the game at 1024x768 Screen Resolution. The blank 2dsprite image in the middle is in layer 3 and all the 3dshape's behind it are in layers 19-20. This is the correct location for the 2d image on the screen in relation to everything else. The 2dimage in the foreground is the right scale and size. Here is the TGB Camera Settings.

When I change the camera settings to other resolutions I get the following:

800x600 Screen Resolution and TGB Camera Settings.

640x480 Screen Resolution and TGB Camera Settings.

Quick embedded screenshot to show what happens when the 3dshapes are turned off with setvisible(0)
www.simonoc.com/images/misc/flipper/screen_640.gifwww.simonoc.com/images/misc/flipper/screengood_640.gif
Nothing has changed with the camera settings in the two screenshots above, they are both at 640x480. The 2d image has not changed, simply the 3dshapes behind the 2d image were turned off. The second screen is made up entirely of 2d images.

I also tried the following:

* Different camera settings, 800x600, 640x480, no difference, 2d image still drawn in original size.
* Different 3d shapes, I thought something might be corrupt, no difference
* Different layer numbers, makes no difference. All 2d images higher than the 3d shape layer number are drawn at original scale, no shrink to fit!
* Moved the 3d shapes off the screen, bingo! problem went away.
* Reduced the 3dshape down to really basic parameters, no change
* tried a different 2d image, no difference

Conclusion: All 2d images drawn in higher layers to 3dshapes will not scale correctly with the camera settings in TGB. I'm sure this is a bug, but I could be wrong. It is like the engine finds a 3dshape and then stops scaling all higher layers to the camera settings. Maybe this is not how the camera system is suppose to work, but it is an amazing feature if it did work correctly. I don't have to manually sort out all the screen scaling of all assets. Just change the camera settings and bingo different screen resolutions.

Simon OC
#4
11/12/2007 (11:46 pm)
Simon, the link to TGB Camera Settings for 640x480 screen resolution is bad.
Could you print to console a size of your blank sprite for each resolution?
#5
11/13/2007 (12:57 pm)
Dmitriy, the link is working now. I used the following code to query the 2d image:-

%wind_x = $bck_error.getSizeX();
%wind_y = $bck_error.getSizeY();
echo("Window X: ",%wind_x," Y: ",%wind_y);

I queried the 2dimage in 3 different camera setting and with the 3dshapes active or not and the parameters returned were the same everytime. 1024x768.

While trying to find a solution to this, I found that this problem also occurs in window and full screen mode. There is no difference, its got to be code related.

Does anyone from garagegames read these forums? Should I try another forum?

Simon OC
#6
11/13/2007 (10:28 pm)
I did mean you should try to print a size of the black rectangle on the top of your screenshots.
#7
11/13/2007 (11:27 pm)
Quote:print a size of the black rectangle on the top of your screenshots

Im not sure why you would want this? When the camera system is working, the whole screen is scaled down correctly, including all 2d assets displayed. The original assets don't change in size, its like taking a 1024x768 image in photoshop and resizing it.

I will try and create an example of this for everyone to test out.

Simon OC
#8
11/13/2007 (11:57 pm)
I suppose that if a sprite size and camera size will keep its proportions for all screen resolutions then there is definitely a TGB bug.
#9
11/15/2007 (1:05 am)
Simon, is it possible to start level with 2D images on the layer 31 and then bring its to front?

In any case, try to post your message to "Report Bugs" forum.