|
|
|
date: Sun, 29 Jun 2008 15:05:25 -0700 (PDT),
group: microsoft.public.win32.programmer.directx.graphics
back
Rotation of an object shrinks it...
Hi,
I'm basically making a 2D engine, I've started with DirectX few months
ago, so I'm still learning alot of stuff while working with it...I
mean, don't get angry with my questions xD
My situation - I'm using orthogonal projection in my application, it's
set with this code:
D3DXMatrixOrthoLH(&m_matProj, width, height, 0.2f, 20.0f);
, where width and height are those from my window's size. When I
rotate an object 90 degrees, it kinda shrinks it's width with visibly
20-30%, I can't tell exactly how much and what is causing it, I know I
see it. I'm not an expert in math, but I think I correctly ordered the
calculation of the scaling, rotation and translation matrixes, as I
somewhere read it should be S-R-T. So I'm just guessing it's not that
code that causes this problem, I must be missing something. This is my
code that's calculates the world matrix for every object:
float fOffX, fOffY, fScaleX, fScaleY;
fScaleX = (float)m_nObjectWidth /m_nScreenWidth;
fScaleY = (float)m_nObjectHeight / m_nScreenHeight;
fOffX = ( 0 + (float) m_nObjectPosLeft / m_nScreenWidth ) - 0.5;
fOffY = ( 0 - (float) m_nObjectPosTop / m_nScreenHeight ) + 0.5;
D3DXMatrixTranslation(&m_PositionMatrix, fOffX, fOffY, 1);
D3DXMatrixScaling(&m_ScalingMatrix, fScaleX, fScaleY, 0); // scale
the quad with same aspect ratio
// rotation
D3DXMatrixRotationYawPitchRoll(&m_RotateMatrix, m_fObjectRotationX,
m_fObjectRotationY, m_fObjectRotationZ);
m_WorldMatrix = m_ScalingMatrix * m_RotateMatrix * m_PositionMatrix;
I hope someone knows why do I get shrinking when rotating.
Thanks,
Pencheff
date: Sun, 29 Jun 2008 15:05:25 -0700 (PDT)
author: Pencheff
|
|