Vehicle physics

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Tasaq
Posts: 13
Joined: Mon Mar 26, 2012 4:25 pm

Vehicle physics

Post by Tasaq »

First of all, I want to congratulate creators for easy to use physics tool :) I've tried many of physics engines but this one is the most user friendly library i found :)
Now to the question, I created method to create vehicle similar to one that we can find inside the demos. I played along with some settings and found strange things happen.
What i did is setting fron wheels brakes and grip to high values and setting rear wheel brakes to 0 and friction to 0, I also put ground friction to small amount. Since nothing happened i ended up with setting friction of every object to 0. And nothing moved. Can You tell me what I am missing, I tought that car will behave like a car set on ice, instead it behaved like it wouldn't have even one HP :D Also I have problems with measure. Since in demos gravity is set to ~9.81 i presume that units are SI, but whet i model box in max that have 1x1x1 meter dimensions and then import it to xna it gots much larger. Ok to make it shorter I would like to know how come wheels didn't move on 0 friction? And why I can't make rear wheels spin faster that front when I start movement? Can You give me a hint about importing models that will work fine with bepu?
And sorry for soooo many simple questions :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Vehicle physics

Post by Norbo »

Since in demos gravity is set to ~9.81 i presume that units are SI
The engine itself is unitless. You can pick whatever meaning you want for the units so long as it's consistent and numerically reasonable. "Numerically reasonable" means that the absolute values aren't made too large or small; single precision floating point numbers cannot represent every value. In addition, staying within 0.5 to 10 units across or so for most individual objects helps the collision detection system. It can handle much larger sizes, but that range is very safe.

There are some more advanced configuration options that can be adjusted if a different scale interpretation is required, but it's good to avoid that if possible.
What i did is setting fron wheels brakes and grip to high values and setting rear wheel brakes to 0 and friction to 0, I also put ground friction to small amount. Since nothing happened i ended up with setting friction of every object to 0. And nothing moved. Can You tell me what I am missing, I tought that car will behave like a car set on ice, instead it behaved like it wouldn't have even one HP :)
If the combined grip friction is zero, the vehicle cannot accelerate- in that way, it is like a car on ice.

For example, in the following, sliding friction, rolling friction, brake friction, and grip friction are zero:

Code: Select all

            Vehicle.AddWheel(new Wheel(
                                 new RaycastWheelShape(.375f, wheelGraphicRotation),
                                 new WheelSuspension(2000, 100f, Vector3.Down, .8f, new Vector3(-1.1f, 0, 1.8f)),
                                 new WheelDrivingMotor(0, 30000, 10000),
                                 new WheelBrake(0, 0, 0),
                                 new WheelSlidingFriction(0, 0)));
            Vehicle.AddWheel(new Wheel(
                                 new RaycastWheelShape(.375f, wheelGraphicRotation),
                                 new WheelSuspension(2000, 100f, Vector3.Down, .8f, new Vector3(-1.1f, 0, -1.8f)),
                                 new WheelDrivingMotor(0, 30000, 10000),
                                 new WheelBrake(0, 0, 0),
                                 new WheelSlidingFriction(0, 0)));
            Vehicle.AddWheel(new Wheel(
                                 new RaycastWheelShape(.375f, wheelGraphicRotation),
                                 new WheelSuspension(2000, 100f, Vector3.Down, .8f, new Vector3(1.1f, 0, 1.8f)),
                                 new WheelDrivingMotor(0, 30000, 10000),
                                 new WheelBrake(0, 0, 0),
                                 new WheelSlidingFriction(0, 0)));
            Vehicle.AddWheel(new Wheel(
                                 new RaycastWheelShape(.375f, wheelGraphicRotation),
                                 new WheelSuspension(2000, 100f, Vector3.Down, .8f, new Vector3(1.1f, 0, -1.8f)),
                                 new WheelDrivingMotor(0, 30000, 10000),
                                 new WheelBrake(0, 0, 0),
                                 new WheelSlidingFriction(0, 0)));
In v1.1, if the environment has low friction, the above will make the vehicle slide uncontrollably around. (In the development version, friction blending is multiplicative by default, so setting the wheel friction to zero makes the combined friction zero.)

If the WheelDrivingMotor grip friction is then changed to a nonzero value, the car will be able to direct itself by applying a drive force.
how come wheels didn't move on 0 friction? And why I can't make rear wheels spin faster that front when I start movement?
The wheels of a Vehicle are not physical. The ray cast vehicle approximates wheels with rays. The rotation of a wheel is based upon the relative velocity at the ray cast intersection point on the support. If the car isn't moving, the 'wheel' isn't rotating. Since the wheel is just a graphical element, you could add in tractionless spin outs externally.
Can You give me a hint about importing models that will work fine with bepu?
There's no single correct content path. The end result should ideally have individual triangles in the numerically reasonable zone described previously. Any export/import process which accomplishes this is acceptable.
Tasaq
Posts: 13
Joined: Mon Mar 26, 2012 4:25 pm

Re: Vehicle physics

Post by Tasaq »

Thank You for your answer :) That's what i expect from help section of a forum :D
So if I want to make a wheel spin (like in burnouts) i need to write some 'hacky' code for wheel animation is that right? Also would it be good idea to add wheels proxy to the space to make it look more natural? :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Vehicle physics

Post by Norbo »

So if I want to make a wheel spin (like in burnouts) i need to write some 'hacky' code for wheel animation is that right?
That's an option, yes. The level of "hackiness" can vary; it doesn't have to be very hacky at all if you'd like to do a little more custom simulation (use the data provided by the fakewheels to simulate the rough dynamics of your own slightlylessfakewheels, which then drive the graphic).

Also would it be good idea to add wheels proxy to the space to make it look more natural?
I wouldn't recommend trying to blend actual Entity wheels and the Vehicle together. It is, however, very possible to create a completely 'real' vehicle; some examples can be found in the demos (SuspensionCarDemo, ReverseTrikeDemo). These 'real' vehicles tend to require a bit more care in configuration since they're a more complicated structure; you may find that the time step duration should be lowered to accommodate the simulation at very high speeds, for example.
Tasaq
Posts: 13
Joined: Mon Mar 26, 2012 4:25 pm

Re: Vehicle physics

Post by Tasaq »

That put a much more light on how does the vehicle class work :) I think I will stick with hack method and maybe later I will implement my own vehicle class :)
Thank You for help and You can count on my recomendation of your tool to other game programmers i know :)
Post Reply