anyone use directx? (camera question)


#1

a forum inside a forum, never seen that before…

i tried asking this on GDNet but about all the response i got was 3 people rephrasing what i said and telling me to use google, and one guy who… i don’t think understood my question.

basically i need a way to figure out the LOOK, UP, and RIGHT vectors given 3 angles. this is because when i turn the camera upside down, the camera doesn’t turn upside down but rather flips rightside up. i know it has something to do with 3d math but i have no clue where to start…! (basically one of the replies i got on GDNet was “you need to use 3d math, go learn about matrices”… pretty sad when i ask for help and get 3 links to google).

i don’t know if anyone can answer as i’m sure more people here are artists than programmers, but if you can, :slight_smile:


#2

Well, I’m afraid to be the bearer of bad news, but this is something where you really should learn some linear algebra (aka, 3D math). It doesn’t make sense to try to do 3D programming without such a foundation, and it isn’t all that difficult to learn.

I haven’t coded in Direct3D in a while, so I can’t give you an exact solution. But basically you need to do the following:

*) Determine the order of your Euler angle rotation (xyz, zyx, xzy, etc). Look up the matrix equations for rotations around each angle, place the three matrixes beside one another, and then combine them with matrix multiplication. This will give you the matrix for rotating in a given axis order.

*) Plug your euler angles into the matrix.

*) That might be the matrix that you need for the camera. I don’t recall what Direct3D requires as a camera matrix. If that matrix isn’t it, then you need to take the transpose of that matrix. Equations for figuring out the transpose is available in any Linear Algebra text.

If you were using OpenGL, then there are some glu calls for setting up a camera which you can use without knowing much about matrixes. I don’t remember if Direct3D has similar calls or not. It’s been over two years since I last coded in D3D or OGL.

Hope this helps,
Michael Duffy
mduffy@ionet.net


#3

thanks for replying :smiley:

unfortunately you confirmed my fear :hmm: i don’t really… like… 3d math, maybe it’s just the horrible explanations of it i’ve found. i need to go find something that’s geared more towards people who DON’T have a Ph.d. in math.

unfortunately the camera in D3D really is this basic, and there are no helper functions like in OGL. basically the only help you get is that the help file says what the look vector is, kind of what the up vector is (i understand what it is NOW, no thanks to the help file), and that you can get the right by doing a cross product. ooookaaaaay…

well thanks anyway. i guess i’ll have to go learn 3d math now :surprised


#4

sorry for replying so late

3d linear algebra is not so difficult when it’s explained well!
and indeed u can’t go anywhere without it! :wink:

http://graphics.lcs.mit.edu/classes/6.837/F02/lectures.html

give a look here!


#5

Ph.D in math? 3D Math doesn’t equal that at all… I’d probably be able to learn it easily, and I’m not even starting Algebra. (Although I should be, damn it…)


#6

DrakeX - Dont you dare give up on it like that…

When it comes to programming games 3D math is cool math trust me. You will want to learn it :cool:

I will do you one better my friend…

This is your path to your dreams good luck

Online Gaming University


#7

krunch – thanks for the link, looks like a lot of info to cover :eek: but i’m sure i’ll have time in a few weeks… right now i’m a little tied up with english class (movie… among other things…)

BP – if it’s so damn easy why don’t you explain it to me :wink: hehe

mesh – cool :slight_smile: i’ll have to look at that site some more…

what i’d like to know is why it doesn’t seem like anyone has written any kind of simple camera lib to make things like this easy…! i mean really, everyone has to make camera functions when they make a game… i’m kind of amazed no one’s released them.


#8

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.