Jump to content
  • Advertisement
Sign in to follow this  
Waxy

DirectX7 Rotations

This topic is 4776 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]

Share this post


Link to post
Share on other sites
Advertisement
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


Link to 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


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!