Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectX 1mm equaivalent

Started by dehseth Feb 28, 2009 at 10:38 AM 10 replies 1.8k views
Original Post
dehseth
dehseth
Hey ppl, I have chess table object which is build in Maya and exported as X file. The table squares sides are 100mm long. So when I am using D3DXMatrixTranslation what should I give to make a movement 1mm? Should I use 1.0f to make a 1mm movement? I hope my question is clear.. Thank you in advance.
MCA
Imgelling
Imgelling
Depends on the coordinates of the corners.

Subtract the coordinates of 2 corners to find the length of the model. Divide the result by 100. That should give you the coordinate resolution of 1mm. Then you can translate by that number.
my blog contains ramblings and what I am up to programming wise.
dehseth
dehseth
I assume when you say "subtract the two corners of model" you mean in directX. But the model is, as I mentioned a chess table, is one model. So I do not have one square piece. And chess table has a border outside. So it seems not possible to calculate 1mm length in directX.

I guess it is do with the screen resolution. There should be a way to make a calculation using viewport and screen resolution parameters..
MCA
Imgelling
Imgelling
Chess table, sorry, I was thinking of a chess board. My mistake.

But as far as I know, the viewport and screen resolution won't help you much. Direct X's coordinate system is abstract. It doesn't map to anything. I mean, 1.0f != 1ft and 1.0f != 1km. You as the programmer need to choose what 1.0f means. Then everything else is scaled to that measurement.

Your gonna have to find the coordinates of the table squares since that is what you know the measurement for.

Sorry I was not very helpful. Hopefully someone will come along soon to aid you more.


my blog contains ramblings and what I am up to programming wise.
dehseth
dehseth
thanks anyway..

so anybody knows about this topic?
MCA
Dunge
Dunge
As Imgelling said, the unit in DirectX is dependent of what you choose to do with it. Some game could have a whole football terrain in 1.0f DirectX unit, while another 1.0f would equal the size of water drop.

What you want to know is the size of the model in Maya. Maya have a tool to measure, use it and find the length you desire to know. When exporting/importing in your game, if you don't use scaling anywhere, it should stay the same.
programci_84
programci_84
Hi,

Quote:
Subtract the coordinates of 2 corners to find the length of the model.


If it's a chess table -not a chess board-, you can calculate a bounding box for it. D3DXComputeBoundingBox() does it for you. And you can find height and/or width of your model by using corner coordinates of bounding box.

Quote:
The unit in DirectX is dependent of what you choose to do with it.

That's absolutely true. We say "unit", in other words, you can substitute any other length units (e.g. meter, kilometer, inch etc.) for it. For instance, in Doom III game, a man's height is approximately 16-20 DirectX units.
There's no "hard", and "the impossible" takes just a little time.
adriano_usp
adriano_usp
No secret. If your exporter didn't scale the model, 100mm in the Maya will be 100 units in DirectX. So, in this case, a translation by 1.0f (one unit) would correspond to 1mm (in the world or view space). Just make sure your exporter preserves the measures of the model.
GMano
GMano
In the past, I have used models provided to me by an artist using Maya and they were in units of centimeters. You may be able to set Maya up to use different units (I would think you could), but I am guessing cm is the default.
dehseth
dehseth
Yeap thank you guys.. I used 1.0f as 1mm as you mentioned. And it worked out fine.

So I guess we can assume 1.0f = 1mm deafult. If there's no scaling factors..

Thanks again.
MCA
sebbit
sebbit
Quote:

So I guess we can assume 1.0f = 1mm deafult. If there's no scaling factors..


Thats wrong! As has already been said, the meaning of 1 unit depends on what you want it to be. If you use a model thats 100 units wide say that this should be 100mm THAN 1 unit corresponds to 1mm in the world. But you could just as well load a 100x100 pixel heightmap and define, that one heightmap cell is 1m wide. Than 1 unit would be 1m.
dehseth
dehseth
So; 1.0f = 1mm because in Maya the model is created using 1mm unit. That why when I move object in dx 1.0f it moves 1mm...

I think I get it.. If I didn't I will eventually :)
MCA

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.