I have created a test 3d-map (X-format) and this maps materials and textures is loaded onto a sceneMesh. Then I move around adding/subtracting values to three floats: x, y and x in the following code:
device.Transform.View = Matrix.LookAtLH(new Vector3(0,0, z+10.0f), new Vector3(x,y,z), new Vector3(0,1,0)); |
When you press Left 1 is added to x and Right subtracts 1 from x. Up subtracts 2 from z and Down adds 2 to z. This works well to move the camera forward, backwards and you can "turn your head" to the left and right.
Here's the problem: You can only turn approx. 90 degrees to the left and the right. It isn't possible spinning around and you can only move forward and backwards along the Z-axis.
The Question: How can I make a more game-like movement By which I mean to move forward and backwards the direction the cameras looking-vector is facing and be able to spin 360 degrees around. I've tried using some Y-axis rotation but it didn't give the wanted effect.
Any help is good help - Thank up
// SirErugor

Moving around in my 3d map..?
Martin Kulov - MVP
Failing that you might as well get acquainted with your vector mathematics and linear algebra - unfortunately this isn't DirectX-specific and more of a general graphics/mathematics problem.
One possibility (that I've used a few times) is Spherical Coordinates - you can specify your rotations in terms of angles and then convert them back to cartesian coordinates for the Matrix.LookAtLH() function. Using angles tends to make rotations a whole lot simpler
hth
Jack
Mr. SpiXener
Thanks for the reply. You're right on the cameras that's what I'm using at the moment.
And also, I should study my vector-math again. I think the trick must be to handle the Initial Vector and Look-at Vector, so that while moving the look-at the initial follows Making it possible to move.
Spherical Coordinates - I'm gonna ask my math-teacher on the topic to get some help. I must admit I don't know how to use it, as of now that is.
But thank you very much!
Regards, SirErugor