Exemplo n.º 1
0
        public override void AddObject(IPhysicObject obj)
        {
            if (obj is PhysxPhysicObject)
            {
                PhysxPhysicObject PhysxPhysicObject = obj as PhysxPhysicObject;
                if (PhysxPhysicObject.Actor == null)
                {
                    PhysxPhysicObject.Actor          = Scene.CreateActor(PhysxPhysicObject.ActorDesc, int.MaxValue);
                    PhysxPhysicObject.Actor.UserData = obj;

                    for (int i = 0; i < PhysxPhysicObject.ActorDesc.Shapes.Count; i++)
                    {
                        PhysxPhysicObject.Actor.Shapes[i].UserData = PhysxPhysicObject.ActorDesc.Shapes[i].UserData;
                    }
                }
                else
                {
                    PhysxPhysicObject.Actor.UserData = obj;
                }
            }

            else if (obj is PhysxClothObject)
            {
                PhysxClothObject PhysxPhysicObject = obj as PhysxClothObject;
                PhysxPhysicObject.Cloth          = Scene.CreateCloth(PhysxPhysicObject.ClothDesc);
                PhysxPhysicObject.Cloth.UserData = obj;
            }

            else if (obj is PhysxFluidObject)
            {
                PhysxFluidObject PhysxPhysicObject = obj as PhysxFluidObject;
                PhysxPhysicObject.Fluid          = Scene.CreateFluid(PhysxPhysicObject.FluidDesc);
                PhysxPhysicObject.Fluid.UserData = obj;
            }

            else if (obj is PhysxCapsuleCharacterObject)
            {
                PhysxCapsuleCharacterObject PhysxPhysicObject = obj as PhysxCapsuleCharacterObject;
                PhysxPhysicObject.Controller          = ControllerManager.CreateController <CapsuleController>(PhysxPhysicObject.CapsuleControllerDescription);
                PhysxPhysicObject.Controller.UserData = obj;
            }

            else if (obj is PhysxBoxCharacterObject)
            {
                PhysxBoxCharacterObject PhysxPhysicObject = obj as PhysxBoxCharacterObject;
                PhysxPhysicObject.Controller          = ControllerManager.CreateController <BoxController>((PhysxPhysicObject.BoxControllerDescription));
                PhysxPhysicObject.Controller.UserData = obj;
            }

            objs.Add(obj);
        }
Exemplo n.º 2
0
        public override void RemoveObject(IPhysicObject obj)
        {
            if (obj is PhysxPhysicObject)
            {
                PhysxPhysicObject PhysxPhysicObject = obj as PhysxPhysicObject;
                PhysxPhysicObject.Actor.UserData = null;
                PhysxPhysicObject.Actor.Dispose();
            }
            else if (obj is PhysxClothObject)
            {
                PhysxClothObject PhysxPhysicObject = obj as PhysxClothObject;
                PhysxPhysicObject.Cloth.UserData = null;
                PhysxPhysicObject.Cloth.Dispose();
            }
            else if (obj is PhysxFluidObject)
            {
                PhysxFluidObject PhysxPhysicObject = obj as PhysxFluidObject;
                PhysxPhysicObject.Fluid.UserData = null;
                PhysxPhysicObject.Fluid.Dispose();
            }

            else if (obj is PhysxCapsuleCharacterObject)
            {
                PhysxCapsuleCharacterObject PhysxPhysicObject = obj as PhysxCapsuleCharacterObject;
                PhysxPhysicObject.Controller.UserData = null;
                PhysxPhysicObject.Controller.Dispose();
            }

            else if (obj is PhysxBoxCharacterObject)
            {
                PhysxBoxCharacterObject PhysxPhysicObject = obj as PhysxBoxCharacterObject;
                PhysxPhysicObject.Controller.UserData = null;
                PhysxPhysicObject.Controller.Dispose();
            }

            objs.Remove(obj);
        }