Ejemplo n.º 1
0
 public override void OnTrigger(Shape triggerShape, Shape otherShape, TriggerFlag status)
 {
     if (triggerShape.UserData != null)
     {
         PhysxTrigger PhysxTrigger = triggerShape.UserData as PhysxTrigger;
         PhysxTrigger.fireEvent(status, otherShape.Actor.UserData as IPhysicObject);
     }
 }
Ejemplo n.º 2
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();
        }
        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(5f);
                 PhysxGhostObject PhysxPhysicObject = new PhysxGhostObject(new Vector3(100,100,100),Matrix.Identity, Vector3.One * 5f);
                 
                 IObject o = new IObject(m, sm2, PhysxPhysicObject);
                 this.World.AddObject(o);

                 PhysxTrigger PhysxTrigger = new PloobsEngine.Physics.PhysxTrigger(
                     SphereGeometry, Matrix.CreateTranslation(new Vector3(100, 100, 100)),
                     new PloobsEngine.Trigger.TriggerEvent("TriggerEvent", "TriggerEvent"), null, true);

                 World.AddTrigger(PhysxTrigger);

            }

            

            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);
            this.AttachCleanUpAble(BallThrowBullet);
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            ReciveMessage ReciveMessage = new ReciveMessage();
        }