quat, matrix, camera oh my!
by Ron Yacketta · in Torque Game Engine · 11/04/2002 (9:08 pm) · 7 replies
need some help, I suck at this 3D math stuff which is making it very frustrating to fulfill my goal of being a 3D game coder.
I know what I want to-do with the camera, but no clue how to-do it with code. can someone with more braincells than me lend a hand?
-Ron
I know what I want to-do with the camera, but no clue how to-do it with code. can someone with more braincells than me lend a hand?
-Ron
#2
I am attempting to do the rotation first, then the positioning. I am not sure if this is correct etc, have yet to find a newbie type 3D math resource..
11/05/2002 (8:06 am)
I am trying to position the camera at a specified location and rotation.I am attempting to do the rotation first, then the positioning. I am not sure if this is correct etc, have yet to find a newbie type 3D math resource..
mCameraMatrix.identity(); /* X Y Z X 1 0 0 Y 0 1 0 Z 0 0 1 */ // set the X axis rotation in deg's mCameraRot.set( mDegToRad(90.0f), 0, 0 ); // rotate CameraMatrix around the CameraRot mCameraMatrix.mul(mCameraRot); // set postion in deg's mCameraPos.set( 0, mDegToRad(-200.0f), mDegToRad(500.0f) ); // position CameraMatrix based on CameraPos mCameraMatrix.mul(mCameraPos);
#3
I wish I could help, but best I can offer is 'I know the feeling'! If you find a good text or resource that explains this stuff in baby steps please post it :)
James
11/05/2002 (10:20 am)
Ron,I wish I could help, but best I can offer is 'I know the feeling'! If you find a good text or resource that explains this stuff in baby steps please post it :)
James
#4
mCameraRot.set(EulerF(mDegToRad(90), 0, 0)); // Initialize rotation matrix using euler
mCameraMatrix.mul(mCameraRot); // mult in rotation
mCameraPos.set( 0, -200.0f, 500.0f); // setup position Point
mCameraMatrix.setColumn(3, &mCameraPos); // set matrix position
11/05/2002 (11:24 am)
this should work, you dont set position in radians .. mCameraRot.set(EulerF(mDegToRad(90), 0, 0)); // Initialize rotation matrix using euler
mCameraMatrix.mul(mCameraRot); // mult in rotation
mCameraPos.set( 0, -200.0f, 500.0f); // setup position Point
mCameraMatrix.setColumn(3, &mCameraPos); // set matrix position
#5
mCameraMatrix.setColumn(3, &mCameraPos); // set matrix position
11/06/2002 (5:53 am)
@Badguy - Can you or anyone explain why column 3 is used to set position? Haven't found a good answer for that one. Do the other columns have similiar uses?mCameraMatrix.setColumn(3, &mCameraPos); // set matrix position
#6
You can get some decent information about the components of the rotation matrix at http://www.makegames.com/3drotation/
Just be sure to ignore Gruber's somewhat goofy opinions on quaternions found at the end of the article.
11/06/2002 (6:14 am)
Wendell, That's just the way that the math works out. If you take a matrix and multiply it by a vector, the 4th column (Remember, C/C++ is zero based!) will end up being added to the components of the vector. The other columns are mostly components of the rotation matrix.You can get some decent information about the components of the rotation matrix at http://www.makegames.com/3drotation/
Just be sure to ignore Gruber's somewhat goofy opinions on quaternions found at the end of the article.
#7
(Torque-)Matrix:
1) x-axis position
2) y-axis position
3) z-axis position
4) x-axis rotation
5) y-axis rotation
6) z-axis rotation
These rotation numbers make up the axis of rotation of the object,
and the 7th and final number is the ...
7) rotation about that axis in radians
11/06/2002 (6:43 am)
Wendell, maybe this helps, also:(Torque-)Matrix:
1) x-axis position
2) y-axis position
3) z-axis position
4) x-axis rotation
5) y-axis rotation
6) z-axis rotation
These rotation numbers make up the axis of rotation of the object,
and the 7th and final number is the ...
7) rotation about that axis in radians
Torque Owner James \"Corvidae\" Williams
http://www.gamasutra.com/features/19980703/quaternions_01.htm