Convex Hulls don't match with center of model
Posted: Tue Jan 03, 2012 7:13 am
Hi Norbo, sorry for all the questions recently
I'm having a strange bug with dynamic physics entities in my game, their models don't match up with the physics entity. It seems as though they aren't correctly centered, however using this fix viewtopic.php?f=4&t=1494&p=8826 doesn't solve my problem.
I'm creating my entity as follows:
(This is my DynamicMapObject class:)
All of my model's scales are 1,1,1, and completely removing scales from the code doesn't remove the bug, either (they still draw the same either with or without Matrix.CreateScale...).
Here is are screenshots of the bug: phys3.jpg, phys4.jpg, phys1.jpg, phys2.jpg
The static physics objects work great, it only appears to be the convex / dynamic shapes that are affected.
Is there a way to fix this offsetting?
Thank you for all of your work on bepu and supporting such a wonderful library

I'm having a strange bug with dynamic physics entities in my game, their models don't match up with the physics entity. It seems as though they aren't correctly centered, however using this fix viewtopic.php?f=4&t=1494&p=8826 doesn't solve my problem.
I'm creating my entity as follows:
Code: Select all
var modelWorld = Matrix.CreateWorld(position, forward, up);
Vector3[] vertices;
int[] indices;
TriangleMesh.GetVerticesAndIndicesFromModel(model, out vertices, out indices);
var convexHull = new ConvexHull(vertices, 1);
//This line doesn't seem to do anything
convexHull.CollisionInformation.LocalPosition = position;
TransformableShape shape = new TransformableShape(convexHull.CollisionInformation.Shape,
Matrix3X3.CreateFromMatrix(modelWorld));
var SpaceObject = new Entity<ConvexCollidable<TransformableShape>>(
new ConvexCollidable<TransformableShape>(shape), 1, convexHull.LocalInertiaTensor, convexHull.Volume);
SpaceObject.Position = position;
SpaceObject.BecomeDynamic(convexHull.Mass);
Engine.PhysicsEngineComponent.Space.Add(SpaceObject);
var dynModel = new DynamicMapObject(model, SpaceObject, scale);
Engine.RenderComponent.SubmitDynamicMapObject(dynModel);
Code: Select all
public class DynamicMapObject
{
public Entity PhysicsEntity;
public SceneObject SceneObject;
public Vector3 ModelScale;
public DynamicMapObject(Model model, Entity obj, Vector3 Scale)
{
this.ModelScale = Scale;
PhysicsEntity = obj;
SceneObject = new SceneObject(model);
}
public void Update()
{
if (SceneObject != null)
{
SceneObject.World = Matrix.CreateScale(ModelScale) * PhysicsEntity.WorldTransform;
}
}
}
Here is are screenshots of the bug: phys3.jpg, phys4.jpg, phys1.jpg, phys2.jpg
The static physics objects work great, it only appears to be the convex / dynamic shapes that are affected.
Is there a way to fix this offsetting?
Thank you for all of your work on bepu and supporting such a wonderful library
