Exemplo n.º 1
0
        /// <summary>
        /// cast a ray from the target position to the camera position
        /// </summary>
        private DynamicsWorld.ClosestRayResultCallback CastRay(Vector3 derivedCam, Vector3 derivedTarget)
        {
            Vector3 from = derivedTarget;
            Vector3 axis = (from - derivedCam);
            axis.Normalise();
            Vector3 to = from - (axis * rayLength); //CameraNode.Position;

            var callback = new DynamicsWorld.ClosestRayResultCallback(from, to);
            callback.CollisionFilterMask = rayFilterGroup;
            world.RayTest(from, to, callback);

            return callback;
        }
Exemplo n.º 2
0
		/// <summary>
		/// Casts a ray downwards from the given kart
		/// </summary>
		/// <returns>The ray result callback</returns>
		private DynamicsWorld.ClosestRayResultCallback CastRay(Kart kart, float rayLength, DiscreteDynamicsWorld world) {
			// get a ray pointing downwards from the kart (-Y axis)
			Vector3 from = kart.ActualPosition + kart.ActualOrientation.YAxis; // have to move it up a bit
			Vector3 to = from - kart.ActualOrientation.YAxis * (rayLength + 1); // add 1 to compensate for the "moving up" we did to the "from" vector

			// make our ray
			var callback = new DynamicsWorld.ClosestRayResultCallback(from, to);
			// we only want the ray to collide with the environment and nothing else
			callback.CollisionFilterMask = rayFilterGroup;
			
			world.RayTest(from, to, callback);
#if DEBUG
			//MogreDebugDrawer.Singleton.DrawLine(from, to, ColourValue.Red);
#endif
			return callback;
		}