Forums

Full Version: modify AI drivers and track
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,i have two questions:
1) i have tried to inspect the code but i don't find where the AI of the computer drivers is implemented.
2) What i have to do if i want to modify a track? i have to use Blender? if yes, what i have to do to import in blender the model of the track?

thanks.
1) It's in src/ai.cpp

2) What kind of modification do you want? Modify the track parameters, or actually modify the track objects? If it's the former, you can use track editor to do that. I don't think you can import the whole track into blender to modify the objects.
i want to modify the track object but i don't find the track editor, where is it?
Just an other question,i need that the car controlled by the computer run on the contrary in the track, i have tried to modify the function UpdateSteer, now the car run on the contrary but don't follow the street. Probably i haven't understand really well as it comes calculated the next angle of steering, someone say something about it?

thanks a lot.
At the car selection menu, there is an option 'Reverse Track'. If it's on, you will race in the reverse direction of the track. Is that what you want?
Not exacltly, i need that the other cars (the cars controlled by the computer) run in the opposite sense to mine.
I'm using Vdrift for a project and this is one of the point that i have to do..
Is this an assignment for a class or something?
He said earlier a project where hes trying to make a virtual helmet correct? i think what he wants is to simulate a car passing you on your left as what would happen in traffic. Big Grin Big Grin
it's a school project, i have interfaced the game with an head mounted display and now i have to modify something to test the ability of the user, one of this thing is modify the ai of the other car, so the user have to avoid the other cars during the game.
I have seen that i have to modify the function "updateSteer" in the file ai.cpp but with the modify that i have done the car turns on the contrary but don't follow the street..
I see what you are saying. thats a bit out of my ability. any ideas joe? (good luck with your project!)
mpo Wrote:I have seen that i have to modify the function "updateSteer" in the file ai.cpp but with the modify that i have done the car turns on the contrary but don't follow the street..

Well, I can be wrong, I never programmed the ai.
But I think it works as follows: It has a set of vectors that marks the street. from their it calculates the best route.
So if you reverse the set of vectors the AI is going to follow the opposite direction.
If all you want is to test the functionality, why not just set the 'reverse track' option? AI will drive in the reverse direction. You, as the player, can drive in whatever direction you want.

<edit>Come to think of it, there is actually no change required. Just let AI drive normally, and ask the player to drive in the reverse direction. Wouldn't this achieve the result you want?</edit>
Not exactly, with this solution the user have to change his direction when start the race, i have to modify the code to avoid it, in this way all will be automatic.
Ok. If that's the case, all you need is to reverse the player's starting orientation.

If you want to do it programmatically, check out function TRACK::ReverseStartingPositions(). This function calculates the reverse starting position and orientation when 'Reverse Track' option is set. Note that this function calculates the reverse for all cars. In your case, you only need to reverse the 1st starting location and orientation in the list, which is what the player car uses.

<edit>Sorry, the reversing of start orientation is done in TRACK::Reverse(). The relevant lines are,
Code:
//reverse start positions
        for (vector <QUATERNION>::iterator i = startquat.begin(); i != startquat.end(); i++)
        {
                //*i = i->ReturnConjugate();
                i->Rotate(3.141593, 0,1,0);
        }
</edit>