3d bullet motion?
OK, I've gotten as far as wireframe modeling with this tutorial, and now I want to turn it into a game. The problem is that I'm a little new to this whole matrix thing and I'm not really sure how to make a bullet move in a certain direction. If I was doing it in 2d I would do something like this:
but I'm not really sure how to do something like that in 3d. Does anyone know how I can adapt this matrix stuff for motion?
bullet.x += bullet.speed * cos(bullet.th);
bullet.y += bullet.speed * sin(bullet.th);
also: I've attached what I've got so far (I added the keyboard stuff as an afterthought, it works best with a joystick), and if you need alleg40.dll you can get it here.
your best bet is to use a direction vector for your bullet. you can obtain this vector as follows.
directionVec = DestinationPoint - CurrentPoint
then scale the magnitude to the speed of the bullet.
then at each frame move the bullet to the end of the obtained vector and you'll have the resulting flight! (note you can translate the vector with respect to the movement instead of calculating it each time assuming the bullet flys in a straight line ie. direction doesnt change)
im sure there are other approaches but this is just one example using your new found linear algebra skillz.
CurrentPosition= InitialPosition+ InterpolatePercent * (End - Initial).
InterpolatePercent is a decimal between 0 and 1, with 0 being the starting point and 1 being the end point. CurrentPosition and InitialPosition are points, End - Initial is the direction the bullet is travelling in. Most games dont' use this for bullets I don't think, rather they just get the ray the gun barrel is pointing in when it is fired and they test it for intersections.