/// <summary> /// Constructs a new demo. /// </summary> /// <param name="game">Game owning this demo.</param> public GeneralConvexPairStressDemo(DemosGame game) : base(game) { Space.Remove(vehicle.Vehicle); //Enable simplex caching. ConfigurationHelper.ApplySuperSpeedySettings(Space); for (int i = 0; i < 2000; i++) { EntityShape shape; switch (i % 3) { case 0: shape = new CylinderShape(0.5f + (float)random.NextDouble() * 1.5f, 0.5f + (float)random.NextDouble() * 1.5f); break; case 1: shape = new ConeShape(0.5f + (float)random.NextDouble() * 1.5f, 0.5f + (float)random.NextDouble() * 1.5f); break; default: shape = new CapsuleShape(0.5f + (float)random.NextDouble() * 1.5f, 0.5f + (float)random.NextDouble() * 1.5f); break; } var toAdd = new Entity(shape, 2); //toAdd.LocalInertiaTensorInverse = new BEPUutilities.Matrix3x3(); RandomizeEntityState(toAdd); Space.Add(toAdd); } Space.ForceUpdater.Gravity = new Vector3(); game.Camera.Position = new Vector3(0, 6, 15); }
/// <summary> /// Creates a new cylinder cast based wheel shape. /// </summary> /// <param name="radius">Radius of the wheel.</param> /// <param name="width">Width of the wheel.</param> /// <param name="localWheelOrientation">Unsteered orientation of the wheel in the vehicle's local space.</param> /// <param name="localGraphicTransform">Local graphic transform of the wheel shape. /// This transform is applied first when creating the shape's worldTransform.</param> /// <param name="includeSteeringTransformInCast">Whether or not to include the steering transform in the wheel shape cast. If false, the casted wheel shape will always point straight forward. /// If true, it will rotate with steering. Sometimes, setting this to false is helpful when the cast shape would otherwise become exposed when steering.</param> public CylinderCastWheelShape(float radius, float width, Quaternion localWheelOrientation, Matrix localGraphicTransform, bool includeSteeringTransformInCast) { shape = new CylinderShape(width, radius); this.LocalWheelOrientation = localWheelOrientation; LocalGraphicTransform = localGraphicTransform; this.IncludeSteeringTransformInCast = includeSteeringTransformInCast; }
public GrenadeEntity(Region tregion) : base(tregion) { Shape = new CylinderShape(0.2f, 0.05f); Bounciness = 0.95f; SetMass(1); }
public GrenadeEntity(Region tregion, bool shadows) : base(tregion, true, shadows) { model = TheClient.Models.Sphere; GColor = new Color4(0f, 0f, 0f, 1f); Shape = new CylinderShape(0.2f, 0.05f); Bounciness = 0.95f; SetMass(1); }
public CharacterControllerConvexCast() { Body = new Capsule(Vector3.Zero, 1.7f, .3f, 10); //Making the character a continuous object prevents it from flying through walls which would be pretty jarring from a player's perspective. Body.PositionUpdateMode = PositionUpdateMode.Continuous; Body.LocalInertiaTensorInverse = new Matrix3X3(); Body.CollisionInformation.Events.CreatingPair += RemoveFriction; GlueSpeed = 20; StepHeight = 1; //construct the casting shape. It should be a little smaller than the character's radius. castShape = new CylinderShape(0, Body.Radius * .8f); castShape.CollisionMargin = 0; }
/// <summary> /// Constructs a simple character controller. /// </summary> /// <param name="position">Location to initially place the character.</param> /// <param name="characterHeight">The height of the character.</param> /// <param name="characterWidth">The diameter of the character.</param> /// <param name="mass">Total mass of the character.</param> /// <param name="maximumStepHeight">Height that the character can climb up.</param> public CharacterControllerOld(Vector3 position, float characterHeight, float characterWidth, float mass, float maximumStepHeight) { //Create the physical body of the character. //The character's cylinder height and radius must be shrunk down marginally //to take into account the collision margin and support margin while still fitting in the defined character height/width. var bodyPosition = new Vector3(position.X, position.Y + supportMargin / 2, position.Z); float collisionMargin = .04f; Body = new Cylinder(bodyPosition, characterHeight - 2 * collisionMargin - supportMargin, characterWidth / 2 - collisionMargin, mass); Body.CollisionInformation.Shape.CollisionMargin = collisionMargin; feetCollisionPairCollectorPositionOffset = new Vector3(0, -Body.Height / 2 - supportMargin - collisionMargin, 0); feetCollisionPairCollector = new Box(bodyPosition + feetCollisionPairCollectorPositionOffset, characterWidth, maximumStepHeight * 2, characterWidth, 1); feetCollisionPairCollector.CollisionInformation.CollisionRules.Personal = CollisionRule.NoNarrowPhaseUpdate; //Prevents collision detection/contact generation from being run. feetCollisionPairCollector.IsAffectedByGravity = false; CollisionRules.AddRule(feetCollisionPairCollector, Body, CollisionRule.NoBroadPhase);//Prevents the creation of any collision pairs between the body and the collector. feetSupportFinderOffset = new Vector3(0, feetCollisionPairCollectorPositionOffset.Y + maximumStepHeight, 0); headCollisionPairCollectorPositionOffset = new Vector3(0, (Body.Height + maximumStepHeight) / 2 + collisionMargin, 0); headCollisionPairCollector = new Box(bodyPosition + headCollisionPairCollectorPositionOffset, characterWidth, maximumStepHeight + collisionMargin, characterWidth, 1); headCollisionPairCollector.CollisionInformation.CollisionRules.Personal = CollisionRule.NoNarrowPhaseUpdate; //Prevents collision detection/contact generation from being run. headCollisionPairCollector.IsAffectedByGravity = false; CollisionRules.AddRule(headCollisionPairCollector, Body, CollisionRule.NoBroadPhase); //Prevents the creation of any collision pairs between the body and the collector. headBlockageFinderOffset = new Vector3(0, headCollisionPairCollectorPositionOffset.Y - maximumStepHeight / 2 - collisionMargin, 0); castingShape = new CylinderShape(0, Body.Radius + collisionMargin); castingShape.CollisionMargin = 0; this.maximumStepHeight = maximumStepHeight; this.supportMargin = .01f; Body.LocalInertiaTensorInverse = new Matrix3X3(); feetCollisionPairCollector.LocalInertiaTensorInverse = new Matrix3X3(); headCollisionPairCollector.LocalInertiaTensorInverse = new Matrix3X3(); }