Vehicle Bugs

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Domino
Posts: 8
Joined: Fri Aug 01, 2008 3:44 am

Vehicle Bugs

Post by Domino »

Hi,
i have some problems with bepuphysics vehicle class, i tried to set suspension and everything but the wheel seems to go through the terrain. While the wheel doesnt even touch the ground, its the vehicles chassis that "rolls" like if there were wheels in it. Another problem i have with it is that when the wheels doesnt touch the ground, they wont move even if i accelerate, and thats not very realistic. Could someone explain me the different settings of the vehicle, or how i could make my own vehicle class? Thanks.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Vehicle Bugs

Post by Norbo »

The wheel's rotation (and position for that matter) is purely a graphical effect. This can be managed separately from the engine's systems. In v0.6.1, this is a little easier to do since the wheels provide more information. I'm planning on releasing v0.6.1 in the very near future, as well.
Domino wrote:i tried to set suspension and everything but the wheel seems to go through the terrain. While the wheel doesnt even touch the ground, its the vehicles chassis that "rolls" like if there were wheels in it.
I can't quite visualize the problem here; could you provide some demo code or screenshots/videos?


Here's a general overview of how the vehicle is set up, maybe it can help with your issue. The VehicleInput.cs in the demos shows the setup in detail.

The vehicle constructor itself establishes the shape of vehicle by giving it an entity and maximum speeds. Most of the parameter tweaking is in the wheels, two types of which exist. Raycast wheels are simpler in function and can be slightly more speedy, but are otherwise very similar to the convex cast wheels. Convex cast wheels won't fall into small holes like a raycast wheel would, giving a slightly better appearance.

Code: Select all

            vehicle.addWheel(new ConvexCastWheel(new Vector3(-1.3f, -.1f, 2.14f), initialWheelRotation,
                  wheelShape, .5f, new Vector3(0, -1, 0), new Vector3(0, 0, 1), .6f, .7f, .8f, .02f, .5f, 500, .8f, .375f));
Here the wheel is added to the vehicle; the paramaters in order correspond to:
  • * new Vector3(-1.3f, -.1f, 2.14f): Offset from the center of the vehicle's body to the wheel's connection point. This is the top of the suspension- the wheel itself will be further down the suspension when at rest.
    * initialWheelRotation: Default rotation applied to wheel's shape. For example, under identity orientation, a cylinder has its height parallel to the Y axis. For the vehicle, I wanted this to be horizontal, so I rotated it by 90 degrees.
    * wheelShape: Shape of the wheel for casting. I used a cylinder here.
    * .5f: Interestingly enough, this parameter does nothing. It was a little oopsy left in from some refactoring; it will be gone in v0.6.1 :P The final 'rad' parameter will be removed, and this one will replace it as the correct parameter.
    * new Vector3(0, -1, 0): Suspension direction. Here, it points from the suspension connection defined by the first parameter down. This is only direction, not length.
    * new Vector3(0, 0, 1): This is the direction in local space that the wheel rolls along. I built the car to move along the Z axis in local space, so the forward vector is positive Z.
    * .6f: Length of the suspension. This is how far along the suspension direction the wheel will travel while bumping along.
    * .7f: Stiffness of the suspension. This is just how hard the springs correct the position error in the spring.
    * .8f: Friction coefficient to apply to motion perpendicular to the rolling direction. This is the component which counteracts sliding.
    * .02f: Rolling friction. Generally a low value is good here; this simulates general friction present when the car is moving and will slowly slow the car down when no other force is applied.
    * .5f: Friction coefficient to apply to motion parallel to the rolling direction. High values enable low 'slippage' and fast velocity changes. I should note that slippage is not directly modeled; the default graphics behave as nothing slips. This could be added in as an extra effect, however.
    * 500: Maximum force that the suspension can apply- this is helpful for having stiffness yet avoiding explosive behavior.
    * .8: Damping applied to the suspension spring. This is approximately the fraction of momentum removed during a second, though there remains some unpleasantness in terms of damping scaling with different length timesteps (it would require a re-tweaking for identical behavior, something I would like to address in future versions).
    * 375f: Radius of the wheel for purposes of angular velocity calculations, just in case your shape isn't a cylinder or your graphic is somewhat different. Here I just matched the cylinder's radius and made the model fit.
Domino
Posts: 8
Joined: Fri Aug 01, 2008 3:44 am

Re: Vehicle Bugs

Post by Domino »

Hi,

Well i just tried copiying the whole vehicle from the demo, it originally worked, but the world of my game is 10x bigger so i tried multiplying the cars settings and gravity 10 times but the suspension is not stiff enough, the chassis touches the ground.

Thanks for the information on the car settings, now i will be able to set this up :)

Another problem i currently have, while its not very important, is the loading time of my map (the map is very big and have just enough polygons, it takes 15secs to load) is there some way to speed it up or to save the physics information and load it?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Vehicle Bugs

Post by Norbo »

At some point I plan to incorporate saving and loading for the heavy duty load times (bounding volume hierarchy initialization of the static triangle group being a big one). This might make its way into v0.7.0, though it's hard to say for sure.

Just curious though, how many triangles are in your world approximately, and what kind of CPU do you have?
Domino
Posts: 8
Joined: Fri Aug 01, 2008 3:44 am

Re: Vehicle Bugs

Post by Domino »

266256 Vertices and 524288 Faces, i know it is a lot but optimizing it a bit would make the driving to bumpy and the map very ugly, and i am running it on a AMD Athlon64 dual core on windows 32bits (x86), i can get around 400fps viewing my map with my nvidia geforce 8800gt so its pretty good.

Edit: I am thinking on making a dynamic loading of the map around the vehicles position, is there a way i could load only certain meshes of a model?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Vehicle Bugs

Post by Norbo »

You could create separate StaticTriangleGroups from the individual meshes, yes; from a runtime speed perspective though it's somewhat faster to keep them all together for the most part.

I'll see what I can do to make the loading times more manageable in future versions.
Domino
Posts: 8
Joined: Fri Aug 01, 2008 3:44 am

Re: Vehicle Bugs

Post by Domino »

Thanks, now i have to go to sleep :wink:. Ill try and make the driving as best as i can tomorrow.
Post Reply