protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            var newCameraFirstPerson = new CameraStatic(new Vector3(100,100,100), - new Vector3(100,100,100) );
            this.World.CameraManager.AddCamera(newCameraFirstPerson);

            SimpleConcreteGestureInputPlayable SimpleConcreteGestureInputPlayable = new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.DoubleTap, (sample) => doubleTapCount++);
            this.BindInput(SimpleConcreteGestureInputPlayable);

            this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Hold, 
                (sample) => 
                    {
                        this.RemoveInputBinding(SimpleConcreteGestureInputPlayable);
                        doubleTapDisabled = true;
                    }
            ));
        }
        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>
        /// Called once to load content
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            ///load background texture
            tile = factory.GetTexture2D("Textures/tile");

            ///recover the physic world reference
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///from vertices
            {
                ////creating objects from vertices
                Vertices Vertices = new Vertices(3);                
                Vertices.Add(new Vector2(0,0));
                Vertices.Add(new Vector2(200,0));
                Vertices.Add(new Vector2(0, -200));

                
                ///creating the IModelo (graphic representation)
                SpriteFarseer SpriteFarseer = new SpriteFarseer(factory, Vertices, Color.Green);
                ///The material (how to draw)
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                ///the physic object (physic representation)
                FarseerObject fs = new FarseerObject(fworld, SpriteFarseer, 1, BodyType.Static);
                ///the iobject (that comprises all)
                I2DObject o = new I2DObject(fs, mat, SpriteFarseer);
                ///adding to the world
                this.World.AddObject(o);

            }
            
            ///Creating from factory helper            
            Vertices verts = PolygonTools.CreateRectangle(50, 50);
            {
                IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down                
                o.PhysicObject.Position = new Vector2(100,150);
                this.World.AddObject(o);
            }

            ///Creating from factory helper            
            verts = PolygonTools.CreateRectangle(50, 50);
            {
                IModelo2D model = new SpriteFarseer(factory, verts, Color.Yellow);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down                
                o.PhysicObject.Position = new Vector2(-100, -150);
                this.World.AddObject(o);
            }

            ///Creating from factory helper            
            verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);
            {
                IModelo2D model = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down                
                o.PhysicObject.Position = new Vector2(0, 250);
                this.World.AddObject(o);
            }                       

            ///when tap ...
            SimpleConcreteGestureInputPlayable SimpleConcreteMouseBottomInputPlayable = null;
            SimpleConcreteMouseBottomInputPlayable = new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Tap,
                 (sample) =>
                 {
                     Vector2 wpos = this.World.Camera2D.ConvertScreenToWorld(sample.Position);
                     {
                         Texture2D tex = factory.GetTexture2D("Textures//goo");                         
                         IModelo2D model = new SpriteFarseer(tex);
                         Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                         FarseerObject fs = new FarseerObject(fworld, tex);                         
                         I2DObject partobj = new I2DObject(fs, mat, model);
                         partobj.PhysicObject.Position = wpos;
                         fs.Body.Friction = StaticRandom.RandomBetween(0, 1);
                         this.World.AddObject(partobj);
                     }                     
                     
                 }
             );
            this.BindInput(SimpleConcreteMouseBottomInputPlayable);

            ///the basic ortographic 2D camera
            this.World.Camera2D = new Camera2D(GraphicInfo);
            base.LoadContent(GraphicInfo, factory, contentManager);
        }
        void Camera2D_ReachedTheTrackingPosition(Camera2D obj)
        {
            SimpleConcreteGestureInputPlayable SimpleConcreteMouseBottomInputPlayable1 = new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.FreeDrag,
                 (sample) =>
                 {
                     mousepressed = true;
                 }
             );
            this.BindInput(SimpleConcreteMouseBottomInputPlayable1);


            SimpleConcreteGestureInputPlayable SimpleConcreteMouseBottomInputPlayable = null;
            SimpleConcreteMouseBottomInputPlayable = new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.DragComplete,
                 (sample) =>
                 {
                     mousepressed = false;
                     lines.isEnabled = false;
                     fired = true;

                     Vector2 mpos = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
                     Vector2 wpos = this.World.Camera2D.ConvertScreenToWorld(mpos);
                     Vector2 force = (ball.PhysicObject.Position - wpos) * 30;
                     ball.PhysicObject.ApplyForce(force);
                     this.RemoveInputBinding(SimpleConcreteMouseBottomInputPlayable);
                     this.RemoveInputBinding(SimpleConcreteMouseBottomInputPlayable1);

                     (this.World.Camera2D as Camera2D).TrackingBody = ball;
                     (this.World.Camera2D as Camera2D).IntertiaController = 1;
                 }
             );
            this.BindInput(SimpleConcreteMouseBottomInputPlayable);            
        }
Пример #6
0
        /// <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);
            }
        }