Jump to content
• Advertisement

# DirectX7 Rotations

This topic is 4951 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

I'm trying to rotate an object around both X, Y, and Z axis, but it's not working. intead it's only rotating around the last axis rotation requested. For example: ' I want to rotate on the Z and X axis so I... vTemp.Z = 0 vTemp.Y = 0 vTemp.X = -20 ' Rotate on Z axis DX.RotateZMatrix MatrixCube1, Angle.Z * Rad TranslateMatrix MatrixTemp, vTemp DX.MatrixMultiply MatrixCube1, MatrixCube1, MatrixTemp ' Now rotate on X axis DX.RotateXMatrix MatrixCube1, Angle.X * Rad TranslateMatrix MatrixTemp, vTemp DX.MatrixMultiply MatrixCube1, MatrixCube1, MatrixTemp DX.RotateXMatrix came last and so it's the only rotation observed, anything done before the last rotation command is completly tossed out. What am i doing wrong? [Edited by - Waxy on April 25, 2005 11:10:38 PM]

Advertisement
matCube1?

#### Share this post

##### Share on other sites
Typo in the message

#### Share this post

##### Share on other sites
Could be gimbal lock. Look into quaternions for rotation.

#### Share this post

##### Share on other sites
What if you do it this way:

 vTemp.Z = 0 vTemp.Y = 0 vTemp.X = -20' Rotate on Z axis            DX.RotateZMatrix MatrixCube1, Angle.Z * Rad' Now rotate on X axis            DX.RotateXMatrix MatrixCube1, Angle.X * Rad            TranslateMatrix MatrixTemp, vTemp            DX.MatrixMultiply MatrixCube1, MatrixTemp, MatrixCube1//note matrix order

#### Share this post

##### Share on other sites
I figured it out.
Above, MatrixTemp is the view matrix. but i've renamed it MatrixView for
refrence sake. Now i create a temporary matrix - (MatrixTemp)

Each time i change Matrix Cube1 i store it in Matrix Cube 2 -
execept for the first time, where i also include the viewing matrix
(I haven't tried this yet with a free camera)

        Clear_Device        Device.BeginScene            DX.MatrixMultiply MatrixCube1, Angle.X * Rad            DX.MatrixMultiply matrixTemp, MatrixCube1, MatrixView            DX.RotateZMatrix MatrixCube1, Angle.Y * Rad            DX.MatrixMultiply MatrixTemp, MatrixTemp, MatrixCube1            DX.RotateYMatrix MatrixCube1, Angle.Z * Rad            DX.MatrixMultiply MatrixTemp, MatrixTemp, MatrixCube1            Device.SetTransform D3DTRANSFORMSTATE_WORLD, MatrixTemp            Call Device.DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, pyramid2(0), 6, D3DDP_DEFAULT)            Call Device.DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, base2(0), 4, D3DDP_DEFAULT)         Device.EndScene

For I = 1 to ubound(MatrixCube())

Now i need to figure out how to clear a matrix so that I can loop it -
to draw MatrixCube(I) to allow multiple objects in an array w/o having to have
multiple MatrixTemp's.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011313
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!