Esempio n. 1
0
 /// <summary>
 /// Creates a new static entity.
 /// </summary>
 /// <param name="position">The position of the static entity.</param>
 /// <param name="orientation">The orientation of the static entity.</param>
 /// <param name="boundingRadius">The bounding radius of the static entity.</param>
 /// <param name="hull">The hull used for collision detection with the static entity.</param>
 public StaticEntity(Vector3 position, Vector3 orientation, float boundingRadius, Hull hull)
     : base(position, orientation, 1.0e10f, boundingRadius, hull, new StaticCollision())
 {
 }
Esempio n. 2
0
 /// <summary>
 /// Create a non-force entity.
 /// </summary>
 /// <param name="position">The initial position of the entity.</param>
 /// <param name="orientation">The initial orientation of the entity.</param>
 /// <param name="mass">The mass of the entity.</param>
 /// <param name="boundingRadius">The bounding radius of the entity.</param>
 /// <param name="hull">The entities collision detection hull.</param>
 /// <param name="collisionHandler">The entities collision handler.</param>
 public NonForceEntity(Vector3 position, Vector3 orientation, float mass, float boundingRadius, Hull hull, CollisionHandler collisionHandler)
     : base(position, orientation, mass, boundingRadius, hull, collisionHandler)
 {
 }
Esempio n. 3
0
        /// <summary>
        /// Test for collisions between two hulls.
        /// </summary>
        /// <param name="left">The first hull to test for collisions.</param>
        /// <param name="leftTransform">The transform taking objects from entity to world space for the left hull.</param>
        /// <param name="right">The second hull to test for collisions.</param>
        /// <param name="rightTransform">The transform taking objects from entity to world space for the right hull.</param>
        /// <returns>The result of the collision or null if no collision is found.</returns>
        public static CollisionResult <ConvexHull> Collided(Hull left, Matrix leftTransform, Hull right, Matrix rightTransform)
        {
            foreach (ConvexHull leftHull in left.convexHulls)
            {
                foreach (ConvexHull rightHull in right.convexHulls)
                {
                    CollisionResult <ConvexHull> result = ConvexHull.Collided(leftHull, leftTransform, rightHull, rightTransform);
                    if (result == null)
                    {
                        result = ConvexHull.Collided(rightHull, rightTransform, leftHull, leftTransform);
                        if (result != null)
                        {
                            result.Normal = -result.Normal;
                        }
                    }

                    return(result);
                }
            }

            return(null);
        }
Esempio n. 4
0
 /// <summary>
 /// Constructs a Entity using some default values.
 /// </summary>
 /// <param name="position">The initial entity position.</param>
 /// <param name="orientation">The initial orientation of the entity.</param>
 /// <param name="mass">The mass of the entity.</param>
 /// <param name="boundingRadius">The bounding radius of the entity.</param>
 /// <param name="hull">The hull used for collision detection.</param>
 /// <param name="collisionHandler">The collision handler to use for collision responce.</param>
 public Entity(Vector3 position, Vector3 orientation, float mass, float boundingRadius, Hull hull, CollisionHandler collisionHandler)
 {
     this._position           = position;
     this.previousPosition    = position;
     this._orientation        = orientation;
     this.previousOrientation = orientation;
     this._mass            = mass;
     this._boundingRadius  = boundingRadius;
     this._hull            = hull;
     this.collisionHandler = collisionHandler;
     this.elapsedTime      = 0.05f;
 }