🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

rotating a view matrix around its origin?

Started by
0 comments, last by youngo 24 years, 6 months ago
how can i make a view matrix rotate, or make it seem like it''s rotating around it''s origin? like first person shooters.. Edited by - youngo on 1/3/00 4:26:41 AM
Advertisement
You have to remember that there is no such thing as a camera. In 3D world you only have one space and that is global/world space. The origin of that space is always 0,0,0 and you can achieve all transformations in world space just by using the world matrix in d3d or modelview matrix in opengl. In d3d for convenience sake they included a view/camera matrix that further transforms the objects in world space. The view matrix has same origin as that of the world space, however you specify the offset in 3d space with the view matrix and then it seems as if though you were using the camera. The view matrix is multiplied with world matrix and then every vertex in the object is multiplied by this concatenated world/view matrix to come to final resting place in world space. There are functions in both apis that will rotate your objects in the world/view space. In opengl you use glRotatef() in d3dx use D3DXMatrixRotationX() for example. You have to remember that in opengl you write first what you want to be done last, and in d3d you write first what you want to be done first then the second thing you want, etc. Correct me if I am wrong but I think this is because the order of matrix multiplication of two matrices differ in both apis.

OpenGL:
glRotatef(blah); <--- done last
glTranslated(blah); <--- done first

d3dx:
D3DXMatrixRotationX(blah); <--- done first
D3DXMatrixTranslation(blah); <---- done last

It's little confusing in opengl but it's the same in assembly where stack growns downward and you read numbers from right to left or little endian for intel/amd machines.

In d3dx if you want to rotate around the origin first then translate/move to new location is always different than moving to new location first and then rotating. In first case you rotate around yourself then you move to new place, while in second case you move to new place then rotate around the origin so you end up half way across the room while traveling in an arc shape. For first person view you want the first case, while for modeling or camera work you want the second case. Hope this helps:)

Edited by - JD on 1/4/00 1:55:02 AM

This topic is closed to new replies.

Advertisement