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.

Using Blender 2.6. My model has its location and rotation zeroed out, scale set at 1.0, and generally conforms to every guideline detailed on this site and misc google results. When exporting it, I check 'XNA Strict Options'. Y up and -Z forward seems right.

However, it still ends up sideways. I found that a possible fix was to just set the X Axis Rotation in the Content Processor properties to -90, but that ended up being worthless when I started checking out collision spheres and realized that they lay in that skewed orientation.

What could I be missing?

Edit: Drawing code:

Matrix[] bones = animPlayer.GetSkinTransforms();
foreach (ModelMesh mesh in model.Meshes)
{
    foreach (SkinnedEffect fx in mesh.Effects)
    {
        fx.SetBoneTransforms(bones);
        fx.View = camera.viewMatrix;
        fx.Projection = camera.projectionMatrix;
        fx.EnableDefaultLighting();
        fx.World = worldMatrix;
    }
    mesh.Draw();
}

Where

worldMatrix = rotMatrix * moveMatrix;
camera.viewMatrix = Matrix.CreateLookAt(camPosition, target+camTargetOffset, camUp);
camera.projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)game.Window.ClientBounds.Width / (float)game.Window.ClientBounds.Height, 1, 100);
share|improve this question
    
can you post your drawing code? –  Vodáček Feb 24 '13 at 7:49

2 Answers 2

up vote 0 down vote accepted

I also used that blog link for reference on importing models. I had a similar problem with importing animated models for this reason.

Some models came out sideways in the game, they will animate properly but turned sideways. For instance the Dude model would appear correct using the default import setting for the pipeline, but then I made a custom animation in Blender from a mesh I downloaded elsewhere and on export was turned 90 degrees to one side. Applying rotation in Blender's export settings didn't work either because the bones will be misaligned and animations will look all wrong.

I managed to solve the problem by making a modification to the content importer and applying the custom rotation during that step. That part of the article with the RotateAll function, I made the parameters editable in the Properties window.

The code isn't much, here's what I added to the model prep code in the model processor class:

    [DisplayName("Mesh animation rotation")]
    [Description("Rotates 3D models while they are loaded, including rotating their animations.")]
    public Vector3 NodeRotation
    {
        get { return nodeRotation; }
        set { nodeRotation = value; }
    }
    private Vector3 nodeRotation;

This makes the NodeRotation editable in the Properties window, so now you can set the rotation (in degrees) on a per-model basis.

share|improve this answer
    
Thank you so much! I'm not too clear on the math behind setting RotationX in the properties versus setting it there using this, but it worked out perfectly. Would upvote if I could. –  idlackage Feb 25 '13 at 21:29

if you right click your model in the solution explorer and choose 'Properties', then in the properties section, expand content processor, then set -90 in the x axis rotation field, it will apply the rotation to all vertices and transforms during build so all the bounding spheres will line up.

share|improve this answer
    
I mentioned in the second paragraph that this is exactly what I did, but the bounding spheres stay non-rotated. –  idlackage Feb 25 '13 at 3:28

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.