# Camera Transform Help

This topic is 4433 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I am trying to create a camera transform matrix that, if multiplied by a world coordinate, will give me a camera coordinate. The problem is, I think I derived the matrix wrong. I did inverseZrotation * inverseYrotation * inverseXrotation * inversetranslation (left to right, edit: column major) The wiki on 3d projection says to multiply the matrices in the opposite order of the world transform, but I think I may have taken that too literally. Am I multiplying the rotation matrices in the wrong order? I know I am doing something incorrectly since pitching is no good. Linear translations across the scene and yawing (if other angles are 0) appears to work though. Thanks ahead for helping. I am guessing my problem is I should be doing inverseXrotation * inverseYrotation * inverseZrotation * inversetranslation? [Edited by - OCcsdude on June 25, 2006 7:57:26 PM]

##### Share on other sites
Two questions:

1. Are you using row or column vectors?

2. What is your convention for Euler-angle order?

By the latter I mean in what order should the rotations about the world axes be applied. For example, if you wanted the x rotation to always 'appear' to be about the local x axis, and the y rotation to always 'appear' to be about the world y axis, the application order would be x->z->y. Note that this isn't necessarily the same as the matrix multiplication order, which depends on whether row or column vectors are being used.

##### Share on other sites
1. I am using the matrices in the wiki article on 3d projection and it says they are column major.

2. I want all angles to 'appear' to be about the local axes and not relative to the world (though that sounds interesting and some additional ways to multiply the matrices for that kind of thing would be nice to know).

##### Share on other sites
Quote:
 Original post by OCcsdude1. I am using the matrices in the wiki article on 3d projection and it says they are column major.
Whether the matrices are row- or column-major isn't relevant to this particular problem; what we need to know is whether row or column vectors are being used.
Quote:
 2. I want all angles to 'appear' to be about the local axes and not relative to the world...
I don't think this will be possible with from-scratch Euler-angle construction, which is what it looks like you're doing. With Euler-angles used in this way, the last rotation applied will always appear to be about the corresponding world axis.

Note however that this isn't always bad; for, say, an FPS camera, this is exactly the behavior you want.

##### Share on other sites
Now I understand what you mean by row/column vectors after looking it up. I am using column vectors. I suppose having the y-rotation be around the world y-axis will do fine. I was considering whether it would hamper a system where a manipulatable up direction is specified for physics calculations. Even in that case I don't think it should matter though.

##### Share on other sites
Quote:
 Original post by OCcsdudeNow I understand what you mean by row/column vectors after looking it up. I am using column vectors. I suppose having the y-rotation be around the world y-axis will do fine. I was considering whether it would hamper a system where a manipulatable up direction is specified for physics calculations. Even in that case I don't think it should matter though.
Ok, with column vectors and Euler order XZY, the 'forward' transform would be:
M = T*Y*Z*X
Making the inverse:
M = X^-1*Z^-1*Y^-1*T^-1
If you decide you need some other Euler order, you can of course just switch these around. Also, on a side note Euler angles aren't usually the best choice for physics calculations; for a camera though, they're usually fine.

##### Share on other sites
Awesome. I appreciate the help a lot. Time to work with a 6DOF renderer. The cool thing is I already have local 3d point and line drawing functions ready to go and tested.

##### Share on other sites
I have one more question. Is there a way I can get the x and y rotations to be relative to the local z-rotation of the camera. In other words, if angle z is say 45, pitching and yawing will appear to be the same as if z was 0 (will rotate straight vertically/horizontally).

In case any reader does not want to read the former posts, I am dealing with column vertices and euler angles and am trying to find a camera transform matrix. Are euler angles suitable for this (maybe with a certain multiplication order?) or is there some other math I should study. Thanks as always.

jyk, I know you said that "With Euler-angles used in this way, the last rotation applied will always appear to be about the corresponding world axis," but is there some way to make a system capable of more arbitrary camera rotation?

##### Share on other sites
Quote:
 Original post by OCcsdudejyk, I know you said that "With Euler-angles used in this way, the last rotation applied will always appear to be about the corresponding world axis," but is there some way to make a system capable of more arbitrary camera rotation?
The short answer is, some types of motion can be implemented using 'from scratch' Euler-angle matrix construction, while others require maintaining the rotation from frame to frame and updating it incrementally. The standard example of the former is an FPS-style camera; for the latter, it would a 6DOF camera such as in the game Descent.

What you're describing sounds like something in-between; my hunch is that incremental rotations would be required, but I'd have to give it some thought to be sure.

If you need info on how to implement pure 6DOF motion, I can post some links to references.

##### Share on other sites
Some links would be helpful if it's not too much trouble. I wonder how movement would work out with an incremental system. Maybe I can hold onto unit up, down, left, right reference points/vectors and modify them incrementally as needed. Up to now I have been using spherical coordinates, but I have just realized that with the 6DOF system I want they are not going to cut it. I am aiming for a general system where the camera class can be used in an fps or descent-like game.

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5

• 14
• 13
• 14
• 69
• 22
• ### Forum Statistics

• Total Topics
632138
• Total Posts
3004319

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!