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);
            }
            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//uzi");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
        }
        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);
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    SimpleModel           simpleModel = new SimpleModel(factory, "Model//uzi");
                    TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, new Vector3(25 * j, 30, 15 * i), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
                    ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                    ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                    IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                    obj.OnUpdate += new OnUpdate(obj_OnUpdate);
                    this.World.AddObject(obj);
                }
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            LightProbeReader LightProbeReader = new EngineTestes.LightProbeReader(factory.GetTexture2D("Textures\\probe"));
            Sampler          Sampler          = new EngineTestes.Sampler(100, 3);

            MonteCarlo MonteCarlo = new EngineTestes.MonteCarlo();

            MonteCarlo.ProjectLight(LightProbeReader, Sampler);


            {
                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);
            }



            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        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);
            }

            ConfigWriter cw = new ConfigWriter("teste.properties");

            cw.AddKeyValue("teste", "value");
            cw.Write();

            ConfigReader cr = new ConfigReader("teste.properties");

            cr.Read();
            String v = cr.ReadValue("teste");

            System.Diagnostics.Debug.Assert(v == "value");

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
        }
Exemple #5
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            ///cast to out world instance
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                ///Physic Triangle mesh (same as bepu)
                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One);

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            ///Ball Throw !!!
            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            RasterizerState          = new Microsoft.Xna.Framework.Graphics.RasterizerState();
            RasterizerState.FillMode = FillMode.WireFrame;

            BloomPostEffect         = new BloomPostEffect();
            BloomPostEffect.Enabled = false;
            this.RenderTechnic.AddPostEffect(BloomPostEffect);


            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel        simpleModel = new SimpleModel(factory, "Model//cena");
                TriangleMeshObject tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());

                ForwardXNABasicShaderDescription ForwardXNABasicShaderDescription = ForwardXNABasicShaderDescription.Default();
                ForwardXNABasicShaderDescription.EnableTexture    = true;
                ForwardXNABasicShaderDescription.EnableLightning  = true;
                ForwardXNABasicShaderDescription.DefaultLightning = true;

                shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription);
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                IObject         obj       = new IObject(fmaterial, simpleModel, tmesh);

                shader.Initialize(GraphicInfo, factory, obj);
                this.World.AddObject(obj);
            }


            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cilos");
                ///tem mais de um cilo neste mesh, tem q setar as texturas de todo mundo ....
                Texture2D tex = factory.CreateTexture2DColor(1, 1, Color.White);
                for (int i = 0; i < simpleModel.MeshNumber; i++)
                {
                    simpleModel.SetTexture(tex, TextureType.DIFFUSE, i, 0);
                }

                TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                shader2 = new ForwardEnvironmentShader(factory.GetTextureCube("Textures//cubeMap"), 1, false);
                ForwardMaterial fmaterial = new ForwardMaterial(shader2);

                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            shader.BasicEffect.FogEnabled = true;
            shader.BasicEffect.FogColor   = new Vector3(0.1f, 0.1f, 0.1f); // Dark grey
            shader.BasicEffect.FogStart   = 30;
            shader.BasicEffect.FogEnd     = 1000;

            shader2.EnvironmentMapEffect.FogEnabled = true;
            shader2.EnvironmentMapEffect.FogColor   = new Vector3(0.1f, 0.1f, 0.1f); // Dark grey
            shader2.EnvironmentMapEffect.FogStart   = 30;
            shader2.EnvironmentMapEffect.FogEnd     = 1000;

            cam = new RotatingCamera(this);
            this.World.CameraManager.AddCamera(cam);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Gray), TextureType.MULTITEX1);
                TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                //ForwardDualTextureShader shader = new ForwardDualTextureShader();
                ForwardEnvironmentShader shader    = new ForwardEnvironmentShader(factory.GetTextureCube("Textures//grassCUBE"));
                ForwardMaterial          fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }
            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//uzi");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
        }
        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;
            }
                                                                  ));
        }
        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);
            }
            {
                SimpleModel      simpleModel = new SimpleModel(factory, "Model//uzi");
                MobileMeshObject tmesh       = new MobileMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial(), BEPUphysics.CollisionShapes.MobileMeshSolidity.DoubleSided, 10);
                //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            new LightThrowBepu(this.World, factory);
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #10
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                StillDesign.PhysX.Material material1 = PhysxPhysicWorld.CreatePhysicMaterial(
                    new StillDesign.PhysX.MaterialDescription()
                {
                    Restitution     = 0.3f,
                    DynamicFriction = 0.5f,
                    StaticFriction  = 1,
                }
                    );
                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One, 1, material1);

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);

            for (int i = 0; i < 10; i++)
            {
                StillDesign.PhysX.Material material2 = PhysxPhysicWorld.CreatePhysicMaterial(
                    new StillDesign.PhysX.MaterialDescription()
                {
                    Restitution            = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    DynamicFriction        = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    StaticFriction         = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    RestitutionCombineMode = CombineMode.Max,
                }
                    );

                ///Load a Model with a custom texture
                SimpleModel sm2 = new SimpleModel(factory, "Model\\ball");
                sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green, false), TextureType.DIFFUSE);

                ForwardXNABasicShader nd = new ForwardXNABasicShader();
                IMaterial             m  = new ForwardMaterial(nd);

                SphereShapeDescription SphereGeometry = new SphereShapeDescription(5f);
                SphereGeometry.Material = material2;

                PhysxPhysicObject PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                                                                            0.5f, Matrix.CreateTranslation(new Vector3(100, 100, 50 * i)), Vector3.One * 5f);

                IObject o = new IObject(m, sm2, PhysxPhysicObject);
                this.World.AddObject(o);
            }
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #11
0
        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);
            }

            ///using component
            Billboard3D Billboard3D = new Billboard3D(factory.GetTexture2D("Textures\\grama1"), new Vector3(100, 20, 100), Vector2.One * 0.2f);

            BillboardComponent.Billboards.Add(Billboard3D);

            ///using old mode (IObject billboard)
            {
                List <Billboard> poss = new List <Billboard>();
                for (int i = 0; i < 10; i++)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        float x, y;
                        x = i * 10;
                        y = j * 10;
                        poss.Add(
                            new Billboard()
                        {
                            Position = new Vector3(x, 50, y),
                            Scale    = Vector2.One * 0.01f,
                            Enabled  = true
                        }
                            );
                    }
                }

                CPUBillboardModel      bm     = new CPUBillboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss.ToArray());
                ForwardAlphaTestShader cb     = new ForwardAlphaTestShader(128, CompareFunction.GreaterEqual);
                ForwardMaterial        matfor = new ForwardMaterial(cb);
                matfor.RasterizerState = RasterizerState.CullNone;
                GhostObject go   = new GhostObject();
                IObject     obj2 = new IObject(matfor, bm, go);
                this.World.AddObject(obj2);

                //Text Billboards
                TextBillboard3D TextBillboard3D = new TextBillboard3D("TEST 123 SPHERICAL", Color.Black, new Vector3(100), 0.5f);
                sBillboardComponent.Billboards.Add(TextBillboard3D);


                TextBillboard3D = new TextBillboard3D("TEST 123 Cylinder", Color.Black, new Vector3(200, 50, 200), 0.5f);
                cBillboardComponent.Billboards.Add(TextBillboard3D);
            }


            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #12
0
        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);
            }

            {
                TModelo <VertexPositionColor> simpleModel = new TModelo <VertexPositionColor>(factory,
                                                                                              new VertexPositionColor[]
                {
                    new VertexPositionColor(new Vector3(50, 10, 0), Color.Green),
                    new VertexPositionColor(new Vector3(10, 10, 0), Color.Green),
                    new VertexPositionColor(new Vector3(0, 100, 0), Color.Green)
                }
                                                                                              , null,
                                                                                              Matrix.Identity, null, -1, false, 1, BufferUsage.None);

                TriangleMeshObject    tmesh     = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 2, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader();
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);

                shader.BasicEffect.TextureEnabled     = false;
                shader.BasicEffect.VertexColorEnabled = true;
            }

            {
                TConstructiveModelo <VertexPositionColor> simpleModel = new TConstructiveModelo <VertexPositionColor>(factory, Matrix.CreateTranslation(new Vector3(100)), null, -1, false, BufferUsage.None);
                simpleModel.AddVertex(new VertexPositionColor(new Vector3(50, 10, 0), Color.Red));
                simpleModel.AddVertex(new VertexPositionColor(new Vector3(100, 10, 0), Color.Red));
                simpleModel.AddVertex(new VertexPositionColor(new Vector3(0, 100, 0), Color.Red));
                simpleModel.BuildModel();

                TriangleMeshObject    tmesh     = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 2, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);

                shader.BasicEffect.TextureEnabled     = false;
                shader.BasicEffect.VertexColorEnabled = true;
            }


            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
        }
Exemple #13
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            BepuPhysicWorld.ApplyHighStabilitySettings(this.World.PhysicWorld as BepuPhysicWorld);

            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);
            }
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE);
                MobileMeshObject tmesh = new MobileMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial(), BEPUphysics.CollisionShapes.MobileMeshSolidity.DoubleSided, 10);
                //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
                shader.BasicEffect.EnableDefaultLighting();
            }

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
                MobileMeshObject tmesh = new MobileMeshObject(simpleModel, new Vector3(150, 100, 10), Matrix.Identity, Vector3.One * 20, MaterialDescription.DefaultBepuMaterial(), BEPUphysics.CollisionShapes.MobileMeshSolidity.DoubleSided, 10);
                //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
                shader.BasicEffect.EnableDefaultLighting();
            }

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);
                MobileMeshObject tmesh = new MobileMeshObject(simpleModel, new Vector3(200, 100, 10), Matrix.Identity, Vector3.One * 15, MaterialDescription.DefaultBepuMaterial(), BEPUphysics.CollisionShapes.MobileMeshSolidity.DoubleSided, 10);
                //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
                shader.BasicEffect.EnableDefaultLighting();
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        public ObjectMock(GraphicFactory GraphicFactory, String modelName, Vector3 position, Matrix orientation, Vector3 scale)
        {
            this.modelName   = modelName;
            this.position    = position;
            this.scale       = scale;
            this.orientation = orientation;
            Modelo           = new SimpleModel(GraphicFactory, modelName);
            PhysicObject     = new TriangleMeshObject(Modelo, position, orientation, scale, MaterialDescription.DefaultBepuMaterial());
            ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());

            Material          = new ForwardMaterial(shader);
            IObjectAttachment = new List <IObjectAttachment>();
        }
Exemple #15
0
        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);
            }

            {
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
                ForwardXNABasicShader    shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial          fmaterial = new ForwardMaterial(shader);
                CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10, 0.5f);
                BaseObject marine = new BaseObject(fmaterial, character.Characterobj, sm);
                this.World.AddObject(marine);

                ///ever !!!
                marine.Behavior = new Repeater <BaseObject>(

                    new Watch <BaseObject>(
                        (a, b) =>
                {
                    ///condition
                    if (a.PhysicObject.Position.Length() < 100)
                    {
                        return(TaskResult.Failure);
                    }
                    return(TaskResult.Success);
                }
                        ,

                        ///chnage its color =P
                        new BehaviorTrees.Action <BaseObject>(
                            (a, b) =>
                {
                    a.Modelo.SetTexture(factory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);
                    return(TaskResult.Success);
                }
                            )
                        )
                    );
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #16
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One);

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


            {
                ///Load a Model with a custom texture
                SimpleModel sm2 = new SimpleModel(factory, "Model\\ball");
                sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Aquamarine, false), TextureType.DIFFUSE);
                ForwardXNABasicShader nd = new ForwardXNABasicShader();
                IMaterial             m  = new ForwardMaterial(nd);

                SphereShapeDescription SphereGeometry    = new SphereShapeDescription(15f);
                PhysxGhostObject       PhysxPhysicObject = new PhysxGhostObject(new Vector3(100, 100, 100), Matrix.Identity, Vector3.One * 15f);

                IObject o = new IObject(m, sm2, PhysxPhysicObject);
                this.World.AddObject(o);

                ///Physx Trigger !!!
                ///Just need to pass a shape to it
                ///WORKS THE SAME AS BEPU TRIGGER
                ///LOOK AT INTRODUCTION DEMOS
                PhysxTrigger PhysxTrigger = new PloobsEngine.Physics.PhysxTrigger(
                    SphereGeometry, Matrix.CreateTranslation(new Vector3(100, 100, 100)),
                    new PloobsEngine.Trigger.TriggerEvent("TriggerEvent", "TriggerEvent"), null, true, true, true);

                World.AddTrigger(PhysxTrigger);
            }


            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            ReciveMessage = new ReciveMessage();
        }
Exemple #17
0
        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);
            }

            NeoforceGui guiManager = this.Gui as NeoforceGui;

            System.Diagnostics.Debug.Assert(guiManager != null);

            // Create and setup Window control.
            Window window = new Window(guiManager.Manager);

            window.Init();
            window.Text   = "Getting Started";
            window.Width  = 480;
            window.Height = 200;
            window.Center();
            window.Visible = true;

            // Create Button control and set the previous window as its parent.
            Button button = new Button(guiManager.Manager);

            button.Init();
            button.Text   = "OK";
            button.Width  = 72;
            button.Height = 24;
            button.Left   = (window.ClientWidth / 2) - (button.Width / 2);
            button.Top    = window.ClientHeight - button.Height - 8;
            button.Anchor = Anchors.Bottom;
            button.Parent = window;
            button.Click += new TomShane.Neoforce.Controls.EventHandler(button_Click);

            // Add the window control to the manager processing queue.
            guiManager.Manager.Add(window);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(false, GraphicInfo));

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube");

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        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);
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo.Viewport));
        }
Exemple #19
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//cenario");
                BulletTriangleMesh    tmesh       = new BulletTriangleMesh(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One);
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            BallThrowBullet BallThrowBullet = new BallThrowBullet(this.World, GraphicFactory);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #20
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One);

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


            {
                ///Controller description
                ///YOu have BoxControllerDescription  and SphereControllerDescription
                BoxControllerDescription desc = new BoxControllerDescription(1, 1, 1);
                desc.UpDirection     = Axis.Y;
                desc.SlopeLimit      = 0;
                desc.SkinWidth       = 0.2f;
                desc.StepOffset      = 0.5f;
                desc.InteractionFlag = CCTInteractionFlag.Include | CCTInteractionFlag.UseFilter;

                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
                ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       mat    = new ForwardMaterial(shader);

                ///Character Object
                PhysxBoxCharacterObject PhysxCapsuleCharacterObject = new PhysxBoxCharacterObject(desc, new Vector3(50), Matrix.Identity, Vector3.One * 5);
                IObject marine = new IObject(mat, sm, PhysxCapsuleCharacterObject);
                this.World.AddObject(marine);
                marine.OnUpdate += new OnUpdate(marine_OnUpdate);
            }

            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);

                BoxShapeDescription SphereGeometry    = new BoxShapeDescription(1000, 5, 1000);
                PhysxPhysicObject   PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                                                                              Matrix.Identity, new Vector3(1000, 5, 1000));

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, PhysxPhysicObject);
                this.World.AddObject(obj);

                shader.BasicEffect.EnableDefaultLighting();
            }

            {
                ///very basic vehicle !!!
                ///no wheels also =P
                Vehicle     Vehicle     = new Vehicle(PhysxPhysicWorld.Scene);
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green));
                PhysxPhysicObject tmesh = new PhysxPhysicObject(Vehicle.VehicleBodyActor, new Vector3(5, 3, 7));

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                UserObject <Vehicle>  obj       = new UserObject <Vehicle>(fmaterial, simpleModel, tmesh, Vehicle);
                obj.OnUserUpdate += new Action <UserObject <StillDesign.PhysX.Samples.Vehicle> >(obj_OnUserUpdate);
                this.World.AddObject(obj);
            }

            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);
                BoxObject tmesh = new BoxObject(new Vector3(0), 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ForwardTransparenteShader shader = new ForwardTransparenteShader();
                shader.TransparencyLevel = 0.2f;
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                IObject         obj       = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


            Simulator.setTimeStep(0.10f);
            Simulator.setAgentDefaults(15.0f, 25, 5.0f, 5.0f, 2.0f, new Vector3());

            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                    simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                    GhostObject           tmesh     = new GhostObject(new Vector3(100 + j * 15, 5, i * 15), Matrix.Identity, new Vector3(1, 1, 1));
                    ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                    ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                    int       id  = Simulator.addAgent(tmesh.Position);
                    RVOObject obj = new RVOObject(id, fmaterial, simpleModel, tmesh);
                    obj.OnUpdate += new OnUpdate(obj_OnUpdate); /// dummy position update way =p
                    this.World.AddObject(obj);
                }
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            Picking p = new Picking(this, 1000);

            p.OnPickedLeftButton += new OnPicked(p_OnPickedLeftButton);
        }
        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);
            }

            SphericalBillboard3D Billboard3D = new SphericalBillboard3D(factory.GetTexture2D("Textures\\goo"), new Vector3(100, 20, 100), Vector2.One * 0.2f);

            BillboardComponent.Billboards.Add(Billboard3D);


            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel, Matrix.Identity,
                                                                Matrix.Identity, Vector3.One, PloobsEngine.Physics.MaterialDescription.DefaultPhysxMaterial());

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            BallThrowPhysx BallThrowBullet = new BallThrowPhysx(this.World, GraphicFactory);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #25
0
        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);
                obj.Name = "Cenario";
                this.World.AddObject(obj);
            }

            Picking pick = new Picking(this, Microsoft.Xna.Framework.Input.Touch.GestureType.DoubleTap);

            pick.Start();
            pick.OnPickedGesture += new OnPicked(pick_OnPickedGesture);

            var newCameraFirstPerson = new CameraFirstPerson(GraphicInfo);

            this.World.CameraManager.AddCamera(newCameraFirstPerson);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);

            for (int i = 0; i < 3; i++)
            {
                ///Different from others examples, we use a model to provide the vertices to the cloth
                ///Model must be "closed"
                ClothMeshDescription ClothMeshDescription = new ClothMeshDescription();
                ClothMeshDescription.WeldingDistance = 0.0001f;
                ClothMeshDescription.Flags           = (MeshFlag)(int)ClothMeshFlag.WeldVertices;


                ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld,
                                                                           ClothMeshDescription, "Model//ball", Vector3.One * 25, "Textures//meiofio");

                var clothDesc = new ClothDescription()
                {
                    Friction  = 0.5f,
                    ClothMesh = ClothModel.ClothMesh,
                    Pressure  = 0.9f, ///experiment changing this =P
                    Flags     = ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization | ClothFlag.Pressure | ClothFlag.Gravity | ClothFlag.SelfCollision | ClothFlag.TriangleCollision,
                    Thickness = 0.4f,
                };


                clothDesc.MeshData.AllocatePositions <Vector3>(ClothModel.VerticesNum);
                clothDesc.MeshData.AllocateIndices <int>(ClothModel.IndicesNum);
                clothDesc.MeshData.AllocateNormals <Vector3>(ClothModel.VerticesNum);

                clothDesc.MeshData.MaximumVertices = ClothModel.VerticesNum;
                clothDesc.MeshData.MaximumIndices  = ClothModel.IndicesNum;

                clothDesc.MeshData.NumberOfVertices = ClothModel.VerticesNum;
                clothDesc.MeshData.NumberOfIndices  = ClothModel.IndicesNum;

                PhysxClothObject PhysxClothObject = new PloobsEngine.Physics.PhysxClothObject(clothDesc,
                                                                                              Matrix.CreateTranslation(100, 50, i * 100));


                ForwardXNABasicShader ForwardXNABasicShader = new PloobsEngine.Material.ForwardXNABasicShader();
                ClothMaterial         ClothMaterial         = new ClothMaterial(ForwardXNABasicShader);
                //ClothMaterial.RasterizerState.FillMode = FillMode.WireFrame;
                IObject IObject = new PloobsEngine.SceneControl.IObject(ClothMaterial, ClothModel, PhysxClothObject);
                World.AddObject(IObject);

                ForwardXNABasicShader.BasicEffect.EnableDefaultLighting();
            }

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);

                BoxShapeDescription SphereGeometry    = new BoxShapeDescription(1000, 5, 1000);
                PhysxPhysicObject   PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                                                                              Matrix.Identity, new Vector3(1000, 5, 1000));

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, PhysxPhysicObject);
                this.World.AddObject(obj);

                shader.BasicEffect.EnableDefaultLighting();
            }


            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemple #27
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            SerializatorWrapper SerializatorWrapper = new SerializatorWrapper();

            SerializatorWrapper.Serialize(new Vector3(10, 20, 30), "vetor.xml");
            Vector3 vec = (Vector3)SerializatorWrapper.Desserialize <Vector3>("vetor.xml", null);

            Debug.Assert(vec.X == 10);
            Debug.Assert(vec.Y == 20);
            Debug.Assert(vec.Z == 30);


            ObjectMock ObjectMock = new ObjectMock(GraphicFactory, "Model/cenario", Vector3.Zero, Matrix.Identity, Vector3.One);

            SerializatorWrapper.Serialize(ObjectMock, "cena.xml");
            ObjectMock mloaded = (ObjectMock)SerializatorWrapper.Desserialize <ObjectMock>("cena.xml", GraphicFactory);

            this.World.AddObject(mloaded);


            IObject obj;

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//ball");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE);
                SphereObject          tmesh     = new SphereObject(new Vector3(100, 200, 10), 1, 10, 5, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


            this.BindInput(new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space,
                                                                   (a) =>
            {
                this.World.RemoveObject(obj);
                DynamicObjectSaver DynamicObjectSaver = new Serialization.DynamicObjectSaver(obj.Modelo.Name, obj.PhysicObject.Position, obj.PhysicObject.Rotation, obj.PhysicObject.Scale, obj.PhysicObject.Velocity, obj.PhysicObject.AngularVelocity);
                SerializatorWrapper.Serialize(DynamicObjectSaver, "dyn.xml");

                DynamicObjectSaver dloaded = (DynamicObjectSaver)SerializatorWrapper.Desserialize <DynamicObjectSaver>("dyn.xml");
                SimpleModel simpleModel    = new SimpleModel(factory, dloaded.modelName);
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE);
                SphereObject tmesh           = new SphereObject(dloaded.position, 1, 10, dloaded.scale.X, MaterialDescription.DefaultBepuMaterial());
                tmesh.Rotation               = dloaded.orientation;
                tmesh.Velocity               = dloaded.LinearVelocity;
                tmesh.AngularVelocity        = dloaded.AngularVelocity;
                ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial fmaterial    = new ForwardMaterial(shader);
                obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
                saved++;
            }
                                                                   ));



            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                //supose you have these: (just an idiot sample -- dummy values)
                int[]     indices = new int[] { 0, 1, 2, 1, 2, 3 };
                Vector3[] vecs    = new Vector3[] { new Vector3(0), new Vector3(4), new Vector3(2), new Vector3(1) };

                ///This is not good, cause it is very cpu intensive
                ///try to update the vertices array instead of creating one every time
                VertexPositionTexture[] vertices = new VertexPositionTexture[vecs.Length];
                for (int i = 0; i < vecs.Length; i++)
                {
                    VertexPositionTexture v = new VertexPositionTexture(vecs[i], Vector2.Zero);
                    vertices[i] = v;
                }


                //TO CONSTRUCT
                ////Creating the terrain
                VoxelTerrainModel    VoxelTerrainModel = new PloobsProjectTemplate.VoxelTerrainModel(factory, "ANY_NAME", "Textures//goo", indices, vertices);
                TriangleMeshObject   tm      = new TriangleMeshObject(VoxelTerrainModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader2 = new DeferredNormalShader();
                IMaterial            mat     = new DeferredMaterial(shader2);
                IObject obj2 = new IObject(mat, VoxelTerrainModel, tm);


                ///TO UPDATE
                ///PHYSIC
                ///to update the triangle mesh date (updated version of indices/vertices ....)
                tm.StaticMesh.Mesh.Data.Indices  = indices;
                tm.StaticMesh.Mesh.Data.Vertices = vecs;

                //if you NOT changed the indices (slower)
                tm.StaticMesh.Mesh.Tree.Reconstruct();
                //if you changed the indices (faster)
                tm.StaticMesh.Mesh.Tree.Refit();



                ///MODEL (see the VoxelTerrainModel  ) implementation
                VoxelTerrainModel.Vertices = vertices;
                VoxelTerrainModel.Indices  = indices;
            }

            {
                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);
            }
            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//uzi");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
        }
Exemple #29
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);
                BoxObject tmesh = new BoxObject(new Vector3(0), 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


            Simulator = Simulator.Instance;
            Simulator.setTimeStep(0.25f);
            Simulator.setAgentDefaults(5.0f, 25, 10.0f, 25.0f, 2.0f, 4.0f, new Vector2(0));

            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                    simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                    BoxObject             tmesh     = new BoxObject(new Vector3(100 + j * 5, 5, i * 5), 1, 1, 1, 10, new Vector3(1, 1, 1), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                    ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                    ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                    int       id  = Simulator.addAgent(tmesh.Position);
                    RVOObject obj = new RVOObject(id, fmaterial, simpleModel, tmesh);
                    obj.OnUpdate += new OnUpdate(obj_OnUpdate); /// dummy position update way =p
                    this.World.AddObject(obj);
                }
            }

            ///counterclockwise vertices
            Simulator.addObstacle(
                new List <Vector2>()
            {
                new Vector2(20, 20),
                new Vector2(40, 20),
                new Vector2(40, 40),
                new Vector2(40, 40),
                new Vector2(20, 40),
                new Vector2(20, 20),
            }
                );

            Simulator.processObstacles();

            ///obstacle
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
                GhostObject           tmesh     = new GhostObject(new Vector3(30, 0, 30), Matrix.Identity, new Vector3(10));
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            Picking p = new Picking(this, 1000);

            p.OnPickedLeftButton += new OnPicked(p_OnPickedLeftButton);
        }
        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);
            }

            {
                SimpleModel sm = new SimpleModel(factory, "Model//block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                //CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10, 0.5f);
                BoxObject  bb     = new BoxObject(new Vector3(100, 0, 1), 1, 1, 1, 10, Vector3.One * 10, Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                BaseObject marine = new BaseObject(fmaterial, bb, sm);
                this.World.AddObject(marine);

                /////ever !!!
                //marine.Behavior = new Repeater<BaseObject>(

                //new Watch<BaseObject>(
                //    (a,b)=>
                //        {

                //            ///condition
                //            if(a.PhysicObject.Position.Length() < 100)
                //            {
                //                return TaskResult.Failure;
                //            }
                //            return TaskResult.Success;
                //        }
                //    ,

                //        ///chnage its color =P
                //        new BehaviorTrees.Action<BaseObject>(
                //            (a,b)=>
                //            {
                //                a.Modelo.SetTexture(factory.CreateTexture2DColor(1,1,StaticRandom.RandomColor()),TextureType.DIFFUSE);
                //                return TaskResult.Success;
                //            }
                //            )
                //)
                //);



                marine.Behavior = new Repeater <BaseObject>
                                  (
                    new Sequence <BaseObject>()
                {
                    new Wait <BaseObject>(0.5f,
                                          new BehaviorTrees.Action <BaseObject>(
                                              (a, b) =>
                    {
                        return(TaskResult.Success);
                    }
                                              )
                                          )
                    ,

                    new RepeaterUntil <BaseObject>(
                        (a, b) =>
                    {
                        if ((a.PhysicObject.Position - waytogo).Length() > 50)
                        {
                            return(TaskResult.Running);
                        }
                        else
                        {
                            return(TaskResult.Success);
                        }
                    }
                        ,
                        new BehaviorTrees.Action <BaseObject>(
                            (a, b) =>
                    {
                        Vector3 direction = waytogo - a.PhysicObject.Position;
                        direction.Y       = 0;
                        direction.Normalize();
                        a.PhysicObject.Velocity = direction * 10;
                        // a.PhysicObject.Velocity += direction;


                        return(TaskResult.Success);
                    }
                            )
                        ),
                    ///chnage its color =P
                    new BehaviorTrees.Action <BaseObject>(
                        (a, b) =>
                    {
                        a.Modelo.SetTexture(factory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);
                        return(TaskResult.Success);
                    }
                        )
                }
                                  );
            }
            //this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
            RotatingCamera cam = new RotatingCamera(this, new Vector3(0, -100, -200));

            this.World.CameraManager.AddCamera(cam);
        }