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)); }
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); }
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; }
public CollisionVolume(CompositeCollision parent, Vector3 offsetPosition) : this(parent, offsetPosition, 0f) { }
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); }
public CollisionCylinder(CompositeCollision parent, float height, float radius, Vector3 offsetPosition) : base(parent, offsetPosition) { this.Height = height /2f; this.Radius = radius; }