quaternion/camera tutorial wanted
Moderators - Reputation: 1357
Posted 24 August 2001 - 05:03 AM
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.)
Applied Research Associates, Inc.
Members - Reputation: 122
Posted 26 August 2001 - 08:45 PM
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 :
-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?
Posted 26 August 2001 - 09:11 PM
Members - Reputation: 122
Posted 28 August 2001 - 10:59 PM
when I want to draw an object seen from the camera I use a function called cam.Frame() after glLoadIdentity() and before glBegin();
float x,y,z, //coordinates of cam
ah,ay; //angles of cam
float x2=x,y2=y,z2=z; //direction of the camera
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