/// <summary>
        ///
        /// </summary>
        /// <param name="terrain"></param>
        public void Translate(JPerlinTerrain terrain)
        {
            float distance = currentSpeed * JGameWindow.Delta;

            float dX = distance * (Orientation.X / Orientation.Length);
            float dZ = distance * (Orientation.Z / Orientation.Length);

            upwardSpeed += GRAVITY * JGameWindow.Delta;
            base.IncreasePosition(dX, upwardSpeed * JGameWindow.Delta, dZ);
            float terrainHeight = terrain.GetHeightOfTerrain(base.Position.X, base.Position.Z);

            if (base.Position.Y < terrainHeight)
            {
                upwardSpeed   = 0;
                isInAir       = false;
                base.Position = new Vector3(Position.X, terrainHeight, Position.Z);
            }
        }
Example #2
0
        /// <summary>
        /// Determine whether point falls below Terrain.
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private Boolean IsUnderGround(Vector3 point)
        {
            JPerlinTerrain terrain = GetTerrain(point.X, point.Z);
            float          height  = 0;

            if (terrain != null)
            {
                height = terrain.GetHeightOfTerrain(point.X, point.Z);
            }
            if (point.Y < height)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }