/*******************************
         * INICIALIZACION **************
         *******************************/

        public Character(Vector3 _position)
        {
            this.loadCharacterRepresentation(_position);
            this.technique = representation.Technique;
            this.Effect = TgcShaders.loadEffect(CommandosUI.Instance.ShadersDir + "shaders.fx");
            this.Selected = false;
            this.Dead = false;
            this.SelectionColor = Color.Red;
            this.life = new Life(this, 100, new Vector2(20, 60), Color.Red, new Vector2(60, 10));
            this.speed = DEFAULT_SPEED;
            
            Vector3 boundingSize = this.Representation.BoundingBox.calculateSize() * 0.5f;
            this.boundingCylinder = new CommandosCylinder(this.Representation.BoundingBox.calculateBoxCenter(), boundingSize.Y, boundingSize.X);
        
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            CommandosUI.Instance.Camera = new TgcCameraAdapter(new StandardCamera());

            //this.lastPos = new Vector3(0, 0, 0);
            //GuiController.Instance.Modifiers.addVertex3f("posicion", new Vector3(-200, 0, -200), new Vector3(200, 0, 200), this.lastPos);

            this.userCylinder = new CommandosCylinder(CommandosUI.Instance.Camera.getLookAt(), 40, 20, Color.Yellow);

            this.staticSphere = new TgcBoundingSphere(new Vector3(200, 0, -200), 40);
            this.staticCylinder = new CommandosCylinder(new Vector3(-100, 0, 0), 40, 40, Color.Yellow);
            this.staticAABB = new TgcBoundingBox(new Vector3(0, -40, -200), new Vector3(80, 40, -120));

            //GuiController.Instance.Modifiers.addBoolean("closestPoint", "closestPoint", false);

            this.colisionNormal = new TgcArrow();
            this.colisionNormal.Thickness = 2f;
            this.colisionNormal.HeadSize = new Vector2(4f, 4f);
            this.colisionNormal.Enabled = true;
        }
 /// <summary>
 /// Indica si existe colision con otro cilindro. En tal caso devuelve la normal de colision.
 /// </summary>
 public bool thereIsCollisionCyCy(CommandosCylinder collider, out Vector3 n)
 {
     Vector3 distance = collider.Center - this.Center;
     if (FastMath.Pow2(distance.X) + FastMath.Pow2(distance.Z) <= FastMath.Pow2(this.radius + collider.radius))
     {
         n = Vector3.Cross(distance, this.halfHeight);
         n = Vector3.Cross(n, this.halfHeight);
         n.Normalize();
         return true;
     }
     else
     {
         n = Vector3.Empty;
         return false;
     }
 }
 public void switchCrouch()
 {
     if (!this.dead)
     {
         this.Representation.switchCrouch();
         Vector3 boundingSize = this.Representation.BoundingBox.calculateSize() * 0.5f;
         this.boundingCylinder = new CommandosCylinder(this.Representation.BoundingBox.calculateBoxCenter(), boundingSize.Y, boundingSize.X);
     }
 }
 public bool collidesWith(CommandosCylinder cyl, out Vector3 n)
 {
     return this.boundingCylinder.thereIsCollisionCyCy(cyl, out n);
 }