Code: Select all
var collisionConfig = new BulletSharp.DefaultCollisionConfiguration();
PhysicsWorld = new BulletSharp.DiscreteDynamicsWorld(
new BulletSharp.CollisionDispatcher(collisionConfig),
new BulletSharp.DbvtBroadphase(),
new BulletSharp.SequentialImpulseConstraintSolver(),
collisionConfig);
Code: Select all
public void SetCollisionBox(Vector3 center, Vector3 scale)
{
SetBody(new BoxShape(0.5f), center, scale);
}
private void SetBody(CollisionShape shape, Vector3 center, Vector3 scale)
{
Center = center;
ClearBody();
RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(1, new DefaultMotionState(Matrix4.CreateTranslation(Transform.Position) + Transform.Rotation.ToMatrix4()), shape);
Body = new RigidBody(info);
Body.CollisionShape.LocalScaling = scale;
GameObject.App.PhysicsWorld.AddRigidBody(Body);
}
Code: Select all
public void MakeStatic()
{
if (Body != null)
Body.SetMassProps(0, Vector3.Zero);
}