Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

When exporting a model from 3ds Max as FBX to import it into XNA, what metrics should I choose to make 1 unit in 3ds Max equal to 1 unit in XNA?

For example: I have a sphere model with 1m radius exported to XNA. When drawing I use:

Matrix[] transforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in model.Meshes)
{
    foreach (BasicEffect be in mesh.Effects)
    {
        be.EnableDefaultLighting();
        be.World = mesh.ParentBone.Transform * Matrix.CreateScale(radius)
                    * TransformMatrix;
        be.View = camera.view;
        be.Projection = camera.projection;
    }
    mesh.Draw();
}

Radius is defined in my class as float.

This will draw a ball smaller than 1.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

There isn't really a one-size-fits-all solution for this. You can make 1 unit in XNA equal to 1 metre, or 1 kilometre if you'd like. What I'd recommend is you find a transform and stick with it. Start with exporting a 1m sphere into XNA, adjust the scale and/or camera until it looks right, then base everything off that scale.

share|improve this answer
    
but this way is not accurate ? is there any default size ? –  MhdSyrwan Jan 13 '12 at 0:52
1  
Modeling units have nothing to do with real world quantities like meters, yards or pixels. At the beginning of every real world project a convention is chosen, let's say that 1 "unit" is equivalent to 1 "centimeter." Everyone works with that decision in mind from that point forwards. There is no default "size" because size makes no sense except in this convention chosen at the beginning of the project. <edit> To clarify, this convention is made simply so people can talk about models in people-friendly terms, no other reason. –  Patrick Hughes Jan 13 '12 at 1:23
3  
Size is relative thus the only two things you need worry about is that: 1) all the models are correctly sized relative to each other and... 2) that the camera setup is proportioned correctly relative to the size of the models to give the look you're after. Unless you're projecting to a specific display in an attempt to display in real world sizes, accuracy is what you make it. –  lzcd Jan 13 '12 at 1:25
1  
Unless you're playing tricks with your models the scale will always be 1.0. –  Patrick Hughes Jan 13 '12 at 5:04
1  
I wouldn't expect them to; there really isn't any correlation between 3ds units and XNA units. –  DMan Jan 13 '12 at 15:42

Not withstanding what Dman is conveying, since you are not following through fully with your matrix[] transforms, there may (or may not) be scaling information inside them that you are not taking into account when setting your be.World.

Use transforms[mesh.parentBone.index] instead of mesh.parentBone.Transform

share|improve this answer
    
they are the same ! what is the difference ? –  MhdSyrwan Jan 13 '12 at 14:31
1  
Possibly in your case, but not always. transforms[mesh.pb.i] will take into account all transforms above it in the hierarchy scheme. mesh.pb.t is the local transform only and isn't affected by upper level transforms. But if there is no bone hierarchy, then yes, they are the same which is the reason I added: "may (or may not)". So when you call the method CopyAbsoluteTransformsTo, it takes each m.pb.t and multiplies it to all transforms above it in the hierarchy chain and returns the result. If there were scaling info in the bone transforms above the m.pb.t, you would have missed it. –  Steve H Jan 13 '12 at 14:51
    
You only have a sphere, and there isn't really a hierarchy of bones in a sphere alone. –  DMan Jan 13 '12 at 15:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.