Sign in to follow this  

Unusual Scaling Problem in XNA (C#)

Recommended Posts


I have a very simple model of a table that is a diameter of 2 units. When I render the model in my XNA (C#) application, everything looks great. However when I scale x/z by 2, it looks like it is scaling larger than a magnitude of 2. Attached are two pictures (unscaled and scaled). I have drawn a plane down the center of the table and two plans 2 units apart in the unscaled, and then 4 units apart in the scaled.

The code below is how I create my world matrix for the mesh:

// the world position gets cached on processing of the scene node in the center of the bounding volume
Vector3 vWorldPosition = m_BoundingVolume.Center;

Matrix mTranslation;
Matrix mScale;
Matrix mRotation;

Vector3 m_vScale = new Vector3(2.0f, 1.0f, 2.0f);

Matrix.CreateTranslation(vWorldPosition.X, vWorldPosition.Y, vWorldPosition.Z, out mTranslation);
Matrix.CreateFromQuaternion(ref m_qOrientation, out mRotation);
Matrix.CreateScale(ref m_vScale, out mScale);

m_mCachedWorldMatrix = mScale * mRotation * mTranslation;

As you can see the code is very simple, so I am not sure where I am going wrong. Can any one suggest any ideas, or even any ideas of a way to debug this, I have exhausted all avenues I can think of.

Thank you!!

Share this post

Link to post
Share on other sites
You can certainly debug the vertex shader with PIX, which is probably where I'd start. Check the world space vertex position and see if it's what you'd expect, and also see if the matrix is what you expect.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this