first of all thanks everyone for the input ...
Now, I know you're gonna call me lazy (it's getting late here, and i'm determined to crack this tonight!) but assume for example i'm flying through a 3d scene (ie moving the camera around), but so far the above only deals with rotating the camera around a fixed point ... what about allowing it full movement as in a normal flight sim? how do you work out where the ship/aeroplane will be after a given rotation, at a given forward velocity? The reason i'm asking is because if you know the start vector ... and say you travel at 1 km per second ... you won't be 1 km further away after a second, because you'll have described an arc through whatever medium you're flying! HELP ...
I think that made sense!
for those that are interested i'm trying to incorporate some form of prediction into the engine i'm creating, so as to allow internet play without being dependant on a good ping ... i'm therefore gonna have to be able to take a know position and rotation and predict the next few probable positions over a given amount of time. say for example another player is banking fully to the right, whilst climbing at the maximum rate, it must be assumed (in the case of a momentarily lost connection) that they are still performing that move!
Please keep this one going, as it is proving to be quite an interesting discussion! I'm sure a lot of ppl will benefit from understanding quaternions!!!
Many Regards All
(PS try http://personal.nbnet.nb.ca/daveg/opengl/quatdemo/quatdemo.zip it's an interesting example of quaternions)
Edited by - Shag on July 17, 2001 9:42:43 PM
Quaternions: A Real Pisser
July 17, 2001 07:27 PM
quote:
Original post by Shag
The reason i''m asking is because if you know the start vector ... and say you travel at 1 km per second ... you won''t be 1 km further away after a second, because you''ll have described an arc through whatever medium you''re flying! HELP ...
NewDeal posted some equations to get the vector of the camera based on its orientation....
dirX = 2.0 * (x * z - w * y)
dirY = 2.0 * (y * z + w * x)
dirZ = 1.0 - 2.0 * (x * x + y * y);
(x,y,z,w are parts of a Quaternion)
I''m not sure if that''s what you want though.
My thanks goes out to all of you too. NewDeal, I''ve managed to break your class somehow =). I''ve never met a piece of code I couldn''t make work anymore, and well, yours is no exception. Here''s a code snippit:
glLoadIdentity();
tempquat.EulerToQuat(pyaw, ppitch, proll); //praw etc are amounts gotten by keyboard input
tempquat.MultQuat(rotquat); //rotquat = rotation quaternion. RotQuat. Thats a damn good variable name.
tempquat.toAxisAngle(result);
rotquat->x = tempquat->x;//Need to overload + for this
rotquat->y = tempquat->y;
rotquat->z = tempquat->z;
rotquat->w = tempquat->w;
rotquat->qLength = tempquat->qlength;
glRotatef(result[0], result[1], result[2], result[3]);
This is done using NewDeal''s Quat Class. For some reason all I see is my skybox flickering in and out of existance, and if I hit a key (make pyaw, ppitch, or proll different from 0 for 1 frame) everything disappears entirely.
Umm... I''m not sure what quaternion rotation has to do with the width of your skybox, are you sure you don''t have your classes mixed up or something?
-David-
-David-
quote:
Original post by Shag
first of all thanks everyone for the input ...
no prob...
quote:
Original post by Shag
Now, I know you''re gonna call me lazy
ok, lazy

quote:
Original post by Shag
(it''s getting late here, and i''m determined to crack this tonight!)
Not likely! (Just being realistic...)
quote:
Original post by Shag
but assume for example i''m flying through a 3d scene (ie moving the camera around), but so far the above only deals with rotating the camera around a fixed point ... what about allowing it full movement as in a normal flight sim? how do you work out where the ship/aeroplane will be after a given rotation, at a given forward velocity? The reason i''m asking is because if you know the start vector ... and say you travel at 1 km per second ... you won''t be 1 km further away after a second, because you''ll have described an arc through whatever medium you''re flying! HELP ...
to do the movement along an arc you''ll have to use finner time slices. The smaller time slice you use the smother the arc. if for example you move 1 km and bank 10 degrees in 1 second you could divide that into 20 updates of 0.5 degrees bank and 0.05km of movement that would give you a 20 sided arc not a perfect arc but smother that just a straight line. To get a smoth movement you''ll probably have to eather use a spline curve or possably that smoth interpolation in the game programming gems book that Dobbs mentioned (I gotta get that now)
Also, anyone that actually understands the actuall quaternion math stuff (not just how to use it) I''d be interested in working on a tutorial that explains quaternions that we could maybe get nehe to put on the site? Anyway I''m gonna start working on it myself anyone that wants to help e-mail me at avian@prairie.lakes.com
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
Ok Dave 
Your code looks very much like mine (which works
) so i dont think the problem lies in the code you just posted.
Please take no offense but ill list some things you might havent thought of
.
First of all try letting go of the skybox for a while (while testing the other stuff). Put in a box or sumthing and try moving around it.
Make sure that pyaw, ppitch, proll are containing only the values for last frame. I set them to 0 when im done rotating. And make sure that they are in radians (very important and i dont think i mentioned it).
When you create the RotQuat use the constructor which takes no parameters. Its important that w is set to 1 initialy since this is the identity quat for multiplications.
Try normalizing both quats after each frame. Dont think this is the problem but it cant hurt.
Good luck.
BTW if you want my entire camera class then feel free to email me.

Your code looks very much like mine (which works

Please take no offense but ill list some things you might havent thought of

First of all try letting go of the skybox for a while (while testing the other stuff). Put in a box or sumthing and try moving around it.
Make sure that pyaw, ppitch, proll are containing only the values for last frame. I set them to 0 when im done rotating. And make sure that they are in radians (very important and i dont think i mentioned it).
When you create the RotQuat use the constructor which takes no parameters. Its important that w is set to 1 initialy since this is the identity quat for multiplications.
Try normalizing both quats after each frame. Dont think this is the problem but it cant hurt.
Good luck.
BTW if you want my entire camera class then feel free to email me.
Have a look at:
http://www.btinternet.com/~matt.lisa/ogl1.htm
It helped me out!
http://www.btinternet.com/~matt.lisa/ogl1.htm
It helped me out!
COOL it''s all working!!! quaternions are easy ... it''s official!
Thanks to everyone how has posted here ...
BTW ... if anyone is interested here are a couple of screen shots of the earth, with specular reflections of the oceans, land mass, and cloud cover!
http://www.btinternet.com/~mark.shaxted/
Thanks to everyone how has posted here ...
BTW ... if anyone is interested here are a couple of screen shots of the earth, with specular reflections of the oceans, land mass, and cloud cover!
http://www.btinternet.com/~mark.shaxted/
Thanks for all your help, I got my Quats working as well. As it turns out, everything with my code was sound. This was the problem: I had a function called deg2rad which converted degrees to radians (so I could use degrees with the trig functions). Unbeknownst to me, the vile Coding Gnomes turned on my computer during the night, and changed return blah*(PI/180.0) to return blah*(PI*180.0). Those bastards.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement