Here is a photo to let you know exactly what is happening, the character floats slightly above the truck bed:

I can also walk through the cab:

Here is the code where I construct the object:
Code: Select all
BepuEntity creatBarrel(Vector3 position, float mass)
{
BepuEntity bar = new BepuEntity();
bar.modelName = "Levels\\Test\\untitled"; //The truck model
bar.diffName = "Levels\\Test\\TruckR"; //Diffuse texture
bar.normName = "Levels\\Test\\TruckRNrml"; //Normal texture
bar.specName = "Levels\\Test\\TruckRNrml"; //Specular
bar.LoadContent(); //Loads the model and textues
TriangleMesh.GetVerticesAndIndicesFromModel(bar.model, out vertices, out indices);
//for (int i = 0; i < vertices.Length; i++)
// vertices[i] = Vector3.Transform(vertices[i], Matrix.CreateScale(1 - 0.01f)); //I tried the graphics matching solution I found on the forums, didn't work.
bar.body = new ConvexHull(vertices, 10);
bar.localGraphicsTransform = Matrix.CreateTranslation(-bar.body.Position);//.body.Position
bar.body.Position = position;
bar.Position = position;// position;
bar.configureEvents();
space.Add(bar.body);
bar.body.BecomeKinematic();
children.Add(bar);
return bar;
}
Code: Select all
public override void Update(GameTime gameTime) //This is called for all BEPU objects in the game.
{
//Console.WriteLine(body.WorldTransform.Translation.ToString());
worldTransform = localGraphicsTransform * body.WorldTransform;
}