Obtaining Yaw, Pitch, Roll and Player Coordinates from DirectX Games


New member

I've been googling for weeks and am at my wits end. I am trying to obtain Yaw, Pitch, Roll and Player X,Y,Z from DirectX games. I have all of my hooks in place and can obtain the the View matrix, etc.. from my .Net app.

I have managed to get Yaw, Pitch and Roll, but I get really weird spikes in what I thought should be the player positions. I want to use the change in positions to determine accelerations. Ultimately, all of this will be used in my DIY motion seat so that I can FEEL the game.

I suspect that I am not fully understanding these matrices and hopeful that someone can put me on the right path. I'm not asking for anyone to write it for me (although I would be willing to pay...PM me) I simply need some tips to put me back on track.

Here is the code in question:

             Me.Yaw = Math.Atan2(currentMatrixSet.ViewMatrix.M31, currentMatrixSet.ViewMatrix.M33)
                Me.Pitch = Math.Atan2(-currentMatrixSet.ViewMatrix.M32, Math.Sqrt(currentMatrixSet.ViewMatrix.M33 * currentMatrixSet.ViewMatrix.M33 + currentMatrixSet.ViewMatrix.M31 * currentMatrixSet.ViewMatrix.M31))
                Me.Roll = Math.Atan2(currentMatrixSet.ViewMatrix.M12, currentMatrixSet.ViewMatrix.M22)

                Dim inverseView As SlimDX.Matrix = SlimDX.Matrix.Invert(currentMatrixSet.ViewMatrix)

                Me.PositionX = inverseView.M41
                Me.PositionY = inverseView.M42
                Me.PositionZ = inverseView.M43

When I chart the position data in a racing game, the positions are all over the pace even when driving in a straight line. They simply can't be correct as I have them, but as I read the docs, this should be right.