Changing location of wheels on a vehicle

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Rusty8521
Posts: 10
Joined: Mon Jul 02, 2012 9:10 pm

Changing location of wheels on a vehicle

Post by Rusty8521 »

Is it possible to change the location of the wheels of the wheels from the vehicleInput class?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Changing location of wheels on a vehicle

Post by Norbo »

Yup. The WheelSuspension constructor takes the location of the wheel in vehicle body local space.

It can also be adjusted post-construction by changing the Wheel.Suspension.LocalAttachmentPoint.
Rusty8521
Posts: 10
Joined: Mon Jul 02, 2012 9:10 pm

Re: Changing location of wheels on a vehicle

Post by Rusty8521 »

Thanks! I can't believe I didn't see that before. I have another question about the vehicle. I tried to make a MobileMesh as the body of the car but in most cases the car either doesn't move, or the wheels start to bounce around and glitch into the surface they are on. Can I not use a MobileMesh for the body?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Changing location of wheels on a vehicle

Post by Norbo »

A MobileMesh, or any entity, should work fine for a vehicle body.

The mesh used to create the MobileMesh may have inconsistent winding or the MobileMesh may be given the wrong winding. If it's using Counterclockwise sidedness, try Clockwise sidedness. If both fail, try using DoubleSided. If DoubleSided works but both one-sided options fail, the mesh likely has inconsistent winding.

If the car cannot move at all, make sure the entity was created with mass. Entities created without mass are kinematic.

Here's a part of the VehicleInput constructor modified to use a MobileMesh:

Code: Select all

            Vector3[] vertices;
            int[] indices;
            TriangleMesh.GetVerticesAndIndicesFromModel(wheelModel, out vertices, out indices);
            var body = new MobileMesh(vertices, indices, new AffineTransform(Matrix3X3.CreateScale(5, 2, 9), new Vector3(0, 0, 0)), MobileMeshSolidity.Counterclockwise, 61);
By the way, it's typically better to approximate the shape with simpler objects. For example, if the shape can be represented by a few boxes in a CompoundBody, that will be a lot faster than a MobileMesh of 1000 triangles. A CompoundShape of a few ConvexHullShapes is a good midpoint between source fidelity and performance. However, the vertex data used to create the ConvexHullShapes would ideally be simplified compared to the graphical version to avoid unnecessary cost.
Rusty8521
Posts: 10
Joined: Mon Jul 02, 2012 9:10 pm

Re: Changing location of wheels on a vehicle

Post by Rusty8521 »

By changing the MobileMeshSolidty to Counterclockwise I got the bouncing and the glitching to stop, but the car still won't move. The wheels turn and rotate when I attempt to move but the car goes nowhere. When the car is inactive I can push the car around a little bit so I know it can be moved.

Here is the code I'm using to get the initialize the mobile mesh.

Model bmw = Content.Load<Model>("bmwCollision");
TriangleMesh.GetVerticesAndIndicesFromModel(bmw, out vertices, out indices);

MobileMesh bwmBody = new MobileMesh(vertices, indices, new AffineTransform(new Vector3(0, 0, 0)), MobileMeshSolidity.Counterclockwise, 61);
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Changing location of wheels on a vehicle

Post by Norbo »

Do the wheels reach the ground?
Rusty8521
Posts: 10
Joined: Mon Jul 02, 2012 9:10 pm

Re: Changing location of wheels on a vehicle

Post by Rusty8521 »

That was it. It took some messing with the local position too, but it seems to be function now thank you!
Post Reply