public override CollisionProxy CreateCapsuleCollision(ICapsuleShape shape, int layer = 1, int mask = -1) { CollisionObject co = new CollisionObject(); co.CollisionShape = new CapsuleShape(shape.Radius, shape.Height); world.AddCollisionObject(co, (short)layer, (short)mask); return(new BulletCollision(co, null)); }
void ILeafVisitorOf <ICapsuleShape> .Visit(ICapsuleShape capsuleShape) { IModel model; if (!_allocatedModels.TryGetValue(capsuleShape, out model)) { IModel cylinder = Models.Cylinder.Translated(0, -.5f, 0).Scaled(capsuleShape.Descriptor.Radius, capsuleShape.Descriptor.Height - (capsuleShape.Descriptor.Radius * 2), capsuleShape.Descriptor.Radius); IModel sphere = Models.Sphere.Scaled(capsuleShape.Descriptor.Radius, capsuleShape.Descriptor.Radius, capsuleShape.Descriptor.Radius); float zOffset = capsuleShape.Descriptor.Height / 2 - capsuleShape.Descriptor.Radius; IModel topSphere = sphere.Translated(0, zOffset, 0); IModel bottomSphere = sphere.Translated(0, -zOffset, 0); model = _allocatedModels[capsuleShape] = Models.Group(cylinder, topSphere, bottomSphere).Allocate(_render); } DrawShape(capsuleShape, model); }
public void CopyStateTo(ICapsuleShape element) { element.Descriptor = Descriptor; }
/// <summary> /// Create standard capsule collision /// </summary> /// <param name="shape">capsule shape interface</param> /// <param name="layer">layer of collision</param> /// <param name="mask">mask of collision</param> public abstract CollisionProxy CreateCapsuleCollision(ICapsuleShape shape, int layer = 1, int mask = -1);