Exemplo n.º 1
0
        /// <summary>
        /// This lets the consumer get notified when two bodies of the material type are colliding
        /// NOTE:  Currently, only one listener per matieral pair is supported
        /// </summary>
        public void SetCollisionCallback(int material1, int material2, CollisionStartHandler collisionStart, CollisionEndHandler collisionEnd)
        {
            string key = GetMaterialComboHash(material1, material2);

            if (_collisionListeners.ContainsKey(key))
            {
                // Newton 2.0 has a much better collision event system (when listening to the ContactProcess event, all I have is the material, not
                // bodies, so I have to keep track of bodies by material to make it easier on the consumer.  This is all based on the fact that I receive
                // all contact events in order for the current collision of two bodies, then I'll get a different ContactBegin/ContactProcess set for another
                // two bodies)
                throw new ApplicationException("Currently, only one event listener is allowed for each material pair -- upgrade to newton 2");
            }

            // Store the delegates for this material pair
            CollisionEventProps eventProps = new CollisionEventProps();

            eventProps.CollisionStart = collisionStart;
            eventProps.CollisionEnd   = collisionEnd;
            _collisionListeners.Add(key, eventProps);

            // Set up a callback for this material pair
            //NOTE:  The callback goes to my event listener.  I then make the args easier for the consumer, and call the delegates that were passed in
            _materialHelper.SetCollisionCallback(_materials[material1], _materials[material2], null, ContactBegin, ContactProcess, null);
        }
Exemplo n.º 2
0
		public void SetCollisionCallback(int material1, int material2, CollisionStartHandler collisionStart, CollisionEndHandler collisionEnd)
		{
			_materials.SetCollisionCallback(material1, material2, collisionStart, collisionEnd);
		}
Exemplo n.º 3
0
        /// <summary>
        /// This lets the consumer get notified when two bodies of the material type are colliding
        /// NOTE:  Currently, only one listener per matieral pair is supported
        /// </summary>
        public void SetCollisionCallback(int material1, int material2, CollisionStartHandler collisionStart, CollisionEndHandler collisionEnd)
        {
            string key = GetMaterialComboHash(material1, material2);
            if (_collisionListeners.ContainsKey(key))
            {
                // Newton 2.0 has a much better collision event system (when listening to the ContactProcess event, all I have is the material, not
                // bodies, so I have to keep track of bodies by material to make it easier on the consumer.  This is all based on the fact that I receive
                // all contact events in order for the current collision of two bodies, then I'll get a different ContactBegin/ContactProcess set for another
                // two bodies)
                throw new ApplicationException("Currently, only one event listener is allowed for each material pair -- upgrade to newton 2");
            }

            // Store the delegates for this material pair
            CollisionEventProps eventProps = new CollisionEventProps();
            eventProps.CollisionStart = collisionStart;
            eventProps.CollisionEnd = collisionEnd;
            _collisionListeners.Add(key, eventProps);

            // Set up a callback for this material pair
            //NOTE:  The callback goes to my event listener.  I then make the args easier for the consumer, and call the delegates that were passed in
            _materialHelper.SetCollisionCallback(_materials[material1], _materials[material2], null, ContactBegin, ContactProcess, null);
        }
Exemplo n.º 4
0
 public void SetCollisionCallback(int material1, int material2, CollisionStartHandler collisionStart, CollisionEndHandler collisionEnd)
 {
     _materials.SetCollisionCallback(material1, material2, collisionStart, collisionEnd);
 }