/// <summary> /// Trigger creation /// </summary> /// <param name="physicWorld">The physic world.</param> /// <param name="triangleMesh">Triangle mesh representing the Volume of the Trigger</param> /// <param name="evt">Event to be fired</param> /// <param name="fireBeginsTouching">if set to <c>true</c> [fire begins touching].</param> /// <param name="fireEndsTouching">if set to <c>true</c> [fire ends touching].</param> /// <param name="fireBeginsContaining">if set to <c>true</c> [fire begins containing].</param> /// <param name="fireEndsContaining">if set to <c>true</c> [fire ends containing].</param> public BepuTrigger(BepuPhysicWorld physicWorld, TriangleMeshObject triangleMesh, TriggerEvent evt, bool fireBeginsTouching, bool fireEndsTouching, bool fireBeginsContaining, bool fireEndsContaining) { this.volumeobject = new DetectorVolumeObject(physicWorld, triangleMesh); DetectorVolume detectorVolume = this.volumeobject.DetectorVolume; if (fireBeginsTouching) { detectorVolume.EntityBeginsTouching += new EntityBeginsTouchingVolumeEventHandler(detectorVolume_EntityBeginsTouching); } if (fireEndsTouching) { detectorVolume.EntityStopsTouching += new EntityStopsTouchingVolumeEventHandler(detectorVolume_EntityStopsTouching); } if (fireBeginsContaining) { detectorVolume.VolumeBeginsContainingEntity += new VolumeBeginsContainingEntityEventHandler(detectorVolume_VolumeBeginsContainingEntity); } if (fireEndsContaining) { detectorVolume.VolumeStopsContainingEntity += new VolumeStopsContainingEntityEventHandler(detectorVolume_VolumeStopsContainingEntity); } this.evt = evt; }
/// <summary> /// Removes the object. /// </summary> /// <param name="obj">The obj.</param> public override void RemoveObject(IPhysicObject obj) { if (obj.PhysicObjectTypes == PhysicObjectTypes.TRIANGLEMESHOBJECT) { TriangleMeshObject bo = (TriangleMeshObject)obj; bo.StaticMesh.Tag = null; space.Remove(bo.StaticMesh); objs.Remove(obj); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.InstancedTriangleMeshObject) { InstancedTriangleMeshObject bo = (InstancedTriangleMeshObject)obj; bo.InstancedMesh.Tag = null; space.Remove(bo.InstancedMesh); objs.Remove(obj); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.MobilePhysicObject) { MobileMeshObject bo = (MobileMeshObject)obj; bo.MobileMesh.Tag = null; space.Remove(bo.MobileMesh); objs.Remove(obj); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.SPECIALIZEDMOVER) { ObjectMover m = (ObjectMover)obj; space.Remove(m.BepuEntityObject.Entity); m.BepuEntityObject.Entity.CollisionInformation.Tag = null; space.Remove(m.Mover); space.Remove(m.Rotator); objs.Remove(m.BepuEntityObject); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.DETECTOROBJECT) { DetectorVolumeObject m = (DetectorVolumeObject)obj; space.Remove(m.DetectorVolume); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.TERRAIN) { TerrainObject t = obj as TerrainObject; space.Remove(t.Terrain); t.Terrain.Tag = null; objs.Remove(obj); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.CHARACTEROBJECT) { CharacterObject cc = (CharacterObject)obj; cc.CharacterController.Body.CollisionInformation.Tag = null; space.Remove(cc.CharacterController); objs.Remove(obj); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.FULLCHARACTEROBJECT) { FullCharacterObject cc = (FullCharacterObject)obj; cc.CharacterController.Body.CollisionInformation.Tag = null; space.Remove(cc.CharacterController); objs.Remove(obj); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.SPHERECHARACTEROBJECT) { SphereCharacterObject cc = (SphereCharacterObject)obj; cc.CharacterController.Body.CollisionInformation.Tag = null; space.Remove(cc.CharacterController); objs.Remove(obj); } else if (obj.PhysicObjectTypes == PhysicObjectTypes.GHOST) { //if (obj is AgregatedPhysicObject) //{ // objs.Remove(obj); // AgregatedPhysicObject ag = obj as AgregatedPhysicObject; // foreach (var item in ag.PhysicsObjects) // { // item.ObjectOwner = null; // this.RemoveObject(item); // } //} //else //{ objs.Remove(obj); //} } else { BepuEntityObject bo = (BepuEntityObject)obj; bo.Entity.CollisionInformation.Tag = null; space.Remove(bo.Entity); objs.Remove(obj); } }