Units in OpenGL and/or Direct3D

Started by
5 comments, last by Jimmy Valavanis 19 years, 6 months ago
Hi, I was just wondering if there are any representation or meaning to the units used in OpenGL and Direct3D. I mean, if I give a length of 1.0f to one of my vectors, is it 1 foot, 1 meter, 1 undefined unit? Does it work the same in OpenGL and in Direct3D? thanks
ThunderMusic
Advertisement
The units are completely arbitrary. You can make them be whatever you want depending on what sort of game you're writing.
It means whatever you want. Just make sure everything else is relative to that unit, whatever you decide it should "mean".
Ok, so if I want it to be inches, the perspective will adjust the same as if I want it to be feet or meters (with the proper unit convertion, naturally)?

thanks a lot
ThunderMusic
Generally when rendering a 2D game one unit corresponds to one pixel. However, in 3D it makes little difference as the size a thing appears on screen depends on how close the thing is to the camera.
The size of one unit is up to you. It could represent a centimetre, and inch, a metre or 1000 kilometres (galaxy simulators etc). Chose a measurement and then try to build your models to the correct proportion.

Hope this helps,
Jackson Allan
Excellent! Thanks a lot!!
ThunderMusic
Of cource you can choose what you want to mean the value 1.0f:

a meter, a cm, a km, etc.

but keep in mind than in my experience in Direct 3D
if you use very small values (I mean for example 1.0f = 1 meter and have a model of a coin) that some rendering errors may be noticed. (if your 3D engine let's say render the coin from a "near" clipping plane).

Just consider that near-clipping-plane in Direct3D is the item [4, 4] of the VIEW_MATRIX, if you have a small value to this some rendering errors occurs in distant scenery (looks like
z-Buffering does not work well). But if you want to "view" with
your 3d engine from a close distance small objects like
a coin etc you sould give to the item [4,4] a small
value.

This topic is closed to new replies.

Advertisement