Exemple #1
0
        public CollisionVolume(CompositeCollision parent, Vector3 offsetPosition, float offsetYaw)
        {
            this.parent = parent;
            this.dimensions = new Vector3();

            this.offsetPosition = offsetPosition;
            this.offsetYaw = offsetYaw;

            this.cachedYaw = parent.Rotation;

            this.cachedRotatedOffsetPosition = new Vector3(
                offsetPosition.X * (float)Math.Cos((double)parent.Rotation) + offsetPosition.Z * (float)Math.Sin((double)parent.Rotation),
                offsetPosition.Y,
                offsetPosition.Z * (float)Math.Cos((double)parent.Rotation) + offsetPosition.X * (float)Math.Sin((double)parent.Rotation));
        }
Exemple #2
0
        public CompositeModel(Model model, Vector3 position, Matrix rotation)
        {
            this.model = model;
            this.Meshes = model.Meshes;
            this.position = position;
            this.rotation = rotation;

            //findme
            if (r == null)
            {
                r = new Random();
            }

            this.customColor = new Color((float)r.NextDouble(), (float)r.NextDouble(), (float)r.NextDouble());

            this.scale = 1.0f;

            this.collisionCollection = new CompositeCollision(this.parent,this.position, this.rotation);
        }
Exemple #3
0
        public CollisionEvent intersects(CompositeCollision other)
        {
            if (this.BoundingVolume.intersects(other.BoundingVolume) == Vector3.Zero)
            {
                return null;
            }

            Vector3 resolve = Vector3.Zero;
            foreach (CollisionVolume selfVolume in volumes)
            {

                foreach (CollisionVolume otherVolume in other.volumes)
                {
                    resolve += selfVolume.intersects(otherVolume);
                }
            }

            if (resolve != Vector3.Zero)
            {
                return new CollisionEvent(this.parent, resolve);
            }

            return null;
        }
Exemple #4
0
 public CollisionVolume(CompositeCollision parent, Vector3 offsetPosition)
     : this(parent, offsetPosition, 0f)
 {
 }
Exemple #5
0
 public CollisionBox(CompositeCollision parent, Vector3 dimensions, Vector3 offsetPosition, float yaw)
     : base(parent, offsetPosition, yaw)
 {
     this.dimensions = new Vector3(dimensions.X /2f, dimensions.Y /2f, dimensions.Z /2f);
 }
Exemple #6
0
 public CollisionCylinder(CompositeCollision parent, float height, float radius, Vector3 offsetPosition)
     : base(parent, offsetPosition)
 {
     this.Height = height /2f;
     this.Radius = radius;
 }