Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 2nd, 2008, 7:43 PM   #1
theflamer14
13 Year Old
 
Join Date: Jan 2008
Location: Toronto
Posts: 11
Rep Power: 0 theflamer14 is on a distinguished road
Exclamation Directx 3D Racing Game

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!
theflamer14 is offline   Reply With Quote
Old Apr 3rd, 2008, 12:31 AM   #2
BstrucT
Hobbyist Programmer
 
BstrucT's Avatar
 
Join Date: Dec 2007
Location: Durban, South-Africa
Posts: 132
Rep Power: 1 BstrucT is on a distinguished road
Send a message via MSN to BstrucT
Re: Directx 3D Racing Game

Are you using XNA Game Studio to develop your game?
__________________
>BstrucT
BstrucT is online now   Reply With Quote
Old Apr 3rd, 2008, 1:59 AM   #3
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 925
Rep Power: 4 lectricpharaoh will become famous soon enough
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
lectricpharaoh is offline   Reply With Quote
Old Apr 3rd, 2008, 3:17 AM   #4
BstrucT
Hobbyist Programmer
 
BstrucT's Avatar
 
Join Date: Dec 2007
Location: Durban, South-Africa
Posts: 132
Rep Power: 1 BstrucT is on a distinguished road
Send a message via MSN to BstrucT
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
BstrucT is online now   Reply With Quote
Old Apr 3rd, 2008, 11:38 AM   #5
theflamer14
13 Year Old
 
Join Date: Jan 2008
Location: Toronto
Posts: 11
Rep Power: 0 theflamer14 is on a distinguished road
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.
theflamer14 is offline   Reply With Quote
Old Apr 3rd, 2008, 11:51 AM   #6
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
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
OpenLoop is offline   Reply With Quote
Old Apr 3rd, 2008, 5:41 PM   #7
theflamer14
13 Year Old
 
Join Date: Jan 2008
Location: Toronto
Posts: 11
Rep Power: 0 theflamer14 is on a distinguished road
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.
theflamer14 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC