1. matrix rotation.

Hi, can anyone help me out with some 3d rotation?
I've got a direction vector {x,y,z} for a 1st person perspective thing,
and i need to be able to rotate it around th 3 axis.
i can use the following to make it turn left/right:

new_direction[x] = direction[x] * sin(angle) + direction[z] * cos(angle)
new_direction[z] = direction[z] * sin(angle) - direction[x] * cos(angle)

That works fine, but from past experience, that method causes incorrect
rotation when you apply it 3 times, one for each axis of rotation.
I've read that matrix rotation produced correct results, but I'm not sure
how to do it. Can anyone help? The 3d engine that I've created should
alow you to point the camera in any position, any angle. It can't do objects
yet tho, it only allows a flat grid mapped ground and a textured 2 layer
moving cloud sky. It also has fog. I'm currently working on speeding it up
so it will beable to run real-time. at the moment it takes 35 minutes
on a 486 to generate 45 frames. when i add the speedup to it it should
run at about 2 frames per second, and it's still in pure euphoria code.
assembly code can speed it up even more.

Thanks for any help!
     Mark.

new topic     » topic index » view message » categorize

2. Re: matrix rotation.

I quote this from the Black Art of 3D Game Programming by Andrew LaMothe
(great book, highly recomended)...to adjust angle along z axis (up/down)
new_direction[x] = direction[x]*cos(angle) - direction[y]*sin(angle)
new_direction[y] = direction[x]*sin(angle) + direction[y]*cos(angle)

to adjust along the x axis (forward/backward)
new_direction[y] = direction[y]*cos(angle) - direction[z]*sin(angle)
new_direction[z] = direction[y]*sin(angle) + direction[z]*cos(angle)

Hope this helps,
Adam Weeden
WeedenSoft Technologies

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu