New Camera Tutorial

Started by
12 comments, last by tobymurray 20 years, 6 months ago
thanks all for the comments.

the final construction of the view matrix is in the tutorial, it is the last piece of thoery before the code and its also reiterated in the code itself.

If i haven''t made it clear enough just let me know.
as far as submitting to gdnet, I submitted another article around 6 months ago and haven''t heard anything so I get the feeling they are more on the swamped side than desperate need side of the aritcle divide, however I am considering submitting this article anyway.

thanks again,
any more comments are completely welcome, the more feedback the better.
Toby

Gobsmacked - by Toby Murray
Advertisement
i loved this tutorial, thank you.

some things:
* "This works so long as amount is a unit vector (length == 1)", amount is a scalar in your tutorial, not a vector.
* a few spelling mistakes
* please explain how "fView41 = -D3DXVec3Dot(&m_vRight &m_vPosition); " actually gives -right.position as in the matrix you show before the code. and why fViewYX and not fViewXY.

i''ve been searching for camera tutorials and this one not only gave me the code, it actually made me understand it at a level that i, except for my last point, could create it from scratch.

thanks.
oh
there is a fundamental flaw in it though.
if you rotate around what is really UP (rotateAroundUp) you will get a ROLL effect... (ofcourse if you think about it)... in ALL fps cameras a look left/look right always rotates around the WORL up axis... like:

Matrix matRotateUp = Matrix.RotationAxis( new Vector3( 0, 0, -1 ), _yaw );

this removes the awkward roll effect when only doing yaw and pitch... try it, move the mouse around in circles... bad..
Ok, I read through the tutorial, but I have a few questions...

1) Here is is the psuedocode for rotating about the right vector:

up = RotateAboutRight * up
facing = RotateAboutRight * facing

I know that ''RotateAboutRight'' is a matrix, and ''up'' is a vector, so shouldn''t you multiply the other way round since DirectX uses row vectors?:

up = up * RotateAboutRight
facing = facing * RotateAboutRight

2) Here is the code for the final view matrix:

right.x up.x facing.x 0
right.y up.y facing.y 0
right.z up.z facing.z 0
-right.position -up.position -facing.position 1

Since you are using DirectX in this example, shouldn''t you use row vectors (cuz DirectX uses row vectors, right?) like this?:

right.x right.y right.z -right.position
up.x up.y up.z -up.position
facing.x facing.y facing.z -facing.position
0 0 0 1

3) In the above view matrix, could someone explain why you put the ''-right.position'' and the ''-up.position'' etc.. instead of just putting 0''s there?? What''s it for?

Please could anyone help me with any of these questions, I appreciate your time.

This topic is closed to new replies.

Advertisement