I am making a game with some friends. At the moment, we are trying to get the controls working as they should, i.e. WASD to move in the 4 main directions, and use the mouse to rotate the view.
The problem is that we are running into difficulties with the matrices, specifically the view matrix. I have read more tutorials than I care to count on matrices over the past few weeks, and I understand the basic principles, and how to do some simple stuff, but I am still lacking that fundamental understanding of how it all comes together.
Right now, our main problem is getting the camera transformations to act as one would expect. Using the tutorials I have seen, the camera transformations all take place along the local axis, which causes some strange behavior, for instance, after moving around a bit, I can easily end up sideways, or even up-side-down.
These are the two functions I am using for rotating the view matrix, as seen in all the tutorials i've looked at:
def xrotate(M,theta):
t = math.pi*theta/180
cosT = math.cos( t )
sinT = math.sin( t )
R = numpy.array(
[[ 1.0, 0.0, 0.0, 0.0 ],
[ 0.0, cosT,-sinT, 0.0 ],
[ 0.0, sinT, cosT, 0.0 ],
[ 0.0, 0.0, 0.0, 1.0 ]], dtype=np.float32)
M[...] = np.dot(M,R)
def yrotate(M,theta):
t = math.pi*theta/180
cosT = math.cos( t )
sinT = math.sin( t )
R = numpy.array(
[[ cosT, 0.0, sinT, 0.0 ],
[ 0.0, 1.0, 0.0, 0.0 ],
[-sinT, 0.0, cosT, 0.0 ],
[ 0.0, 0.0, 0.0, 1.0 ]], dtype=np.float32)
M[...] = np.dot(M,R)
How would I go about applying view matrix transformations in global space?
Oh, and also, if you know of any really good matrix tutorials that don't just say 'the math here is complicated so we won't go into it, just know it works', I would love to take a look.