Package me.iron.WarpSpace.Mod.HUD.client
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.Vector3fgetCurrentScreenResolution()get the resolution in pixels of currently used screen.static javax.vecmath.Vector3fgetDirection(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)get the vector from position a to position bstatic floatgetDistance(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)returns distance between two pointsstatic javax.vecmath.Vector3fpixelPosToRelPos(javax.vecmath.Vector3f pos, boolean onlyWidth)get relative position on screen from pixel positionstatic javax.vecmath.Vector3frelPosToPixelPos(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.Vector3frelPosToPixelPos(javax.vecmath.Vector3f pos, boolean onlyWidth)get pixel position from relative screen positon, use only screenwidth to scalestatic voidscaleDivide(javax.vecmath.Vector3f a, javax.vecmath.Vector3f b)static voidscaleMultiply(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)
-
Constructor Details
-
ScreenHelper
public ScreenHelper()
-
-
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 screenonlyWidth- 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 positiononlyWidth- 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 mutatedb- 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 ab- 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 ab- point b- Returns:
- euclidean distance as float
-