Game Development Community

Camera Size wrong?

by Phillip O'Shea · in Torque Game Builder · 12/10/2007 (2:30 pm) · 10 replies

I noticed this a while ago, but I forgot the mention it.

In my scene I'm using the default camera size of 100x75, but when I type:

echo(sceneWindow2D.getCurrentCameraSize());

I get a size of 99x74!

When I change the camera size to 80x60, i get a size of 79x59!

Is this a bug? Or there for a reason?

About the author

Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.


#1
12/10/2007 (3:20 pm)
I'm guessing that getCurrentCameraSize is just returning the highest X and Y pixel locations. They probably start at zero and go to 99 (or whatever). So you have 100 x 75 pixels but they are numbered 0-99 x 0-74.

I'm not saying this makes sense. I'm just saying that that is probably what's going on.
#2
12/10/2007 (3:31 pm)
If you also echo the current camera area, then deduct the max from the min points, you will see that the actual size is 99 not 100 as well.
#3
12/12/2007 (12:52 am)
I've also noticed this. Glad to see I wasn't the only one.
Since the default camera is like this, I initially assumed it was the 'correct' way to size a camera. Since then I've used some pretty small camera sizes and it appears to visually distort the scene. So I've changed all my camera sizing to use setCurrentCameraArea, which doesn't have the same problem.

Am I wrong, is there some logic behind a camera of width=80 going from -40 to 39 rather than -40 to 40?
#4
12/13/2007 (5:54 am)
Quote:is there some logic behind a camera of width=80 going from -40 to 39 rather than -40 to 40?

Because -40 to 40 would be a width of 81. (0,0) is a point.
#5
12/13/2007 (7:24 am)
I've noticed this myself recently, when working with very small camera sizes. I suspect it's a bug, but I haven't gotten around to digging into it yet to see if there's any good reason that the code does it this way.
#6
12/13/2007 (10:50 am)
Quote: Because -40 to 40 would be a width of 81. (0,0) is a point.

I think that's incorrect. There are 81 points but only 80 spaces between those points. Let me try it visually with a small set: -3 to 3 looks like this:

-3 -2 -1 0 1 2 3
|__|__|__|__|__|__|

As you can see there are 7 points (-3,-2,-1,0,1,2,3) but the width from -3 to 3 is 6 spaces (-3 to -2, -2 to -1, -1 to 0, 0 to 1, 1 to 2, 2 to 3).

If this is a bug, it's funny to think that almost every TGB camera ever used has been slightly distorted.
#7
12/14/2007 (7:46 am)
The width of 80 refers to the number of pixels not the distance between them.
#8
12/14/2007 (9:07 am)
@Chaim - But camera width isn't measured in pixels, it's measured in world units.
#9
12/14/2007 (2:53 pm)
I think everyone is missing the point. You set the width and height of the camera to X and Y, and they are actually set to X-1 and Y-1. This must be a mistake.
#10
12/14/2007 (5:04 pm)
@Phillip - I think the discussion here is whether the "width" is the _number of world points_ between the left and right (or top and bottom) boundaries, or the _amount of space_. To me, it seems clear that width should be a measure of space.

Dropping the numbers down to width 1 and height 1, centered on the origin, intuitively wouldn't the camera area go from point -0.5 to 0.5?