///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="position">Local position of the shape.</param> ///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner /// for the purposes of center of mass and inertia computation.</param> public CompoundShapeEntry(EntityShape shape, Vector3 position, float weight) { position.Validate(); LocalTransform = new RigidTransform(position); Shape = shape; Weight = weight; }
public virtual EntityShape GetShape(BlockDamage damage, out Location offset, bool shrink) { if ((shrink ? ShrunkBlockShapeCache : BlockShapeCache) != null) { offset = (shrink ? ShrunkOffsetCache : OffsetCache); return (shrink ? ShrunkBlockShapeCache : BlockShapeCache); } List<Vector3> vecs = GetVertices(new Vector3(0, 0, 0), false, false, false, false, false, false); Vector3 offs; if (vecs.Count == 0) { throw new Exception("No vertices for shape " + this); } if (shrink) { for (int i = 0; i < vecs.Count; i++) { vecs[i] = (vecs[i] - new Vector3(0.5f, 0.5f, 0.5f)) * SHRINK_CONSTANT + new Vector3(0.5f, 0.5f, 0.5f); } } ConvexHullShape shape = new ConvexHullShape(vecs, out offs) { CollisionMargin = 0 }; offset = new Location(offs); if (shrink) { ShrunkBlockShapeCache = shape; ShrunkOffsetCache = offset; } else { BlockShapeCache = shape; OffsetCache = offset; } return shape; }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="localTransform">Local transform of the shape.</param> ///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner /// for the purposes of center of rotation computation.</param> public CompoundShapeEntry(EntityShape shape, RigidTransform localTransform, float weight) { localTransform.Validate(); LocalTransform = localTransform; Shape = shape; Weight = weight; }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="orientation">Local orientation of the shape.</param> ///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner /// for the purposes of center of rotation computation.</param> public CompoundShapeEntry(EntityShape shape, Quaternion orientation, float weight) { orientation.Validate(); LocalTransform = new RigidTransform(orientation); Shape = shape; Weight = weight; }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="orientation">Local orientation of the shape.</param> public CompoundShapeEntry(EntityShape shape, Quaternion orientation) { LocalTransform = new RigidTransform(orientation); Shape = shape; Weight = shape.ComputeVolume(); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner /// for the purposes of center of rotation computation.</param> public CompoundShapeEntry(EntityShape shape, float weight) { LocalTransform = RigidTransform.Identity; Shape = shape; Weight = weight; }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="position">Local position of the shape.</param> public CompoundShapeEntry(EntityShape shape, Vector3 position) { LocalTransform = new RigidTransform(position); Shape = shape; Weight = shape.ComputeVolume(); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="position">Local position of the shape.</param> public CompoundShapeEntry(EntityShape shape, Vector3 position) { position.Validate(); LocalTransform = new RigidTransform(position); Shape = shape; Weight = shape.ComputeVolume(); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="position">Local position of the shape.</param> public CompoundShapeEntry(EntityShape shape, System.Numerics.Vector3 position) { position.Validate(); LocalTransform = new RigidTransform(position); Shape = shape; Weight = shape.Volume; }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="localTransform">Local transform of the shape.</param> ///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner /// for the purposes of center of rotation computation.</param> public CompoundShapeEntry(EntityShape shape, RigidTransform localTransform, float weight) { LocalTransform = localTransform; Shape = shape; Weight = weight; }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="orientation">Local orientation of the shape.</param> ///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner /// for the purposes of center of rotation computation.</param> public CompoundShapeEntry(EntityShape shape, Quaternion orientation, float weight) { LocalTransform = new RigidTransform(orientation); Shape = shape; Weight = weight; }
///<summary> /// Constructs a new entity. ///</summary> ///<param name="shape">Shape to use with the entity.</param> ///<param name="mass">Mass of the entity. If positive, the entity will be dynamic. Otherwise, it will be kinematic.</param> /// <param name="inertiaTensor">Inertia tensor of the entity. Only used for a dynamic entity.</param> public Entity(EntityShape shape, float mass, Matrix3x3 inertiaTensor) : this() { Initialize(shape.GetCollidableInstance(), mass, inertiaTensor); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="localTransform">Local transform of the shape.</param> public CompoundShapeEntry(EntityShape shape, RigidTransform localTransform) { localTransform.Validate(); LocalTransform = localTransform; Shape = shape; Weight = shape.Volume; }
///<summary> /// Constructs a new kinematic entity. ///</summary> ///<param name="shape">Shape to use with the entity.</param> public Entity(EntityShape shape) : this() { Initialize(shape.GetCollidableInstance()); }
///<summary> /// Constructs a new entity. ///</summary> ///<param name="shape">Shape to use with the entity.</param> ///<param name="mass">Mass of the entity. If positive, the entity will be dynamic. Otherwise, it will be kinematic.</param> public Entity(EntityShape shape, float mass) : this() { Initialize(shape.GetCollidableInstance(), mass); }
protected EntityCollidable(EntityShape shape) { base.Shape = shape; }
///<summary> /// Gets the volume distribution contributed by a single shape. ///</summary> ///<param name="shape">Shape to use to compute a contribution.</param> ///<param name="transform">Transform of the shape.</param> ///<param name="center">Center to use when computing the distribution.</param> ///<param name="weight">Weighting to apply to the contribution.</param> ///<param name="contribution">Volume distribution of the contribution.</param> public static void GetContribution(EntityShape shape, ref RigidTransform transform, ref Vector3 center, float weight, out Matrix3x3 contribution) { contribution = shape.ComputeVolumeDistribution(); TransformContribution(ref transform, ref center, ref contribution, weight, out contribution); //return TransformContribution(ref transform, ref center, ref contribution, weight); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="orientation">Local orientation of the shape.</param> public CompoundShapeEntry(EntityShape shape, Quaternion orientation) { orientation.Validate(); LocalTransform = new RigidTransform(orientation); Shape = shape; Weight = shape.ComputeVolume(); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> public CompoundShapeEntry(EntityShape shape) { LocalTransform = RigidTransform.Identity; Shape = shape; Weight = shape.ComputeVolume(); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> public CompoundShapeEntry(EntityShape shape) { LocalTransform = RigidTransform.Identity; Shape = shape; Weight = shape.Volume; }
///<summary> /// Gets the volume distribution contributed by a single shape. ///</summary> ///<param name="shape">Shape to use to compute a contribution.</param> ///<param name="transform">Transform of the shape.</param> ///<param name="center">Center to use when computing the distribution.</param> ///<param name="weight">Weighting to apply to the contribution.</param> ///<param name="contribution">Volume distribution of the contribution.</param> public static void GetContribution(EntityShape shape, ref RigidTransform transform, ref Vector3 center, float weight, out Matrix3X3 contribution) { contribution = shape.ComputeVolumeDistribution(); TransformContribution(ref transform, ref center, ref contribution, weight, out contribution); //return TransformContribution(ref transform, ref center, ref contribution, weight); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="localTransform">Local transform of the shape.</param> public CompoundShapeEntry(EntityShape shape, RigidTransform localTransform) { LocalTransform = localTransform; Shape = shape; Weight = shape.ComputeVolume(); }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="position">Local position of the shape.</param> ///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner /// for the purposes of center of mass and inertia computation.</param> public CompoundShapeEntry(EntityShape shape, Vector3 position, float weight) { LocalTransform = new RigidTransform(position); Shape = shape; Weight = weight; }
///<summary> /// Constructs a new morphable entity. ///</summary> ///<param name="shape">Shape to use with the entity.</param> ///<param name="mass">Mass of the entity.</param> public MorphableEntity(EntityShape shape, float mass) : base(shape, mass) { }
///<summary> /// Constructs a new compound shape entry using the volume of the shape as a weight. ///</summary> ///<param name="shape">Shape to use.</param> ///<param name="orientation">Local orientation of the shape.</param> public CompoundShapeEntry(EntityShape shape, System.Numerics.Quaternion orientation) { orientation.Validate(); LocalTransform = new RigidTransform(orientation); Shape = shape; Weight = shape.Volume; }
///<summary> /// Constructs a new morphable entity. ///</summary> ///<param name="shape">Shape to use with the entity.</param> public MorphableEntity(EntityShape shape) : base(shape) { }
///<summary> /// Constructs a new morphable entity. ///</summary> ///<param name="shape">Shape to use with the entity.</param> ///<param name="mass">Mass of the entity.</param> /// <param name="inertiaTensor">Inertia tensor of the entity.</param> public MorphableEntity(EntityShape shape, float mass, Matrix3X3 inertiaTensor) : base(shape, mass, inertiaTensor) { }
///<summary> /// Constructs a new morphable entity. ///</summary> ///<param name="shape">Shape to use with the entity.</param> ///<param name="mass">Mass of the entity.</param> /// <param name="inertiaTensor">Inertia tensor of the entity.</param> /// <param name="volume">Volume of the entity.</param> public MorphableEntity(EntityShape shape, float mass, Matrix3x3 inertiaTensor, float volume) : base(shape, mass, inertiaTensor, volume) { }