Car simulator

Started by
2 comments, last by rcag 18 years, 4 months ago
hi i´m making a simple car simulator. i want my tracks to have inclination in some parts of it(ex. passing by a hill). my problem is how to determine the angle and the axis to apply the rotation to the car so that it inclines in the right direction when passing by the hill. internally my tracks are represented by nurbs and so i thought that, ok i have the direction of my car i can retreive a tangent vector to each point of the track and applying the arcos to the dot product of the normalized tangent vector with the normalized direction vector i can get the angle to rotate the car. but this solution raises big problems like : the cosin is symmetrical(i dont know if the car is going up or down the mountain) and to which axis(or combination of axis) to apply that angle... i know the existance of quaternions and i've been told that using them is the best choice for applying combinations of rotations in more than one axis.the problem is that i dont have a clue how to use them :( (and more important use them on the context of my problem). can anyone give me some help/suggestion?
knowlege is power /the path to sucess has no shortcuts
Advertisement
We were just talking about aligning an object to a surface a few threads down. First of all, you could do this with quaternions, but they don't have any particular magical properties that make them capable of doing things matrices can't. They do have some advantages though (efficient interpolation in particular) which make them a good candidate for this sort of thing.

But, it can certainly be done with matrices only. The simplest way to do this is to perform an axis-angle rotation that aligns the car's up vector with the surface normal. This is assuming your motion is otherwise unconstrained, but it may be the case that you also want the car (perhaps controlled by AI) to align with the tangent vector as well. The normal and the tangent together actually uniquely define an orientation, so you could just construct the rotation matrix directly. Or, you could apply the axis-angle method to both the up and forward vectors with interpolation, which would give more realistic behavior than just snapping instantly to the correct orientation.

Just some ideas.
just a suggestion....

Is directly rotating the car to match the surface normal even the approach you want for a car sim?
Wouldn't it be better to instead, have each wheel collision detect against the inclided surface, then tilt the car based on the different translation of each wheel, taking into account the car's suspension and whatnot?

If you just do a single rotation for the car as a whole, then depending on just how smooth the surface is compared to the size of the car, you might end up with some wheels going into the floor or some not touching....
thanks for all the suggestions/ideas
i'll try them :D
knowlege is power /the path to sucess has no shortcuts

This topic is closed to new replies.

Advertisement