Lets say we initialize the view looking out so that our view vector
is not aligned to the world z axis. In my experiments yesterday, I
pointed the view slightly "down" (rotated clockwise around the world x
axis) but with my view vector still on the world YZ plane. Then I used
the following to "pan" the camera.
rotation_matrix=camera_matrix;//permanent view matrix
D3DXMatrixRotationY(&rotation_matrix,angle);//build a matrix to
rotate around the y axis
D3DXMatrixMultiply(&camera_matrix,&camera_matrix,&rotation_matrix);//apply
the rotation to the permanent matrix
d3dDevice->SetTransform(D3DTS_VIEW,&camera_matrix);//make the
rotation effective
This rotates the view around its current Y axis rather than the
world Y axis. So if our current view Y axis isn't aligned to the world
Y axis, we also get an unwanted (in my case) rotation relative to the
world Z axis as well - a roll.
I figure the answer might lie in using D3DXMatrixRotationAxis rather
than D3DXMatrixRotationY, specifying the world Y axis as a rotation
axis in terms relative to the current view Y axis. This is where I'm
stumped. If I could just get the vectors specifying the current
orientation of the view it would be easy. But I don't see how to get
them. This is such an obviously useful thing I know there must be a
way to get the orientation vectors. How do you do it?
Regards,
Norm Koger
Software Developer
http://home.austin.rr.com/normkoger/
What I'd like to see is a set of higher level rotation functions
that look like this...
D3DXMatrixRotationWorldAxis
D3DXMatrixRotationWorldX
D3DXMatrixRotationWorldY
D3DXMatrixRotationWorldZ
...which would work in a manner identical to the provided rotation
matrix builders, but would build the matrices in reference to _world_
axes rather than local axes.
The DirectX8 Docs _do_ have a good description of the view matrix
(article titled "What is the View Transformation?"). All you need to
do to build a rotation matrix for the view around the world Y axis is
to...
1) create an axial vector from the view matrix _12,_22,_32 elements.
2) use D3DXMatrixRotationAxis with your new axial vector as the axis.
...and voila, you get a rotation matrix relative to the world Y axis.
Norm is a happy boy.
I fail to see your point. What is "current" ? or what is "local" ?
The function DX3DXMatrixRotation functions rotate around X,Y,Z axis or given vector as axis.
These X,Y,Z or vectors are "object space" when applied before the world matrix, they are "world space" if applied afterwards, and
they are any other desired space if combined with appended or prefixed matrixes that provide the way there.
Walter Knupe