Blitz units?

Blitz3D Forums/Blitz3D Programming/Blitz units?

martonic(Posted 2004) [#1]
Hi! Many commands like "EntityRadius" etc. use so-called Blitz units, but what are they? For instance, I have a character mesh that is scaled up to fit into a scene. I would like to set pivots at her feet and head to intelligently manage collisions, but where are her feet and head? How can I find out the height of my character in "Blitz units"?


Koriolis(Posted 2004) [#2]
Keep in mind all is relative. A unit means nothing in itself.
But put a 20 units tall mesh in your scene, if your mesh is supposed to represent a house which is 10 meters in height, then you just have *decided* that 1 unit is 2 meters. You just have to be consistent with all your other meshes (a human character should in this case be around 3.6 units in height).


martonic(Posted 2004) [#3]
Thanks. I put an artificial object into the scene, next to my character, and found out that she is roughly 60 units tall.

I wonder if there is any programmatic way to determine the dimensions of the smallest bounding box to a given Blitz3d entity.


ZombieWoof(Posted 2004) [#4]
MeshWidth, MeshHeight, MeshDepth


Zethrax(Posted 2004) [#5]
The usual terms of reference used are 1 unit = 1 metric metre.

You also may need to factor in practicalities like default 3d sound parameters, default game texture UV coords as set by modelling programs, etc, which often use a metre as the unit value. You can change these, of course, but it makes your life simpler if you don't have to.


poopla(Posted 2004) [#6]
Can I give a bit of advice, which is to keep your game in much lower scale. If your character is 60 units tall, your going to run into floating point accuracy issues when you start moving it arround in a large arena.(At least you very well could.)


poopla(Posted 2004) [#7]
Sorry, double post.


Mustang(Posted 2004) [#8]
Yup, IMO character that's 60 units tall is too "big". I use 1 unit = 1 meter scale and this matches exactly what my lightwave spits out when I model everything there in real-world scale, using meters.


Koriolis(Posted 2004) [#9]
Can I give a bit of advice, which is to keep your game in much lower scale
Unless blitz does something very weird, I really don't see why. There is plenty of room for scaling without any precision loss, ie multiplying everything by 1000 would give you the exact same result (floats can handle numbers up to near 1e40). When i say everything, it includes the camera range.
If there is really some precision loss I'd be interested to see some sample exhibiting the problem, so that I can figure what's going on.

Anyway using 1 unit per meter is really a good advice, makes everything easier to manage.


Robert(Posted 2004) [#10]
If there is really some precision loss I'd be interested to see some sample exhibiting the problem, so that I can figure what's going on.


Watch what happens with terrain collision when you get too far away from the origin!


Koriolis(Posted 2004) [#11]
Maybe (...?), but what does too far away mean? Relatively to the terrain size (in which case the scaling doesn't matter at all), or in absolute value ?

Actually I see a very simple thing blitz might do (wrong) that would be a problem relatively to scaling: using a hard coded "epsilon" value. By example, in order to prevent floating point inaccuracy problems, to test if two values are "equal you'd do something like abs(a-b) < epsilon rather than just a = b. When scaling up a lot, the epsilon would become insignificant (if hard coded) and then it would become useless, and there comes back the floating point inaccuracy issue.
I wonder if it's the problem.


WolRon(Posted 2004) [#12]
I have no idea what you are talking about when you say "epsilon".


Koriolis(Posted 2004) [#13]
Simply a very little value constant, like 0.001. That's the common term, it comes from a long mathematics tradition (in mathematics it's actually a value we make tend to zero).


eBusiness(Posted 2004) [#14]
Koriolis is right, if you scale up the world you will get less exaction, but you will need equally less exaction, so no difference.


jhocking(Posted 2004) [#15]
"The usual terms of reference used are 1 unit = 1 metric metre."

Usually I use 1 unit = 1 foot. But obviously it all depends on your game; we're talking here about something set at a normal human scale like an average first-person shooter. If you're doing a god's eye view RTS game then the scale you decide on would be different.


Zethrax(Posted 2004) [#16]
You're using imperial measurement? How many number bases does that system have again? :-P


Rob Farley(Posted 2004) [#17]
I've noticed when you get to over 100,000 blitz units things start getting a touch wobbly!


(tu) ENAY(Posted 2004) [#18]
> things start getting a touch wobbly!

Like BAPS?


TomToad(Posted 2004) [#19]
a# = .01

For x = 1 To 83
a# = a# + .01
Next
Print a#

Repeat Until KeyDown(1)



The answer should be .84 but instead it's .83999999
the reason is the way computers store floating point numbers. Just like there are some fractions that can't be represented in base 10 decimal (like 1/3 would be .333333 repeated forever) there are some fractions the computer can't handle in base 2. The more you add, the more pronounce the inaccuracies become.

So if you move your character over a distance of 1000 units instead of 100 the inaccuracies become very noticable. Try replacing the 83 in the for next loop with 1000. The answer, which should be 10.01 is now 10.0101.


Zethrax(Posted 2004) [#20]
I've noticed when you get to over 100,000 blitz units things start getting a touch wobbly!


Yes, I've seen this with infinite planes. Get a decent distance from point zero and you can see the two tris that make up the plane moving relative to each other as you move around.


Koriolis(Posted 2004) [#21]
So if you move your character over a distance of 1000 units instead of 100 the inaccuracies become very noticable
In the case of a scale by ten, the inaccuracy would indeed be 10 times bigger (*if* it's really the case internally - the "epsilon" issue would be a contradiction to this), but everything being ten times bigger the relative inaccuracy is just the same. As long as you don't go too close to the maximum float value ( -> possibilies of overflow ) everything would then be fine.


Nik Green(Posted 2004) [#22]
Surely you would get LESS floating point errors if you scale things up.

For example, if you use 1000 blitz units to 1 metre you can place verts and move things around to millimetre accuracy using integer values (and integer maths).

Nik.


Zethrax(Posted 2004) [#23]
Surely you would get LESS floating point errors if you scale things up.


Obviously not!

If you scale things up, your world scale gets less detailed, and you get precision errors.

Try it and see.

Blitz doesn't use integer maths for this, so that part of your post is pointless.