Torque Units
by rennie moffat · in Torque Game Builder · 07/20/2009 (7:45 am) · 12 replies
What are the default measuring units of Torque?
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
even in 2D?
One thing I noticed tho in my conversions, and maybe my math is rusty, but 480x320 (iPhone Pixels) does not equate in ratio to 100x75 (torque units)
:?
07/20/2009 (9:46 am)
wow,even in 2D?
One thing I noticed tho in my conversions, and maybe my math is rusty, but 480x320 (iPhone Pixels) does not equate in ratio to 100x75 (torque units)
:?
#5
for example, the default resolution of TGB is 100x75 (800x600), so, 1 TUnit = 8 pixels in that default configuration... the rest, well, do the math.
07/20/2009 (1:59 pm)
the regular torque (TGB) measurements are in TUnits. and it all depends on the design resolution.for example, the default resolution of TGB is 100x75 (800x600), so, 1 TUnit = 8 pixels in that default configuration... the rest, well, do the math.
#6
07/20/2009 (2:07 pm)
yah i did but as stated, before, it just seems a little off. tho it is safe to say 1 TUnit is 1 Meter even in 2D?
#7
For example, your main character is ~1.75 meters tall and is represented by a 32 pixel tall sprite.
Set your target resolution in the preferences of TGB (I'll use 1280x720 in this example). This will set the target resolution of your viewport in pixels. Now, in the scene editor, you specify the size of the viewport in torque units (how many units you want the viewport/camera to display). If a 32 pixel tall sprite equates to approximately a 1.75m tall man, then 1 meter would be approximately 18 pixels (rounding a bit - depends on how exact you need it). So, you want 1 Torque unit = 18 pixels = 1 meter (the scale of your graphics at the default resolution). This means you divide your target resolution by 18 pixels (1280/18 x 720/18) to find the number of meters/torque units to dispay and set the viewport in the scene to ~71.1x40. This means that your default 1280x720 pixel viewport will show 71.1x40 torque units(meters), making each torque unit(meter) 18x18 pixels, making your 32 pixel man 1.75 meters. If all of your graphics are to same scale then you are set. 1 Torque unit = 1 meter.
When your game window changes size, everything will be scaled by the engine. If it's re-sized to 640x360, even though your sprite will be smaller in pixels, it will still be 1 torque unit (meter) tall because 1 torque unit will then be fewer pixels than before.
The meter aspect is really meaningless to the game engine. It's really just a way to make things easier for you. The engine won't know what meters are since it uses torque units. In fact you can equate a torque unit to 1 yard, 1 cm, 1 mile, whatever you want as the scale of the game. That equivalence is just for you alone.
It's really nice that the game abstracts units for you. It allows you to (after the initial configuration) place all of your objects in the games space according to your own measurements (in your case meters) without having to convert to/from pixels more than once. If your artists tell you that the assets were created of a scale of x pixels = 1 meter then you can easily adjust accordingly.
Heck, if you made a space game, if you want 1 pixel to be 1 million miles, then you could set up your resolution, divide the x and y size by 99 and make 1 torque unit = 1 astronomical unit (~99 million miles). Of course as resolution changes 1 pixel won't equal 1 million miles, but all of your graphics will still be to the same scale and you can use the X and Y coordinates to place your objects in your game based on the number of Astronomical Units in the X and Y planes.
I know it doesn't sound too easy at first, but once you wrap your mind around it then it becomes really, really simple.
Ultimately, if your graphics are already done and you know their scale, then you set the torque units up according to that scale (like I mentioned).
07/20/2009 (7:54 pm)
It's entirely arbitrary. It took me a while to wrap my mind around it. You can make a torque unit however big or small you want.For example, your main character is ~1.75 meters tall and is represented by a 32 pixel tall sprite.
Set your target resolution in the preferences of TGB (I'll use 1280x720 in this example). This will set the target resolution of your viewport in pixels. Now, in the scene editor, you specify the size of the viewport in torque units (how many units you want the viewport/camera to display). If a 32 pixel tall sprite equates to approximately a 1.75m tall man, then 1 meter would be approximately 18 pixels (rounding a bit - depends on how exact you need it). So, you want 1 Torque unit = 18 pixels = 1 meter (the scale of your graphics at the default resolution). This means you divide your target resolution by 18 pixels (1280/18 x 720/18) to find the number of meters/torque units to dispay and set the viewport in the scene to ~71.1x40. This means that your default 1280x720 pixel viewport will show 71.1x40 torque units(meters), making each torque unit(meter) 18x18 pixels, making your 32 pixel man 1.75 meters. If all of your graphics are to same scale then you are set. 1 Torque unit = 1 meter.
When your game window changes size, everything will be scaled by the engine. If it's re-sized to 640x360, even though your sprite will be smaller in pixels, it will still be 1 torque unit (meter) tall because 1 torque unit will then be fewer pixels than before.
The meter aspect is really meaningless to the game engine. It's really just a way to make things easier for you. The engine won't know what meters are since it uses torque units. In fact you can equate a torque unit to 1 yard, 1 cm, 1 mile, whatever you want as the scale of the game. That equivalence is just for you alone.
It's really nice that the game abstracts units for you. It allows you to (after the initial configuration) place all of your objects in the games space according to your own measurements (in your case meters) without having to convert to/from pixels more than once. If your artists tell you that the assets were created of a scale of x pixels = 1 meter then you can easily adjust accordingly.
Heck, if you made a space game, if you want 1 pixel to be 1 million miles, then you could set up your resolution, divide the x and y size by 99 and make 1 torque unit = 1 astronomical unit (~99 million miles). Of course as resolution changes 1 pixel won't equal 1 million miles, but all of your graphics will still be to the same scale and you can use the X and Y coordinates to place your objects in your game based on the number of Astronomical Units in the X and Y planes.
I know it doesn't sound too easy at first, but once you wrap your mind around it then it becomes really, really simple.
Ultimately, if your graphics are already done and you know their scale, then you set the torque units up according to that scale (like I mentioned).
#8
07/20/2009 (8:07 pm)
If you have a specific example, then maybe we can help you figure it out. For example if your game is based on a side-scrolling character, how many pixels is the graphic for your character and how tall is he supposed to be? If your game is a shooter, how many pixels is your ship/vehicle and how long is it supposed to be (in meters). Then tell us your target screen resolution and we can just plug in the numbers to get you a good 1 torque unit = 1 meter. Remember, though, that the 1 meter part is really just for you as the game doesn't know what a meter is. It will however make entering velocities, distances, etc simpler for you since you can enter them for a 1-to-1 as meters.
#9
It's not so much that I have a specific example, beyond the default iPhone dimensions. The reason I was asking was because I was trying to design things, elements in Illustrator and I couldn't figure out a "pitch perfect" translation.
07/20/2009 (8:31 pm)
Thanks Kevin,It's not so much that I have a specific example, beyond the default iPhone dimensions. The reason I was asking was because I was trying to design things, elements in Illustrator and I couldn't figure out a "pitch perfect" translation.
#10
To make it easier to create games on the iPhone, I set the Camera's Width and Height equal to the Design Resolution's X and Y (1 Pixel per Torque Unit).
08/13/2009 (3:56 pm)
Heh, I do not like how iTGB defaults the iPhone Camera landscape and portrait size to 75 x 100 (or 100 x 75) Torque Units mainly because it is a 3:4 ratio, where the iPhone resolution is a 2:3 ratio of 320 x 480 (or 480 x 320) pixels.To make it easier to create games on the iPhone, I set the Camera's Width and Height equal to the Design Resolution's X and Y (1 Pixel per Torque Unit).
#12
the way torque is right now, works for me, since when you do somehting particular with a sprite, it doesnt really matter what resolution you are in, it will work just fine... when you work on a per pixel system, unless you know whatyou're doing, something can go wrong.
08/14/2009 (6:40 am)
superb?... i dont think so, it all depends on what are you doing and how you needit done.the way torque is right now, works for me, since when you do somehting particular with a sprite, it doesnt really matter what resolution you are in, it will work just fine... when you work on a per pixel system, unless you know whatyou're doing, something can go wrong.
Torque Owner Shaderman
1 Torque unit should be 1 Meter.