Which Units?

Hi all,

I have some trouble with the constructor for a Box

public Box(String name, Vector3f center, float xExtent, float yExtent, float zExtent)

if i set values for the x, y, and z, which units are these values? pixels? or centimeters? or what??

i read already in this forum, that units are just units, and the programm has to define the context. but if for example i use 1024x800 resolution is it possible to predict the real distance for 5 units??

hope someone can help. thx

In the usual "perspective" mode, units are just units… how large something appears on screen will depend on the camera settings, despite your resolution. So what really matters is that you are consistent: for example if you create a 10x10x10 box, then your camera should be around 50-100 units away from the box for it to fit completely in your screen (this however also depends on other camera settings).

If you are drawing in "ortho" mode, the screen is just 1x1 big. So a 0.5x0.5 box will occupy half of the screen. If you know your resolution is 1024 wide, then one pixel is 1/1024 units. However coding like this would make your application resolution-dependant, so always consider this when using constants or even functions that depend on actual screen resolution.

Been wondering a bit about this unit “problem”. It would be nice to work a known dimension scale, in my part of the world that is meters and centimeters. So I would like to model stuff where for example 1 unit = 1m. But for this to work 1:1 into the game world I guess the camera would have to be adjusted to get a correct “look” on the world. Especially with physics in mind where e.g. your player “capsule” needs to be of some height in which the camera is on the top of this capsule. Atm I feel my character is a bit of a midget from a viewpoint perspective so I either had to resize all my assets in the game or make my player capsule higher, although that doesnt necesessary make my camera fov correct. A bit confused at this… what scale do you work on? Or are you just sizing stuff until it “feels right” in proportion?

Visually you can work on any scale you like, it will be depending on the camera location and the models size relations how “big” the things look. For physics, the default units are 1 unit = 1 meter so there you should use that or adapt the gravity / mass accordingly.