Re: Moving and Rotating Camera.
"Uday Karan" <[email protected]> Sat, 11 Mar 2006 05:09:24 -0800
| Newsgroups | gmane.games.devel.opengl |
|---|---|
| Organization | Fat City Network Services, San Diego, California |
| Message-ID | <[email protected]> |
Hi Ajit, The two different ways you are visualizing things here might look different intutively but give out the same final result. Everything eventually needs to be transformed to the view space. Since you have the position and the direction vector (and possibly an up vector, if your car is shaking a lot ;) or use (0, 1, 0) if not), you can create a model view matrix using these vectors. Essentially, you need three vectors: direction, right and up. You already have the direction vector, cross (direction, (0, 1, 0)) will give you the right vector. cross (right, direction) will then give you the up vector. let these vectors we n (direction), u (right) and v (up). Lay your model view matrix as: u.x u.y u.z -pos.x v.x v.y v.z -pos.y n.x n.y n.z -pos.z 0.0 0.0 0.0 1.0 and load it in your GL_MODEVIEW matrix. If this is too much detail, you can use gluLookAt to get similar results. (I am passing complete vectors here, you will have to pass individual components) gluLookAt (pos, pos + dir, (0, 1, 0)); Just making it look a unit away into the given direction. Hope this helps, Uday On 3/11/06, Ajit Singh <[email protected]> wrote: > Hello, > > I'm working on a Racing Game and I want to move and rotate the camera along > with car in the Game. I have to do this i.e, to Move and Rotate the camera > using Lookat, I mean using Position Vector and Direction Vector. > > There is an another alternative to move the world in the opposite direction, > but I want to go with the first, that is the camera movement. > > I'm not able to do that. > > Any Help Appreciated. > > > Regards & Thanks > Ajit Singh > Trainee Software Enggineer. > Lambent Technologies Pvt. Ltd. > > > > > > > Express yourself with over 8,000 FREE Email Smileys - click here! > > > > > -- > This message has been scanned for viruses and > dangerous content and is believed to be clean. > > > ----- > FAQ and OpenGL Resources at: > http://www.geocities.com/SiliconValley/Hills/9956/OpenGL > > -- > Author: Ajit Singh > INET: [email protected] > > Fat City Hosting, San Diego, California -- http://www.fatcity.com > --------------------------------------------------------------------- > To REMOVE yourself from this mailing list, send an E-Mail message > to: [email protected] (note EXACT spelling of 'ListGuru') and in > the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L > (or the name of mailing list you want to be removed from). You may > also send the HELP command for other information (like subscribing). > ----- FAQ and OpenGL Resources at: http://www.geocities.com/SiliconValley/Hills/9956/OpenGL -- Author: Uday Karan INET: [email protected] Fat City Hosting, San Diego, California -- http://www.fatcity.com --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [email protected] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).