Ah ok, i created an CompoundShape and all all the tiles into this shape. It get debuged wrong but behaves like it should
This is my code atm
public void CreateRigidBody(float mass, PhysicHandler handler)
{
if (this.Parent.GetType() == typeof(BufferedSprite))
{
var bufferedSprite = (BufferedSprite)this.Parent;
//var Childshape = new ConvexHullShape(bufferedSprite.Verticies.ToArray());
//var shape = new Convex2DShape(Childshape);
var mesh = new TriangleMesh();
CompoundShape compoundShape = new CompoundShape(true);
foreach(var deffinition in bufferedSprite.ShapeDeffinitions)
{
Box2DShape box2DShape = new Box2DShape(new Vector3(deffinition.sizeX, deffinition.sizeY, 0f) / 2);
BulletSharp.Math.Matrix boxtransform = BulletSharp.Math.Matrix.Translation(new Vector3(deffinition.locX, deffinition.locY, 0f));
compoundShape.AddChildShape(boxtransform, box2DShape);
//Vector3 v1 = new Vector3(deffinition.verticies[0], deffinition.verticies[1], deffinition.verticies[2]);
//Vector3 v2 = new Vector3(deffinition.verticies[3], deffinition.verticies[4], deffinition.verticies[5]);
//Vector3 v3 = new Vector3(deffinition.verticies[6], deffinition.verticies[7], deffinition.verticies[8]);
//mesh.AddTriangle(v1, v2, v3, true);
//v1 = new Vector3(deffinition.verticies[0], deffinition.verticies[1], deffinition.verticies[2]);
//v2 = new Vector3(deffinition.verticies[3], deffinition.verticies[4], deffinition.verticies[5]);
//v3 = new Vector3(deffinition.verticies[6], deffinition.verticies[7], deffinition.verticies[8]);
//mesh.AddTriangle(v1, v2, v3, true);
}
//ConvexTriangleMeshShape shape = new ConvexTriangleMeshShape(mesh, true);
//var shape = new Convex2DShape(meshShape);
RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(mass, null, compoundShape, compoundShape.CalculateLocalInertia(mass));
BulletSharp.Math.Matrix transform = BulletSharp.Math.Matrix.Translation(bufferedSprite.Location.ToBulletVec3());
Matrix startTransform = transform;
info.MotionState = new DefaultMotionState(startTransform);
RigidBody = new BulletSharp.RigidBody(info);
RigidBody.UserObject = this.Parent;
RigidBody.LinearFactor = this.LinearFactor.ToBulletVec3();
RigidBody.AngularFactor = this.AngularFactor.ToBulletVec3();
RigidBody.CollisionFlags = CollisionFlags.StaticObject;
handler.ManageElement(this);
}
else
{
throw new InvalidOperationException("Invalid element for this Behavior");
}
}