Class ScreenHelper

java.lang.Object
me.iron.WarpSpace.Mod.HUD.client.ScreenHelper

public class ScreenHelper
extends java.lang.Object
helper class that provides methods for scaling screenposititons according to resolution, etc.
  • Constructor Summary

    Constructors 
    Constructor Description
    ScreenHelper()  
  • Method Summary

    Modifier and Type Method Description
    static javax.vecmath.Vector3f getCurrentScreenResolution()
    get the resolution in pixels of currently used screen.
    static javax.vecmath.Vector3f getDirection​(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)
    get the vector from position a to position b
    static float getDistance​(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)
    returns distance between two points
    static javax.vecmath.Vector3f pixelPosToRelPos​(javax.vecmath.Vector3f pos, boolean onlyWidth)
    get relative position on screen from pixel position
    static javax.vecmath.Vector3f relPosToPixelPos​(javax.vecmath.Vector3f pos)
    adjust given position in % of screen to current resolution. center: (0.5,0.5,0) -- pxPos (1920/2,1080/2,0) (assuming current screen is full HD).
    static javax.vecmath.Vector3f relPosToPixelPos​(javax.vecmath.Vector3f pos, boolean onlyWidth)
    get pixel position from relative screen positon, use only screenwidth to scale
    static void scaleDivide​(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)  
    static void scaleMultiply​(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)
    multiplies every position of a with corresponding pos of b: (a.x * b.x, a.y * b.y, a. z * b.z)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • relPosToPixelPos

      public static javax.vecmath.Vector3f relPosToPixelPos​(javax.vecmath.Vector3f pos)
      adjust given position in % of screen to current resolution. center: (0.5,0.5,0) -- pxPos (1920/2,1080/2,0) (assuming current screen is full HD). creates new vector.
      Parameters:
      pos - relative position in percent on screen
      Returns:
      position in absolute pixels
    • relPosToPixelPos

      public static javax.vecmath.Vector3f relPosToPixelPos​(javax.vecmath.Vector3f pos, boolean onlyWidth)
      get pixel position from relative screen positon, use only screenwidth to scale
      Parameters:
      pos - relative position in percent on screen
      onlyWidth - only use screenwidht to scale pos vector
      Returns:
      position in absolute pixels
    • pixelPosToRelPos

      public static javax.vecmath.Vector3f pixelPosToRelPos​(javax.vecmath.Vector3f pos, boolean onlyWidth)
      get relative position on screen from pixel position
      Parameters:
      pos - pixel position
      onlyWidth - use only width for x and y(for quadratic scaling on resolutionchange)
      Returns:
      relative screenpos in percent
    • getCurrentScreenResolution

      public static javax.vecmath.Vector3f getCurrentScreenResolution()
      get the resolution in pixels of currently used screen.
      Returns:
      Vector3f (screenwidht, screenheight, 0)
    • scaleMultiply

      public static void scaleMultiply​(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)
      multiplies every position of a with corresponding pos of b: (a.x * b.x, a.y * b.y, a. z * b.z)
      Parameters:
      a - Vector to be mutated
      b - vector which is used to mutate a
    • scaleDivide

      public static void scaleDivide​(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)
    • getDirection

      public static javax.vecmath.Vector3f getDirection​(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)
      get the vector from position a to position b
      Parameters:
      a - point a
      b - point b
      Returns:
      new vector a--b
    • getDistance

      public static float getDistance​(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)
      returns distance between two points
      Parameters:
      a - point a
      b - point b
      Returns:
      euclidean distance as float