#region File Description //----------------------------------------------------------------------------- // CollideSphere.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; #endregion namespace RobotGameData.Collision { /// /// It's a collision sphere. /// public class CollideSphere : CollideElement { #region Fields /// /// local center of the bounding sphere /// protected Vector3 localCenter = Vector3.Zero; /// /// Bounding sphere /// protected BoundingSphere boundingSphere; #endregion #region Properties public BoundingSphere BoundingSphere { get { return boundingSphere; } } public Vector3 LocalCenter { get { return localCenter; } } public Vector3 WorldCenter { get { return BoundingSphere.Center; } } /// /// Collision Radius of this sphere /// public float Radius { get { return BoundingSphere.Radius; } } #endregion /// /// Constructor. /// /// center position of the sphere /// radius of the sphere public CollideSphere(Vector3 center, float radius) : base() { localCenter = center; boundingSphere = new BoundingSphere(localCenter, radius); } /// /// Transform the bounding sphere. /// public override void Transform(Matrix matrix) { boundingSphere.Center = Vector3.Transform(localCenter, matrix); matrix.Translation = boundingSphere.Center; base.Transform(matrix); } } }