• Advertisement

Archived

This topic is now archived and is closed to further replies.

quaternion/camera tutorial wanted

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
What kind of camera do you have? 3rd person, 1st person?

There is a chapter in "Game Programming Gems II" from Charles River Media on the Super Mario 64 3rd person camera model, from one of Nintendo''s programmers. It''s not really a tutorial, more a detailed technical documentation of their model and how to implement it. You might find it useful. There may be other chapters on camera control as well----I haven''t looked at it in great detail yet. My guess is you would get far more out of the book than just camera stuff.

(That book was just shipped last week, but you should be able to order it. Not sure if libraries will have it yet.)

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Actually,

I guess I should know from another post that you have a 3rd person camera model!

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
well, i was looking for some 3rd-person tutorial at the web, but i only found some possibilyties to buy or download a 3d-engine, basic 3d-math tutorials and other unusefull stuff.
my mathematical knowledges doesnt allow me to solve my problem by my self. i simply want to know, how to move the camera behind my player, looking to the direction of the player.
i am able to set up the camera at a fixed point behind the player but i cant set the rot-matrix of the camera to the dircetion i want. ghrodes further told me how to rotate an object to a given dir-eiheits-vec using a quaternion. but this doesnt helps me at all, because the camera points to the opposite dir of the angles ( i press right, camera goes felt, i press down, camera goes up.. ). i negated the x/y/z part of the quaternion :
camera.quaternion(cos(angle/2),
-n.x * sin(angle/2)),
-n.y * sin(angle/2)),
-n.z * sin(angle/2)))
the result was that the camera pointed to the correct dir, but it did a rotation about z-axis while moving around (u can see here ).
using quaternions is still a little mysterious to me, because:
u can rotate an object to the dir u wanna have, u just have on
vec of R³. quaternion allow u to rotate it to that axis. rotate
the object about this axis takes one more calculating step.
i made a little demo-tool to visualise this. there is a source
object that rotates arbitrary and a dest. obj. that gets the
normal-einheits-vec from source and calculating the rest by it
self. i found that it is also possible to let the source object
rotate about z-axis and the quaternion-calculated object is
taking that dir also in the correct way. why??? one vec
represents a line, that is enought information to do x/y rot.
but z-rot also works?
u see it isnt easy to understand for my.
AblazeSpace, can u let me know, when u''re tut. will be finished?

thanks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Gamasutra has one featured:

http://www.gamasutra.com/features/19980703/quaternions_01.htm

/Urbi

Share this post


Link to post
Share on other sites
you should check out this site
http://personal.nbnet.nb.ca/daveg/openg
It has a Quaternion demo that you might find useful.

Share this post


Link to post
Share on other sites
nope,
no usefull to me. u dont seem to understand my problem:
i have a direction-einheits-vector that represents the orientation of my player, i need to calculate the camera rot.matr. so that it points to that dir.

Share this post


Link to post
Share on other sites
i have a class called cam.
when I want to draw an object seen from the camera I use a function called cam.Frame() after glLoadIdentity() and before glBegin();

class CAM
{
public:
float x,y,z, //coordinates of cam
ah,ay; //angles of cam
void Frame();
};
void CAM::Frame()
{
float x2=x,y2=y,z2=z; //direction of the camera
Advance3d(x2,y2,z2,ah,ay,10.0f);
glLookAt(x,y,z,x2,y2,z2,0,1,0);
}

Advance3d is a function which advances x y and z along the ah and ay angle.
It works fine in my game, hope it helps

icecode

Share this post


Link to post
Share on other sites

  • Advertisement