![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
13 Year Old
Join Date: Jan 2008
Location: Toronto
Posts: 11
Rep Power: 0
![]() |
Hi,
For the past few weeks, I've been working on a racing game using directx. My vehicle driving and acceleration are good, however, I'm having a little trouble with the camera movements(the cam is placed behind my vehicle). I'm trying to position the camera so that when turning my vehicle, the camera should still be behind the vehicle, and the vehicle still remains to be the camera target, thereby only changing the yaw of the camera. I've been trying to come up with a solution to this for a few days now. But I'm still unsure of what to do. Any help is appreciated. Thanks in advance! ![]() |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
Re: Directx 3D Racing Game
Are you using XNA Game Studio to develop your game?
__________________
>BstrucT |
|
|
|
|
|
#3 |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 927
Rep Power: 4
![]() |
Re: Directx 3D Racing Game
I don't know if this will help, but here's a .NET Managed DirectX resource.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
|
Re: Directx 3D Racing Game
Thanks for the link lectricpharaoh!
Was looking for something like that myself but couldn't find anything decent. >BstrucT
__________________
>BstrucT |
|
|
|
|
|
#5 |
|
13 Year Old
Join Date: Jan 2008
Location: Toronto
Posts: 11
Rep Power: 0
![]() |
Re: Directx 3D Racing Game
Thank you for trying to help, but I have gone through every single one of these tutorials for DirectX. If I get the camera rotations for the car, then my problem will be solved. The site provided above does not have any tutorials on camera movements, but only how to set it up. I'm looking for a certain formula(s) for the camera position.
|
|
|
|
|
|
#6 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Re: Directx 3D Racing Game
You need to multiply the camera position vector with the same quaternion you used to rotate the car. Reimers's tutorials should have some insight about this.
http://www.riemers.net/eng/Tutorials...rp/series2.php |
|
|
|
|
|
#7 |
|
13 Year Old
Join Date: Jan 2008
Location: Toronto
Posts: 11
Rep Power: 0
![]() |
Re: Directx 3D Racing Game
Thanks for helping everyone. Although I didn't use quaternions, I got it! This is what it looks like after I modified it:
cameraPosition = new Vector3(Racer.vehiclePosition.X, 1f, Racer.vehiclePosition.Z);
cameraPosition.X -= (float)(Math.Sin(Racer.angle)) * 2f;
cameraPosition.Z -= (float)(Math.Cos(Racer.angle)) * 2f;
cameraTarget = cameraPosition;
cameraTarget.X += (float)Math.Sin(Racer.angle) * 0.5f;
cameraTarget.Y += (float)Math.Sin(_pitch) * 0.5f;
cameraTarget.Z += (float)Math.Cos(Racer.angle) * 0.5f;This code is from my camera.cs, and "Racer" is my main form with the rendering, and "angle" is increased by a certain amount every time Left/Right is pressed. It looks really good! Thanks for trying to help once again. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Coder's Block Arena - The Game AI Platform | Sane | Existing Project Development | 23 | May 6th, 2008 9:12 PM |
| Visualizing How Game Development Would Take Place | Josef_Stalin | Coder's Corner Lounge | 4 | Mar 14th, 2008 10:52 AM |
| Problems with directx and game crashing | Craig05 | Coder's Corner Lounge | 0 | Oct 30th, 2005 4:54 AM |
| Java programmers, game developers, artists, be ware! RPG game team is recruiting! | atcomputers.us | Paid Job Offers | 7 | Sep 25th, 2005 7:25 PM |
| Programmers Needed! Online Game | troy_eisert | C++ | 2 | Jan 29th, 2005 12:51 PM |