DirectX7 Rotations
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]
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
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)
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement