XNA model drawing problem

Posted by user1990950 on Game Development See other posts from Game Development or by user1990950
Published on 2013-06-28T14:53:54Z Indexed on 2013/06/28 16:31 UTC
Read the original article Hit count: 266

Filed under:

When using this code:

public static void DrawModel(Model model, Vector3 position, Vector3 offset, float xRotation, float yRotation, float zRotation, float allrot, float xScale, float yScale, float zScale)
    {
        position.Y *= -1;
        offset.Y *= -1;
        Matrix worldMatrix = ((Matrix.CreateRotationZ(MathHelper.ToRadians(zRotation)) * Matrix.CreateRotationX(MathHelper.ToRadians(xRotation))) * Matrix.CreateRotationY(MathHelper.ToRadians(yRotation))) * (Matrix.CreateTranslation(offset) * Matrix.CreateRotationY(MathHelper.ToRadians(allrot))) * Matrix.CreateScale(xScale, yScale, zScale);

        worldMatrix *= Matrix.CreateTranslation(position) * theCamera.GetTransformation() * Matrix.CreateTranslation(new Vector3(-(graphics.GraphicsDevice.Viewport.Width / 2), graphics.GraphicsDevice.Viewport.Height / 2, 0));
        foreach (ModelMesh mesh in model.Meshes)
        {
            for (int i = 0; i < mesh.Effects.Count; i++)
            {
                    ((BasicEffect)mesh.Effects[i]).EnableDefaultLighting();
                    ((BasicEffect)mesh.Effects[i]).World = worldMatrix;
                    ((BasicEffect)mesh.Effects[i]).View = viewMatrix;
                    ((BasicEffect)mesh.Effects[i]).Projection = projectionMatrix;
            }
            mesh.Draw();
        }
    }

The model rotates and then scales. It should scale and then rotate, but whenever I try to change it, it won't work.

© Game Development or respective owner

Related posts about xna-4.0