Jump to content

  • Log In with Google      Sign In   
  • Create Account

quaternion/camera tutorial wanted


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 bloemschneif   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 August 2001 - 01:04 AM

hello, can u advise me a good quaternionen / camera tutorial? i got problems fix my camera math. thanx

Sponsor:

#2 grhodes_at_work   Moderators   -  Reputation: 1361

Like
Likes
Like

Posted 24 August 2001 - 05:03 AM

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.

#3 grhodes_at_work   Moderators   -  Reputation: 1361

Like
Likes
Like

Posted 24 August 2001 - 05:03 AM

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.

#4 AblazeSpace   Members   -  Reputation: 161

Like
Likes
Like

Posted 25 August 2001 - 07:26 PM

At the moment I write such an tutorial for NeHe''s side...

#5 bloemschneif   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 August 2001 - 08:45 PM

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

#6 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 26 August 2001 - 09:11 PM

Gamasutra has one featured:

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

/Urbi

#7 bloemschneif   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 August 2001 - 05:45 PM

i allready red this, didnt help me at all...
need more input

#8 Kestrel   Members   -  Reputation: 158

Like
Likes
Like

Posted 27 August 2001 - 06:00 PM

you should check out this site
http://personal.nbnet.nb.ca/daveg/openg
It has a Quaternion demo that you might find useful.

#9 bloemschneif   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 August 2001 - 02:01 AM

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.


#10 icecode   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 August 2001 - 10:59 PM

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

#11 bloemschneif   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 August 2001 - 07:02 AM

sorry man, but pure java code. i dont know anything about oGL.
never the less, thank u.

#12 icecode   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 August 2001 - 07:28 AM

sorry, didnt know..

#13 bloemschneif   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 August 2001 - 08:15 PM

can i see u''re game?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS