Moving directions

Hi all! Loving OpenGl, graphics programming made easy and fun. Well I have a question regarding moving in a 3-d environment. Currently, I move in the forward direction my camera is facing by multiplying a vec(0.0f, 0.0f, 1.0f) by the camRotationMatrix, and I suppose it being the first way I came up with moving in any way the camera is looking is alright, but I want to know if there is a better way. Currently, I’m having problems being able to “select” objects I’m looking at, and to solve it for now I “ray cast” from my cameras position, forward in the way it is facing, by the way explained above. When looking some directions, it works great (not perfectly straight, its weird, but gets the messy job done), however when looking in other directions, the “ray” will not move in the predicted pattern, as in going up when I’m looking down. So, to end this lengthy post, how can I calculate a movement vector for any direction I’m looking, and works in all directions, and what are the flaws in the way I am doing it now?
Hope to hear from you all soon! Happy holidays and cheers!

Ray casting works and is a good method, is robust and portable, you have a bug.

Moving forward like that works but you have to get the multiplication order correct. You’re basically multiplying a rotation matrix with a translation matrix.

The real question then arises, how do you then move sequentially in the scene. You can matrix multiply incremental deltas and rotations as you go. Rounding accumulations can mess up the 3x3 rotational making it non orthogonal.

It really depends what kind of motion you’re interested in. Typically you either have a camera concept or a ship simulation which you then produce a viewing matrix from.

Here’s a tutorial and sample/demo code I wrote in 1998 that included motion simulation courtesy of the wayback machine.

Index with several tutorials:

The Aqua tutorial describing an incremental ship-frame relative motion calculation:

Awesome tutorials! You must know a lot about geometry. Well, the motion tutorial explained some things to me, but I still have a few questions if you wouldn’t mind helping me out a bit more. Multiplying the rotation matrix and translation matrix works great when constrained to x and z axis, but when the y axis movement is added is when things get weird. += forward * (speed * dtime);

This is already what I am doing, which is fairly simple, and the rest of your movement section in the Aqua tutorial seems to be about orientation of the object, which I don’t need, I just need it to move in the right direction. About the rounding thing, I never recalculate the forward vector for the “ray”, it is always (0.0f, 0.0f, 1.0f), should I recalculate it as you do in your tutorial? I see that you recalculated your forward and up vector using a pitch matrix, but what is that there for exactly? Is that to generate a new forward and up for which ever way your ship is facing? Do I need an up vector to properly simulate the movement, and if I do, this might be why going up or down slowly makes the ray get out of sync with where I am looking.

Well I’ll be awaiting your reply! Happy holidays, cheers!