Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rotating the view - D3DXMatrixRotation

201 views
Skip to first unread message

Norm Koger

unread,
Apr 12, 2001, 9:07:31 AM4/12/01
to
The D3DXMatrixRotation functions all rotate matrices relative to the
current axes of the matrix rather than world axes. Now in general,
this is fine. But yesterday I couldn't figure out how to rotate a
matrix around _world_ axes instead, and I need to do this.

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/

Norm Koger

unread,
Apr 12, 2001, 11:14:44 AM4/12/01
to
> The D3DXMatrixRotation functions all rotate matrices relative to the
>current axes of the matrix rather than world axes. Now in general,
>this is fine. But yesterday I couldn't figure out how to rotate a
>matrix around _world_ axes instead, and I need to do this.

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.

Norm Koger

unread,
Apr 12, 2001, 12:17:58 PM4/12/01
to
Never mind. I figured it out.

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.

Walter Knupe

unread,
Apr 12, 2001, 12:28:58 PM4/12/01
to
"Norm Koger" <nko...@austin.rr.com> schrieb im Newsbeitrag news:c9hbdt86se69qtbcl...@4ax.com...

> > The D3DXMatrixRotation functions all rotate matrices relative to the
> >current axes of the matrix rather than world axes. Now in general,
> >this is fine. But yesterday I couldn't figure out how to rotate a
> >matrix around _world_ axes instead, and I need to do this.
> 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.


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


0 new messages