Moving a 3D object along it's own axes

BlitzMax Forums/BlitzMax Programming/Moving a 3D object along it's own axes

Sanctus(Posted 2009) [#1]
Hi
I'm trying to make a small 3D engine and I have some problems.
I have and abject that has a position Pos (a 3 float vector)
It also has a Rot vactor that stores the object's orientation.

I'm trying to make a function named Turn that's supossed to do kind of like whta minib3D does: Modify the position vector using the rotation vector o that the object will move along it's axes (not the global ones).
I tryed looking ath the minib3d code but somehow that doesn't work( just when the rotation vector is 0,0,0)

Any ideea on how to do this?


Brendane(Posted 2009) [#2]
Construct a 3x3 orientation matrix from the rotation vector...

Each column (or row depending on how you construct it) of the matrix is the normal vector for that axis.

ie. with no rotation, the x-axis is (1,0,0), the y-axis is (0,1,0) etc.

Check these after a rotation, you'll see it makes perfect sense.

I'll presume you know how to translate an object once you know the vector you want to translate by. :)

Be aware that if your object is in a hierarchy you will want to concatenate the orientations through the hierarchy. (let me know if you don't understand this)


Sanctus(Posted 2009) [#3]
I'm working on C# for this project and aparently it takes radians for cos and sin while blitzmax takes degrees. That was the only problem. And now it works perfectly. I haven't implemented a hierarchy yet but I will.
I'm still having problems with raytracing picking. I have a line generated trough glunproject and and the mesh triangles. I also have a function that tests if a line and a triangle intersect. The problem is that I have to move the object and it won't always be in the center. so I guess I'll have to rotate and translate the line by minus the objects rotation and translation.

If you have any articles worth reading for this I'd be grateful.