using JigLibX.Collision;
using JigLibX.Geometry;
using Microsoft.Xna.Framework;

namespace Innovation
{
    // A sphere physics object
    public class SphereObject : PhysicsObject
    {
        // The radius of the sphere
        public float Radius
        {
            get { return ((Sphere)CollisionSkin.GetPrimitiveLocal(0)).Radius; }
            set { SetupSkin(value); }
        }

        // Constructors

        public SphereObject() : base()
        {
            InitializeBody();
            SetupSkin(1);
        }

        public SphereObject(float Radius)
        {
            InitializeBody();
            SetupSkin(Radius);
        }

        public SphereObject(float Radius, Vector3 Position, Vector3 Rotation)
            : base()
        {
            InitializeBody();
            SetupSkin(Radius);
            this.Position = Position;
            this.EulerRotation = Rotation;
        }

        // Sets up the object
        void SetupSkin(float Radius)
        {
            CollisionSkin.RemoveAllPrimitives();
            CollisionSkin.AddPrimitive(new Sphere(Vector3.Zero, Radius),
                (int)MaterialTable.MaterialID.UserDefined,
                PhysicsMaterial);
        }
    }
}
