public CharacterControllerInput(IScene scene, Vector3 position, float characterHeight, float characterWidth, float mass, Vector3 scale,float Yalignement = 0)
     : base(scene)
 {
     Characterobj = new CharacterObject(position, Matrix.Identity, characterHeight, characterWidth, mass, 1f, scale, Yalignement);
     this.Start();
     
 }
        public BallThrowBepu(IScene scene, GraphicFactory factory, GestureType type)
            : base(scene)
        {
            this.Start();
            this.factory = factory;
            _mundo = scene.World;

            SimpleConcreteGestureInputPlayable SimpleConcreteGestureInputPlayable = new SimpleConcreteGestureInputPlayable(type,
               (sample) =>
               {
                   IObject physObj = SpawnPrimitive(_mundo.CameraManager.ActiveCamera.Position, Matrix.CreateRotationX(0.5f));
                   physObj.PhysicObject.Velocity = (_mundo.CameraManager.ActiveCamera.Target - _mundo.CameraManager.ActiveCamera.Position) * 15.0f;
                   physObj.Name = "FlyingBall " + ++i;
                   _mundo.AddObject(physObj);
               }
           );
            scene.BindInput(SimpleConcreteGestureInputPlayable);
        }
        public BallThrowBepu(IScene scene, GraphicFactory factory, GestureType type)
            : base(scene)
        {
            this.Start();
            this.factory = factory;
            _mundo = scene.World;

            SimpleConcreteGestureInputPlayable SimpleConcreteGestureInputPlayable = new SimpleConcreteGestureInputPlayable(type,
               (sample) =>
               {
                   IObject physObj = SpawnPrimitive(_mundo.CameraManager.ActiveCamera.Position, Matrix.Identity);
                   physObj.PhysicObject.Velocity = (_mundo.CameraManager.ActiveCamera.Target - _mundo.CameraManager.ActiveCamera.Position) * 10.0f;
                   physObj.Name = "FlyingBall " + ++i;
                   _mundo.AddObject(physObj);
                   (physObj.Material.Shader as ForwardXNABasicShader).BasicEffect.EnableDefaultLighting();
               }
           );
            scene.BindInput(SimpleConcreteGestureInputPlayable);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Picking"/> class.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="pickingRayDistance">The picking ray distance.</param>
        public Picking(IScene owner, float pickingRayDistance = 500)
            : base(owner)
        {            
            leftButtonIntercept = rightButtonIntercept = noneButtonIntercept = CullNothing;
            this.pickingRayDistance = pickingRayDistance;
            world = owner.World;
            info = owner.GraphicInfo;

            {
                SimpleConcreteMouseBottomInputPlayable pbLeft = new SimpleConcreteMouseBottomInputPlayable(StateKey.PRESS, EntityType.COMPONENT, MouseButtons.LeftButton, MouseBottomLeft, InputMask.GPICKING);
                bmc1 = new BindMouseCommand(pbLeft, BindAction.ADD);
                CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bmc1);
            }

            {
                SimpleConcreteMouseBottomInputPlayable pbRight = new SimpleConcreteMouseBottomInputPlayable(StateKey.PRESS, EntityType.COMPONENT, MouseButtons.RightButton, MouseBottomRight, InputMask.GPICKING);
                bmc2 = new BindMouseCommand(pbRight, BindAction.ADD);
                CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bmc2);
            }
        }
 public SphereCharacterControllerInput(IScene scene, Vector3 position, float radius, float scale, float Yalignement = 0)
     : base(scene)
 {
     Characterobj = new SphereCharacterObject(position, Matrix.Identity, radius, scale, Yalignement);
     this.Start();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="Picking"/> class.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="pickingRayDistance">The picking ray distance.</param>
        public Picking(IScene owner, GestureType GestureType, float pickingRayDistance = 500)
            : base(owner)
        {
            leftButtonIntercept = noneButtonIntercept = CullNothing;
            this.pickingRayDistance = pickingRayDistance;
            world = owner.World;
            info = owner.GraphicInfo;
            {
                SimpleConcreteGestureInputPlayable pbRight = new SimpleConcreteGestureInputPlayable(GestureType,

                    (sample) =>
                    {
                        if (OnPickedGesture != null)
                        {
                            TouchCollection tc = TouchPanel.GetState();
                            for (int i = 0; i < tc.Count; i++)
                            {
                            UpdatePickRay(tc[i].Position);

                            SegmentInterceptInfo rti = world.PhysicWorld.SegmentIntersect(ray, noneButtonIntercept, pickingRayDistance);
                            if (rti == null)
                                return;
                            OnPickedGesture(rti,tc[i]);
                            }
                        }
                    
                    }
                    , InputMask.GPICKING);
                bmc2 = new BindGestureCommand(pbRight, BindAction.ADD);
                CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bmc2);
            }
        }
 public FullCharacterControllerInput(IScene scene, Vector3 position, float characterHeight, float radius, Vector3 scale,float Yalignement = 0)
     : base(scene)
 {
     Characterobj = new FullCharacterObject(position, Matrix.Identity, characterHeight, radius, scale, Yalignement);
     this.Start();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CameraFirstPerson"/> class.
        /// </summary>
        /// <param name="lrRot">The leftright rotation.</param>
        /// <param name="udRot">The updown rotation.</param>
        /// <param name="startingPos">The starting pos.</param>
        /// <param name="viewport">The viewport.</param>
        public P3DCamera(IScene scene, float lrRot, float udRot, Vector3 startingPos, Viewport viewport)
        {
            this.world = scene.World;
            
            init(lrRot, udRot, startingPos, viewport);

            scene.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.FreeDrag,
                  (sample) =>
                  {
                      leftrightRot -= rotationSpeed * sample.Delta.X;
                      updownRot -= rotationSpeed * sample.Delta.Y;
                      UpdateViewMatrix();
                  }
              ));

            scene.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.DoubleTap,
                  (sample) =>
                  {
                            onunseek = true;
                            Matrix projection = world.CameraManager.ActiveCamera.Projection;
                            Matrix viewProjection = world.CameraManager.ActiveCamera.View * world.CameraManager.ActiveCamera.Projection;
                            Matrix viewInverse = Matrix.Invert(world.CameraManager.ActiveCamera.View);
                            Matrix projectionInverse = Matrix.Invert(world.CameraManager.ActiveCamera.Projection);
                            Matrix viewProjectionInverse = projectionInverse * viewInverse;

                            Vector3 v = new Vector3();
                            v.X = (((2.0f * sample.Position.X) / viewPort.Width) - 1);
                            v.Y = -(((2.0f * sample.Position.Y) / viewPort.Height) - 1);
                            v.Z = 0.0f;

                            Ray pickRay = new Ray();
                            pickRay.Position.X = viewInverse.M41;
                            pickRay.Position.Y = viewInverse.M42;
                            pickRay.Position.Z = viewInverse.M43;
                            pickRay.Direction = Vector3.Normalize(Vector3.Transform(v, viewProjectionInverse) - pickRay.Position);

                            SegmentInterceptInfo rti = world.PhysicWorld.SegmentIntersect(pickRay, (a) => true, 9999);
                            if (rti == null)
                            {
                             
                            }
                            else
                            {
                                Vector3 impact = rti.ImpactPosition;
                                Vector3 lookAt = Position - impact;
                                origem = Position;
                                destino = Position + lookAt * 0.8f;
                                passo = 0;
                            }
                        


                  }
              ));

            scene.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Hold,
                  (sample) =>
                  {
                      onseek = true;
                      Matrix projection = world.CameraManager.ActiveCamera.Projection;
                      Matrix viewProjection = world.CameraManager.ActiveCamera.View * world.CameraManager.ActiveCamera.Projection;
                      Matrix viewInverse = Matrix.Invert(world.CameraManager.ActiveCamera.View);
                      Matrix projectionInverse = Matrix.Invert(world.CameraManager.ActiveCamera.Projection);
                      Matrix viewProjectionInverse = projectionInverse * viewInverse;

                      Vector3 v = new Vector3();
                      v.X = (((2.0f * sample.Position.X) / viewPort.Width) - 1);
                      v.Y = -(((2.0f * sample.Position.Y) / viewPort.Height) - 1);
                      v.Z = 0.0f;

                      Ray pickRay = new Ray();
                      pickRay.Position.X = viewInverse.M41;
                      pickRay.Position.Y = viewInverse.M42;
                      pickRay.Position.Z = viewInverse.M43;
                      pickRay.Direction = Vector3.Normalize(Vector3.Transform(v, viewProjectionInverse) - pickRay.Position);

                      SegmentInterceptInfo rti = world.PhysicWorld.SegmentIntersect(pickRay, (a) => true, 9999);
                      if (rti == null)
                      {
                         
                      }
                      else
                      {
                          Vector3 impact = rti.ImpactPosition;
                          Vector3 lookAt = impact - Position;
                          destino = Position + lookAt * 0.8f;
                          origem = Position;
                          passo = 0;
                      }
                  }
              ));

           

            


            if (useAcelerometer)
            {
                accelSensor = new Microsoft.Devices.Sensors.Accelerometer();
                // Start the accelerometer
                try
                {
                    accelSensor.Start();
                    accelActive = true;
                }
                catch (Microsoft.Devices.Sensors.AccelerometerFailedException e)
                {
                    // the accelerometer couldn't be started.  No fun!
                    accelActive = false;
                }
                catch (UnauthorizedAccessException e)
                {
                    // This exception is thrown in the emulator-which doesn't support an accelerometer.
                    accelActive = false;
                }
                accelSensor.ReadingChanged += new EventHandler<Microsoft.Devices.Sensors.AccelerometerReadingEventArgs>(accelSensor_ReadingChanged);
            }


        }