Class Utils.VectorUtils

java.lang.Object
net.risingworld.api.utils.Utils.VectorUtils
Enclosing class:
Utils

public abstract static class Utils.VectorUtils extends Object
Vector functions.
  • Constructor Details

    • VectorUtils

      public VectorUtils()
  • Method Details

    • getXZInFrontOfPlayer

      public static Vector3f getXZInFrontOfPlayer(Player player, float distance)
    • getXZInFrontOfPlayer

      public static Vector3f getXZInFrontOfPlayer(Player player, float distance, Vector3f storeTo)
    • getXYZInFrontOfPlayer

      public static Vector3f getXYZInFrontOfPlayer(Player player, float distance)
      Gets the position in front of the player (with the given distance to the player). This function takes the full player view direction into account, i.e. if the player looks up in the sky, the resulting position is above the player.
      Parameters:
      player - the player.
      distance - the desired distance between the player and the resulting position.
      Returns:
      a new vector representing the position in front of the player.
      See Also:
    • getXYZInFrontOfPlayer

      public static Vector3f getXYZInFrontOfPlayer(Player player, float distance, Vector3f storeTo)
      Gets the position in front of the player (with the given distance to the player). This function takes the full player view direction into account, i.e. if the player looks up in the sky, the resulting position is above the player.
      Parameters:
      player - the player.
      distance - the desired distance between the player and the resulting position.
      storeTo - the vector you want to store the result in. If null is provided, a new vector will be created.
      Returns:
      the position in front of the player.
      See Also:
    • getDirection

      public static Vector3f getDirection(Vector3f from, Vector3f to)
      Gets the direction between two points (from -> to) as a normalized vector (unit vector, i.e length == 1).
      Parameters:
      from - the start position.
      to - the end position.
      Returns:
      a new unit vector representing the direction between position "from" and position "to"
    • getDirection

      public static Vector3f getDirection(Vector3f from, Vector3f to, Vector3f storeTo)
      Gets the direction between two points (from -> to) as a normalized vector (unit vector, i.e length == 1).
      Parameters:
      from - the start position.
      to - the end position.
      storeTo - the vector you want to store the resulting direction in. If null is provided, a new vector will be created.
      Returns:
      a unit vector representing the direction between position "from" and position "to"
    • getAlignedDirection

      public static Vector3f getAlignedDirection(Vector3f direction, Vector3f normal)
      Gets a direction vector aligned to a normal.
      Parameters:
      direction - the original direction (as unit vector).
      normal - the normal (as unit vector) you want to align the direction to.
      Returns:
      a unit vector representing the new direction, based on the original direction and the provided normal.
      Example: Get rotation based on a direction and ground normal
      1Vector3f direction = new Vector3f(0f, 0f, 1f);
      2Vector3f normal = new Vector3f(0f, 1f, 1f).normalizeLocal();
      3
      4//Get aligned direction
      5Vector3f newDirection = Utils.VectorUtils.getAlignedDirection(direction, normal);
      6
      7//Use direction and normal for quaternion lookAt method
      8Quaternion rotation = new Quaternion().lookAt(newDirection, normal);
    • getAlignedDirection

      public static Vector3f getAlignedDirection(Vector3f direction, Vector3f normal, Vector3f storeTo)